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

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

    static class BMixJuice {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int n = s.nextInt(), k = s.nextInt();
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = s.nextInt();
            long sum = 0;
            Arrays.sort(a);
            for (int i = 0; i < k; i++)
                sum += a[i];
            w.println(sum);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32720
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));
$a1 = array_slice($a, 0, $n);
$a2 = array_slice($a, -$n);

$q1 = new SplMinHeap();
$q2 = new SplMaxHeap();
$s = 0;
foreach ($a1 as $x) {
	$q1->insert($x);
	$s += $x;
}
$s1[$n] = $s;
$s = 0;
foreach ($a2 as $x) {
	$q2->insert($x);
	$s += $x;
}
$s2[$n*2] = $s;
for ($k = $n + 1; $k <= $n * 2; $k++) {
	$q1->insert($a[$k-1]);
	$v = $q1->extract();
	$s1[$k] = $s1[$k-1] + $a[$k-1] - $v;
}
for ($k = $n * 2 - 1; $k >= $n; $k--) {
	$q2->insert($a[$k]);
	$v = $q2->extract();
	$s2[$k] = $s2[$k+1] + $a[$k] - $v;
}
$max = PHP_INT_MIN;
for ($k = $n; $k <= $n * 2; $k++) {
	$s = $s1[$k] - $s2[$k];
	if ($max < $s) $max = $s;
}
echo $max;

Measured memory_bytes: 49956
#!/usr/bin/env python3
import sys
import functools
INF = float("inf")

MOD = 1000000007  # type: int


@functools.lru_cache(maxsize=None)
def cmb(n, r):
    r = min(r, n-r)
    if r == 0:
        return 1
    if r == 1:
        return n

    numer = [n - r + k + 1 for k in range(r)]
    denom = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denom[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numer[k - offset] /= pivot
                denom[k] /= pivot

    result = 1
    for k in range(r):
        if numer[k] > 1:
            result *= int(numer[k])
            result %= MOD

    return result % MOD


def solve(N: int, K: int):

    for i in range(1, K+1):
        if N-K+1 < i:
            ans = 0
        else:
            ans = cmb(N-K+1, i)
        ans *= cmb(K-1, i-1)
        ans %= MOD
        print(ans)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4496
S = [int(x) for x in input()][::-1]
n = len(S) - 1
ans = S[0] * 2 ** n
for i in range(2 ** n):
    t = 1
    for j in range(n):
        if i >> j & 1:
            t = 1
        else:
            t *= 10
        ans += S[j + 1] * t
print(ans)

Measured memory_bytes: 39280
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            Func<int, int> func = null;
            func = (n) =>
            {
                if (n == 1) return 1;
                return n + func(n - 1);
            };

            Println(func(ReadInt()));
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());
        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}



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

int main() {
  
  int N;
  cin >> N;
  vector<int> bipa(N);
  
  for (int i = 0; i < N; i ++) {
    cin >> bipa.at(i);
  }
  
  int now = 0, c = 0;
  
  for (;;) {   
  	if (now == 1) {
      cout << c << endl;
      break;
    }
    if (c >= N) {
      cout << -1 << endl;
      break;
    }
    c++;
    now = bipa[now];
    now -= 1;
    //cout << now << endl;
  }
}


Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        string s = Console.ReadLine();
        if (s == "RRR") Console.WriteLine(3);
        else if (s.StartsWith("RR") || s.EndsWith("RR")) Console.WriteLine(2);
        else if (s.Contains("R")) Console.WriteLine(1);
        else Console.WriteLine(0);
    }
}

Measured memory_bytes: 26080
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int H, W; cin >> H >> W;
	char pixel[H + 2][W + 2] = {0};
	rep (i, H + 2) rep (j, W + 2) pixel[i][j] = '#';

	for (int i = 1; i <= H; ++i){
		for (int j = 1; j <= W; ++j){
			cin >> pixel[i][j];
		} // end for
	} // end for

	rep (i, H + 2){
		rep (j, W + 2){
			cout << pixel[i][j];
		} // end rep
		cout << endl;
	} // end rep	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int a[5],k;
 	for(int i=0;i<5;i++)
 		cin >> a[i];
 	cin >> k;

 	for(int i=0;i<5;i++){
 		for(int j=0;j<5;j++){
 			if(k < abs(a[j] - a[i])){
 				cout << ":(" << endl;
 				return 0;
 			}
 		}
 	}
 	cout << "Yay!" << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define ld long double
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define arrin(x,n) int x[n]; for(int o=0;o<n;o++) cin>>x[o]
#define arrout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<'='<<x<<endl
#define deb2(x,y) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<endl
#define deb3(x,y,z) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<" "<<#z<<'='<<z<<endl
#define debarr(arr,n) for(int o=0;o<n;o++) deb2(o,arr[o])
const double pi = 3.14159265358979323846;

ll power(ll a, ll b){//a^b
    ll res=1;
    //a=a%MOD;
    while(b>0){
        if(b&1)
		{res=(res*a);
		//res%=MOD;
		b--;}
        a=(a*a);
        //a%=MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int C(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}

void solve()
{

	int i=0,j=0,k=0,m,n,p,sum=0,cnt=0;
	int l,r,d;
	cin>>l>>r>>d;
	
	cout<<(r/d)-(l-1)/d<<endl;
	
	
}
int32_t main() {
    fast
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w+", stdout);
	//cout<<fixed<<setprecision(6);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  

Measured memory_bytes: 3576
import sys

def main():
    N = int(sys.stdin.readline())
    S = [tuple(sorted(x.rstrip())) for x in sys.stdin.readlines()]

    dic = {}
    for i, s in enumerate(S):
        if s not in dic:
            dic[s] = {i:1}
        else:
            dic[s][i] = len(dic[s])+1

    count = 0
    for i, s in enumerate(S):
        count += len(dic[s]) - dic[s][i]

    print(count)

if __name__=='__main__':
    main()

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

const char nl = '\n';

int counter = 0;

void solve()
{
    int n; cin >> n;
    cout << (n % 1000 == 0 ? 0 : (n / 1000 + 1) * 1000 - n) << nl;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N), sum(N + 1, 0);

    rep(i, N) {
        cin >> A[i];
    }

    sort(all(A));

    rep(i, N) sum[i + 1] = sum[i] + A[i];
    // 選択数がM以上となる最小のxを探す
    ll x = 0, ng = 100000 * N + 1;
    while (1 < ng - x) {
        ll mid = (x + ng) / 2;
        ll num = 0;
        for (int i = N - 1; i >= 0; i--) {
            num += A.end() - lower_bound(all(A), mid - A[i]);
        }
        if (M <= num) {
            x = mid;
        }
        else {
            ng = mid;
        }
    }


    ll ans = 0;
    ll cnt = 0;
    rep(i, N) {
        ll ind = upper_bound(all(A), x - A[i]) - A.begin();
        cnt += N - ind;

        ans += A[i] * (N - ind) + sum[N] - sum[ind];

    }

    ans += x * (M - cnt);

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

Measured memory_bytes: 1792
n = int(input())
l = [input() for _ in range(n)]
d ={}
for i in l:
    if i in d:
        d[i] +=1
    if i not in d:
        d[i] =1
        
dic = sorted(d.items(), key=lambda x:x[1],reverse=True)
a = dic[0][1]
lis = []
for j in dic:
    if j[1] == a:
        lis.append(j[0])
    else:
        break
        
answerlist = sorted(lis)
[print(i) for i in answerlist]

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

int main() {
    int n;
    double ans=0;
    cin>>n;
    vector<double> x(n);
    vector<string> u(n);
    rep(i,n) cin>>x[i]>>u[i];
    rep(i,n) {
        if (u[i]=="JPY") ans+=x[i];
        else ans+=380000.0*x[i];
    }
    printf("%.6f\n",ans);
}


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

using namespace std;

int A, B, C, D;

int main() {
	cin >> A >> B >> C >> D;

	if (A + B > C + D) {
		cout << "Left";
	}
	else if (A + B == C + D) {
		cout << "Balanced";
	}else{
		cout << "Right";
	}
	getchar();
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);
		int counter = 0;

		String temp = scanner.nextLine();
		if(String.valueOf(temp.charAt(0)).equals("1")) {
			counter++;
		}
		if(String.valueOf(temp.charAt(1)).equals("1")) {
			counter++;
		}
		if(String.valueOf(temp.charAt(2)).equals("1")) {
			counter++;
		}

		System.out.println(counter);

		scanner.close();


	}

}


Measured memory_bytes: 21844
// AOJ 2135 Reverse a Road
// 2018.2.26 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 15000
typedef struct { short t, s, r; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && (que[l].t < que[i].t ||
		que[l].t == que[i].t && que[l].r < que[i].r)) min = l; else min = i;
	if (r < qsize && (que[r].t < que[min].t ||
		que[r].t == que[min].t && que[r].r < que[min].r)) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t, int r)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t, que[i].r = r;
	while (i > 0 && (que[min = PARENT(i)].t > que[i].t ||
		   que[min].t == que[i].t && que[min].r > que[i].r)) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

short hi[1002], to[1002][100], no[1002][100];
char mk[1002][1002][2];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int dijkstra(int *rno, int start, int goal)
{
	int i, s, t, r, e, k;

	memset(mk, 0, sizeof(mk));
	qsize = 0;
	enq(start, 0, 0);
	while (qsize) {
		s = que[0].s, t = que[0].t, r = que[0].r, deq();
		if (s == goal) { *rno = r; return t; }

		if (r == 0) {
			for (i = 0; i < hi[s]; i++) {
				e = to[s][i], k = no[s][i];
				if (k > 0) {
					if (!mk[e][k][0]) mk[e][k][0] = 1, enq(e, t+1, 0);
				} else {
					if (!mk[s][-k][1]) mk[s][-k][1] = 1, enq(e, t+1, -k);
				}
			}
		} else {
			for (i = 0; i < hi[s]; i++) {
				e = to[s][i], k = no[s][i];
				if (k > 0 && !mk[e][k][1]) mk[e][k][1] = 1, enq(e, t+1, r);
			}
		}
	}
	return -1;
}

int main()
{
	int N, S, T, M, a, b, i, k, ans;

	while (N = in()) {
		N++, S = in(), T = in();
		M = in();

		memset(hi, 0, N << 1);
		memset(mk, 0, sizeof(mk));
		for (i = 1; i <= M; i++) {
			a = in(), b = in();
			if (mk[a][b][0]) continue;
			mk[a][b][0] = 1;
			k = hi[a]++, to[a][k] = b, no[a][k] =  i;
			k = hi[b]++, to[b][k] = a, no[b][k] = -i;
		}

		ans = dijkstra(&k, S, T);
		printf("%d %d\n", ans, k);
	}
	return 0;
}


Measured memory_bytes: 4124
#include<iostream>
#include<cstdio>
#include<cmath>
#define MAX 1100
int main(){
    int n=1;
    int n2 =0;
    int value[MAX];
    int sum =0;
    double ave = 0.0;
    double sigma;
    scanf("%d",&n);
    while(n != 0){
        
        n2 = n;
        for(int i=0;i<n;i++){
            scanf("%d",&value[i]);
            sum += value[i];
        }
        ave = (double)sum / (double)n2 ;
        for(int j=0;j<n;j++){
            sigma += ((double)value[j] - ave)*((double)value[j] - ave);
        }
            sigma = sigma/n;
            sigma = sqrt(sigma);
            printf("%.7f\n",sigma);
            sum = 0;
            ave = 0;
            sigma =0;
            scanf("%d",&n);
    }
    return 0;
}



Measured memory_bytes: 3216
using System;
using System.Linq;
namespace EasyBBQ
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			var combSetNum = int.Parse (Console.ReadLine ());
			var lengths = Console.ReadLine ().Split (' ');
			var lengthsInt = lengths.Select (_ => int.Parse (_)).ToList ();

			lengthsInt = lengthsInt.OrderByDescending (_ => _).ToList ();
			var totalNum = 0;
			for (int i = 0; i < combSetNum; i++) {
				totalNum += lengthsInt [1];
				lengthsInt.RemoveAt (0);
				lengthsInt.RemoveAt (0);
			}
			Console.WriteLine (totalNum);
		}
	}
}


Measured memory_bytes: 3032
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



int gcd(int a, int b)
{
	if (a%b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a%b));
	}
}

signed main() {
	int N, X;
	vector<int>list;

	cin >> N >> X;

	for (int i = 0; i < N; i++) {
		int num;
		cin >> num;
		list.push_back(num);
	}

	if (N == 1) {
		cout << abs(X - list[0]) << endl;
		return 0;
	}

	list.push_back(X);
	sort(list.begin(), list.end());
	
	vector<ll>list2;

	for (int i = 0; i < list.size() - 1; i++) {
		ll sa = abs(list[i + 1] - list[i]);
		list2.push_back(sa);
	}

	ll minn = 9999999999;

	for (int i = 0; i < list2.size() - 1; i++) {
		ll num1 = gcd(list2[i], list2[i + 1]);
		if ( num1 < minn) {
			minn = num1;
		}
	}

	cout << minn << endl;



	return 0;
}

Measured memory_bytes: 2548
#include<iostream>
using namespace std;
long l,a[1<<17],n;
main()
{
	cin>>n>>l;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(i&&a[i-1]+a[i]>=l)
		{
			cout<<"Possible\n";
			for(int j=1;j<i;j++)cout<<j<<endl;
			for(;n-->i;)cout<<n<<endl;
			return 0;
		}
	}
	cout<<"Impossible"<<endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 100005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x){return x*x;}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////

struct graph{ 
    vi v;
};
int path[55][55]; // u-v edge --> xth edge .
graph G[55];
int n,m;
ll mask = 0;
bool dfs(int u,int par,int v){
    if(u == v){
        return true;
    }
    for(int i =0;i<G[u].v.size();++i){
        int to = G[u].v[i];
        if(to == par){
            continue;
        }
        if(dfs(to,u,v)){
            mask |= (1ll<<path[u][to]);
            return true;
        }
    }
    return false;
}

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    f(n-1){
        int u,v;   cin>>u>>v;
        G[u].v.pb(v);
        G[v].v.pb(u);
        path[u][v] = path[v][u] = i;
    }
    cin>>m;
    ll arr[25];   // will store the mask . and it's set bits will show that ith edge belong to this u to v path.
    f(m){                    
        int u,v;  cin>>u>>v;
        mask = 0;
        dfs(u,0,v);
        arr[i]= mask;   // storing the mask.
        
    }
    ll ans = 0;
    for(int i = 0;i<(1ll<<m);++i){   // m total instructions . if one violet any of them that will be a counter part.
        ll count = 0;
        for(int j =0 ;j<m;++j){      // m set bits represent that ith instrction is being voileted.
            if(i&(1ll<<j)){
                count |= arr[j];     // so number of edges belongs to that u to v path will be added.
            }
        }
        ll sets = __builtin_popcountll(count);
        ll val = (1ll<<(n-1-sets));    // these sets edges will have only one choice white and others have 2^(n-1-c) possibilities. 
        ll total = __builtin_popcount(i);  
        if(total%2){
            ans -= val;
        }
        else{
            ans += val;
        }
    }
    cout << ans;



    return 0;
}

    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
//char a[55][55];
int dx[] = {1,0,-1,0,1,1,-1,-1};
int dy[] = {0,1,0,-1,1,-1,-1,1};
ll a[100];
int main()
{
	dhoom;
	int a , b , c , d;
	cin >> a >> b >> c >> d;
	if(a + b > c + d)
		cout << "Left" << endl;
	else if(a + b < c + d)
		cout << "Right" << endl;
	else 
		cout << "Balanced" << endl;
	return 0;
}


Measured memory_bytes: 256
class WeightUnionfindtree:
    def __init__(self,number):
        self.par = [i for i in range(number)]
        self.rank = [0]*(number)
        self.weight=[0]*(number)

    def find(self,x):#親を探す xの親を示す
        if self.par[x] ==x:
            return x
        else:
            r = self.find(self.par[x])
            self.weight[x]+=self.weight[self.par[x]]
            self.par[x]=r
            return self.par[x]
        
    def weighted(self,x):
        self.find(x)
        return self.weight[x]
    
    def union(self,x,y,w):#weight(y) = weight(x) + w となるように x と y をマージする
        w += self.weighted(x)
        w -= self.weighted(y)
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return 
        if self.rank[px]<self.rank[py]:
            self.par[px]=py
            self.weight[px]=-w
        else:
            self.par[py]=px
            self.weight[py] = w
        if self.rank[px]==self.rank[py]:
            self.rank[px] +=1
    
    def connect(self,x,y):#親が同じかみる
        return self.find(x)==self.find(y)
    
    def diff(self,x,y):
        return self.weighted(y)-self.weighted(x)
    
N,M = map(int,input().split())
Tree = WeightUnionfindtree(N)
ans = 'Yes'
for i in range(M):
    L,R,D = map(int,input().split())
    if Tree.connect(L-1,R-1):
        if Tree.diff(L-1,R-1)!=D:
            ans = 'No'
    else:
        Tree.union(L-1,R-1,D)
print(ans)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b;
  cin >> a >> b;
  
  if(a == b) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

K = ri()
S = rs()

if len(S) <= K:
	print(S)
else:
	print(S[:K]+'...')


Measured memory_bytes: 62012
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i]; a[i] -= i + 1;
  }
  sort(a.begin(), a.end());
  int best = a[n / 2];
  long long ans = 0;
  for(int i = 0; i < n; i++) ans += abs(a[i] - best);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    int ans = ((n - 1) / x + 1) * t;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
using Graph = vector<vector<int>>;
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; }
const int INF = 1000000000;
const int MOD = 1000000007;

typedef pair<int, int> P;
int myAbs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}
/*
vector<bool> seen;
void dfs(const Graph& G, int v, int count) {
    seen[v] = true;
    count = 0;
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue;
        if (count > 2) continue;
        count++;
        cout << count << ":" << next_v << endl;
        dfs(G, next_v, count);
    }
}*/

typedef pair<int, int> P;

int main() {
    int N,M; cin >> N >> M;
    int K[11], S[11][11], amari[11];
    
    for (int i = 0; i < M; i++) {
        cin >> K[i];
        for (int j = 0; j < K[i]; j++) {
            cin >> S[i][j];
            S[i][j]--;
        }
    }
    for (int i = 0; i < M; i++) cin >> amari[i];
    int ans = 0;
    int count = 0;
    bool ok = true;
    
    for (int tmp = 0; tmp < (1 << N); tmp++) {
        bitset<10> B(tmp);
        //電球ごとに見ていく
        for (int i = 0; i < M; i++) {
            count = 0;
            //電球についているスイッチごとに見ていく
            for (int j = 0; j < K[i]; j++) {
                if (B.test(S[i][j])) count++;
            }
            if (count % 2 != amari[i]) {
                ok = false;
                break;
            }
        }
        if (ok) ans++;
        ok = true;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)   
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<cstdlib>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds; 
//#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef long double ld;
typedef vector < pair < ll, ll > > vpll;
#define Boost() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define forn(i,n) for (ll i = 0; i < n; i++)
#define fo(i,n) for (ll i = 1; i <= n; i++)
#define fore(i,l,r) for (ll i = l; i <= r; i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define back(c,it) for(auto it=(c).rbegin(); it!=(c).rend(); it++)
#define fi first
#define se second
#define MOD 998244353
#define MAX 1000000007
ll power(ll a,ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;}a=(a*a)%MOD;b>>=1;}return res;}
ll fact[500009];
ll fermat_inv(ll y){return power(y,MOD-2);}
ll nCrMod(ll n, ll r){ ll p=fact[n];ll q=(fact[r]*fact[n-r])%MOD;return (p*fermat_inv(q))%MOD;} 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
const ld PI = acos(-1.0);
vector<int> g[200009];

  int main(){
      #ifndef ONLINE_JUDGE
      freopen("input.cpp","r",stdin);
      freopen("output.cpp","w",stdout);
      #endif
      Boost();
      int t;
      //cin>>t;
      t=1;
      int t1=t;
      while(t--)
      { 
        ll n;
        cin>>n;
        string s;
        cin>>s;
        ll c1=0;
        ll c2=0;
        forn(i,n)
        {
          if(s[i]=='R')
            c1++;
          else
            c2++;
        }
        ll c3=0;
        fo(i,c1)
        {
          if(s[i-1]!='R')
            c3++;
        }
        cout<<min(c1,min(c2,c3))<<endl;
      }
      return 0;
      }
  

Measured memory_bytes: 8396
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, m = ns()

    tmp = abs(n - m)
    if tmp > 1:
        print(0)
        exit(0)

    def for_factorial(n):
        val = 1
        for i in range(2, n + 1):
            val *= i
            val %= MOD
        return val

    n_fact = for_factorial(n)
    m_fact = for_factorial(m)

    if tmp == 1:
        ans = n_fact * m_fact % MOD
    else:
        ans = 2 * n_fact * m_fact % MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    clock_t start = clock();
    
    ll d;
    cin >> d;
    vector<ll> c(26);
    for (ll i = 0; i < 26; i++) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; i++) {
        for (ll j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    
    vector<ll> w(0);
    for (ll i = 0; i < 26; i++) {
        w.push_back(i);
        for (ll j = 0; j < c[i]; j++) {
            w.push_back(i);
        }
    }
    ll m = w.size();
    
    random_device rand;
    vector<ll> ans(d);
    for (ll i = 0; i < d; i++) ans[i] = w[rand() % m];
    
    auto calc_score = [&] () {
        vector<ll> v(26, -1);
        ll ret = 0;
        for (ll i = 0; i < d; i++) {
            v[ans[i]] = i;
            ret += s[i][ans[i]];
            for (ll j = 0; j < 26; j++) {
                ret -= c[j] * (i - v[j]);
            }
        }
        return ret;
    };
    
    ll score = calc_score();
    
    auto f = [&] () {
        double prob = pow((clock() - start) / CLOCKS_PER_SEC / 1.95, 4) + 1;
        return ((double)rand() / RAND_MAX < prob);
    };
    
    while (clock() - start <= 1.95 * CLOCKS_PER_SEC) {
        ll change_at1 = rand() % d, into1 = w[rand() % m];
        ll change_at2 = rand() % d, into2 = w[rand() % m];
        ll memo1 = ans[change_at1], memo2 = ans[change_at2];
        ll memo_score = score;
        ans[change_at1] = into1; ans[change_at2] = into2;
        score = calc_score();
        if (score < memo_score && f()) {
            ans[change_at1] = memo1; ans[change_at2] = memo2;
            score = memo_score;
        }
    }
    
    for (ll i = 0; i < d; i++) cout << ans[i] + 1 << endl;
    xout << score << endl;
}

Measured memory_bytes: 4264
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,a[105],ans;
double x;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++) 
	    cin>>a[i],x+=a[i];
	x=x/m/4;
    sort(a+1,a+1+n);
    if(a[n-m+1]>=x) cout<<"Yes";
    else cout<<"No";
    return 0;
}

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

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

    long long min_val = 100000000000;
    for (long long i=0;i<n;i++){
        if (monsters[i] < min_val){
            min_val = monsters[i];
        }
    }

    bool odd = false;
    bool all_same = true;
    for(long long i=0;i<n;i++){
        if (monsters[i] % 2 == 1){
            odd = true;
            break;
        }
    }
    for (long long i=1;i<n;i++){
        if (monsters[0] != monsters[i]){
            all_same = false;
            break;
        }
    }

    if (odd && all_same){
        cout << min_val <<endl;
        return 0;

    }

    // if (odd){
    //     cout << 1 << endl;
    //     return 0;
    // }


    while (true){
        bool all_divided = true;
        long long temp_min = min_val;
        for (long long i=0;i<n;i++){
            if (monsters[i] % min_val != 0){
                all_divided = false;
                if (monsters[i] % min_val < temp_min){
                    temp_min = monsters[i] % min_val;
                }
            }
        }
        min_val = temp_min;
        if (all_divided){
            break;
        }
    }
    cout << min_val << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,m,p[100005],ans,l[100005],r[100005];
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>l[i]>>r[i];
    }
    sort(l,l+m);
    sort(r,r+m);
    if(r[0]-l[m-1]+1>0)cout<<r[0]-l[m-1]+1<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 1152
a,b=map(int,input().split())
if a*b<0:
  print(1+abs(a+b))
elif a*b==0:
  print((a>0 or b<0)+abs(a)+abs(b))
elif a==b:
  print(0)
else:
  print(max(a-b+2,b-a))

Measured memory_bytes: 3060
import collections
S=list(input())
T=list(input())
values1=[]
values2=[]
flag=1

c=collections.Counter(S)
values1=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
c2=collections.Counter(T)
values2=list(c2.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)

values1.sort()
values2.sort()
#print(values2,values1)
if len(values2)!=len(values1):
    flag=0
else:
    for i in range(len(values2)):
        if values1[i]!=values2[i]:
            flag=0
            break
if flag==0:
    print("No")
else:
    print("Yes")

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

int main(){
  /*
  string s;
  cin >> s;
  int n = s.size();
  vector<int> a(n);
  rep(i, n) a.at(i) = s.at(i) - '0';
  */
  
  int n;
  cin >> n;
  vector<int> a(4);
  vector<char> op(3);
  rep(i, 4) {
    a.at(i) = n % 10;
    n /= 10;
  }
  
  reverse(a.begin(), a.end());
  
  for(int i = 0; i < (1<<3); i++){
    int sum = a.at(0);
    for(int j = 0; j < 3; j++){
      if(i & (1<<j)) {
        sum += a.at(j+1);
        op.at(j) = '+';
      } else {
        sum -= a.at(j+1);
        op.at(j) = '-';
      }
    }
    
    if(sum == 7) break;    
  }
  
  cout << a.at(0);
  rep(i, 3) cout << op.at(i) << a.at(i+1);
  cout << "=7" << endl;
    
}

Measured memory_bytes: 256
import typing

class DSU:
    '''
    Implement (union by size) + (path compression)
    Reference:
    Zvi Galil and Giuseppe F. Italiano,
    Data structures and algorithms for disjoint set union problems
    '''

    def __init__(self, n: int = 0):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        x = self.leader(a)
        y = self.leader(b)

        if x == y:
            return x

        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x

        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x

        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n

        if self.parent_or_size[a] < 0:
            return a

        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a: int) -> int:
        assert 0 <= a < self._n

        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> typing.List[typing.List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]

        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)

        return list(filter(lambda r: r, result))

N, Q = map(int, input().split())
dsu = DSU(N)

for _ in range(Q):
    t, u, v = map(int, input().split())
    if t == 0:
        # add line
        dsu.merge(u, v)
    else:
        # concat
        if dsu.same(u, v):
            print(1)
        else:
            print(0)


Measured memory_bytes: 12748
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int k, x;
    cin >> k >> x;
    for (int i = -1000000; i <= 1000000; i++)
    {
        if (abs(x - i) < k)
            cout << i << " ";
    }
    cout << endl;
}

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

int main() {
  string s;
  cin >> s;
  int N = s.size();
  for(int i = 0; i < N - 1; i++) {
    if(s[i] == 'B' && s[i + 1] == 'C') {
      s[i] = 'D';
      s[i + 1] = 'E';
    }
    if(s[i] == 'E') {
      s.erase(s.begin() + i);
      i--;
    }
  }
  N = s.size();
  int A_count = 0;
  long ans = 0;
  int i = 0;
  while(i < N) {
    if(s[i] == 'A') {
      A_count++, i++;
      continue;
    }
    if(s[i] == 'D') {
      ans += A_count;
      i++;
      continue;
    }
    A_count = 0;
    i++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
n,m = map(int,input().split())
h = list(map(int,input().split()))
out = [1 for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  if h[a] <= h[b]:
    out[a] = 0
  if h[a] >= h[b]:
    out[b] = 0
#print(out)
print(sum(out))

Measured memory_bytes: 84916
n=int(input())
l=sorted(list(map(int,input().split())))

num=(l[0]+l[1])/2
l.pop(0)
l.pop(0)
if len(l) > 0:
  for i in range(n-2):
    num=(num+l[0])/2
    l.pop(0)
  
print(num)

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

vector<ll> pw2(51,1);
vector<ll> pw10(19,1);

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll myceil(ll x,ll y){
	if(x<=y) return 1;
	else if(x%y==0) return x/y;
	else return x/y+1;
}

//a,b x
int main(){
	ll N; cin>>N;
	vector<ll> H(N);
	rep(i,N) cin>>H[i];
	ll ma=0;
	rep(i,N){
		if(H[i]<=ma-2){
			cout<<"No";
			return 0;
		}
		ma=max(ma,H[i]);
	}
	cout<<"Yes";
}

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

using vint_t = vector<int>;

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

  vint_t ablist(N+10, 0);

  for (int a = 1; a <= N; a++){
    for (int b = 1; b <= N; b++){
      int ab = a*b;
      if (ab <= N){
	ablist[ab]++;
      }else{
	break;
      }
    }
  }
  
  int ans = 0;
  for (int c = 1; c < N; c++){
    int ab = N-c;
    ans += ablist[ab];
  }

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


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[7] = {1, 3, 5, 7, 8, 10, 12};
ll B[4] = {4, 6, 9, 11};
ll C[1] = {2};

int main() {
    ll x, y;
    cin >> x >> y;
    {
        bool X = false;
        bool Y = false;
        REP(i, 7) {
            if (A[i] == x)
                X = true;
            if (A[i] == y)
                Y = true;
        }
        if (X && Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    {
        bool X = false;
        bool Y = false;
        REP(i, 4) {
            if (B[i] == x)
                X = true;
            if (B[i] == y)
                Y = true;
        }
        if (X && Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    {
        bool X = false;
        bool Y = false;
        REP(i, 1) {
            if (C[i] == x)
                X = true;
            if (C[i] == y)
                Y = true;
        }
        if (X && Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<cstring>
#include<cstdio>
using namespace std;
	struct slayer {
		int S;				//S=ri-l
		int Li;
	};
int main() {
	char ch;
	stack<int> cal;
	stack<slayer> area;
	int sum = 0;
	for (int i = 0; ch=getchar(); i++) {
		if (ch == '\\') {
			cal.push(i);
		}
		else if (ch == '/') {
			if (cal.empty())
				continue;
			
			int temp = cal.top();			

			slayer s{0,temp};
			
			while (!area.empty() && area.top().Li > cal.top()) {
				s.S += area.top().S;
				area.pop();
			}
			cal.pop();
			s.S += (i - temp);
			sum += (i - temp);
			area.push(s);
		}
		else if (ch == '\n')break;
	}
	if (!area.empty()) {
		cout << sum << endl;
		cout << area.size() << " ";
		int* arr = new int[area.size()];
		int i;
		for (i = 0; !area.empty(); i++) {
			arr[i] = area.top().S;
			area.pop();
		}
		i--;
		for (; i > 0; i--) {
			cout << arr[i] << " ";
		}
		cout << arr[0] << endl;
	}
	else {
		cout << 0 << endl<<0<<endl;
	}
	return 0;
}


Measured memory_bytes: 3168