akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int N;
int main(){
	int A,B;
	cin>>A>>B;
	int SZ=100;
	string ans[SZ];
	for(int i=0;i<SZ;i++){
		if(i%2==0){
			for(int j=0;j<SZ-1;j++)ans[i]+='.';
			ans[i]+='#';
		}else{
			for(int j=0;j<SZ-1;j++)ans[i]+='#';
			ans[i]='.'+ans[i];
		}
	}
	A--;B--;
	int cnt=0,now=0;
	while(A){
		ans[now][SZ-3-cnt*2]='#';
		cnt++;
		A--;
		if(cnt==15)now+=2,cnt=0;
	}
	now=1,cnt=0;
	while(B){
		ans[now][2+cnt*2]='.';
		cnt++;
		B--;
		if(cnt==15)now+=2,cnt=0;
	}
	cout<<SZ<<" "<<SZ<<endl;
	rep(i,SZ)cout<<ans[i]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int A,B;
cin>>A>>B;
if(A==1) A=14;
if(B==1) B=14;
if(A>B)
  cout<<"Alice";
if(A<B)
  cout<<"Bob";
if(A==B)
  cout<<"Draw";
system("pause");
return 0;
}

Measured memory_bytes: 504
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int K = s.nextInt();
        int N = s.nextInt();
        int A[] = new int[N];
        int A_min[] = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = s.nextInt();
        }

        culRoot(A, A_min, K, N);
        Arrays.sort(A_min);

        System.out.println(A_min[0]);

        s.close();
    }

    public static void culRoot(int A[], int A_min[], int K, int N) {
        for (int i = 0; i < N; i++) {
            if (i == 0) {
                A_min[i] = min(A[N - 1] - A[0], A[0] + K - A[1]);
            } else if (i == N - 1) {
                A_min[i] = min(A[N - 1] - A[0], A[N - 2] + K - A[N - 1]);
            } else {
                A_min[i] = min(K - (A[i] - A[i - 1]), K - (A[i + 1] - A[i]));
            }
        }
    }

    public static int min(int X, int Y) {
        if (X >= Y) {
            return Y;
        } else {
            return X;
        }
    }
}

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

using namespace std;

int main()
{
	int n, m, flag = 0;
	cin >> n >> m;
	int cnt[n + 1] = {};

	int h[n + 1];
	for (int i = 1; i < n + 1; i++)
	{
		cin >> h[i];
	}

	int a, b;
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		if (h[a] > h[b])
		{
			cnt[b] = 1;
		}
		else if (h[b] > h[a])
		{
			cnt[a] = 1;
		}
		else
		{
			cnt[a] = 1;
			cnt[b] = 1;
		}
	}

	for (int i = 1; i < n + 1; i++)
	{
		if (cnt[i] == 0)
			{
				flag++;
			}
	}

	cout << flag;
	return 0;
}

Measured memory_bytes: 4376
string = input()
q = int(input())
for c in range(0,q):
    instruction = input().split(' ')
    if instruction[0] == 'print':
        print(string[int(instruction[1]):int(instruction[2]) + 1])
    elif instruction[0] == 'reverse':
        string = string.replace(string[int(instruction[1]):int(instruction[2])+1], string[int(instruction[1]):int(instruction[2])+1][::-1], 1)
    elif instruction[0] == 'replace':
        string = string[:int(instruction[1])] + instruction[3] + string[int(instruction[2])+1:]

Measured memory_bytes: 7676
fun main(args: Array<String>) {
  val (S, T) = readLine()!!.split(" ")
  val (A, B) = readLine()!!.split(" ").map(String::toInt)
  val U = readLine()!!
  println("%d %d".format(if (U == S) A - 1 else A, if (U == T) B - 1 else B))
}

Measured memory_bytes: 37996
#include<stdio.h>
int main()
{
	int n, q;
	scanf("%d %d", &n, &q);
	char s[200005];
	scanf("%s", s);
	int i, j;
	char t[200005], d[200005];
	for (i = 0; i < q; i++)
		scanf(" %c %c", &t[i], &d[i]);
	int p[200005], pp[200005];
	for (i = 0; i <= n + 1; i++)
		p[i] = pp[i] = 0;
	for (i = n; i > 0; i--)
		s[i] = s[i - 1];
	s[0] = s[n + 1] = '.';
	j = 0;
	p[0] = 1;
	for (i = q - 1; i >= 0; i--)
	{
		if (t[i] == s[j + 1] && d[i] == 'L')
		{
			j++;
			p[j] = 1;
		}
		if (t[i] == s[j] && d[i] == 'R')
		{
			p[j] = 0;
			j--;
		}
	}
	j = n + 1;
	pp[n + 1] = 1;
	for (i = q - 1; i >= 0; i--)
	{
		if (t[i] == s[j - 1] && d[i] == 'R')
		{
			j--;
			pp[j] = 1;
		}
		if (t[i] == s[j] && d[i] == 'L')
		{
			pp[j] = 0;
			j++;
		}
	}
	int ans = n;
	for (i = 1; i <= n; i++)
		if (p[i] > 0 || pp[i] > 0)
			ans--;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    vector<long long>vec(3);
    for(int i=0;i<3;i++){
        cin>>vec.at(i);
    }
    sort(vec.begin(),vec.end());
    if(vec.at(0)%2==1&&vec.at(1)%2==1&&vec.at(2)%2==1){
        cout<<vec.at(0)*vec.at(1)<<endl;
        return 0;
    }

    cout <<0<<endl;
}

Measured memory_bytes: 3632
n = int(input())
ls = list(map(int,input().split()))
ls.sort(reverse=True)
p = len(ls)
if len(ls)%2 == 1:
    p += 1
p //= 2
q = 0
for i in range(1,p+1):
    if i == 1:
        q += ls[0]
    else:
        if i == p:
            if len(ls)%2 == 1:
                q += ls[p-1]
            else:
                q += 2*ls[p-1]
        else:
            q += 2*ls[i-1]
print(q)

Measured memory_bytes: 31268
; A - Maximize the Formula
; https://beta.atcoder.jp/contests/abc110/tasks/abc110_a

(defun split-and-parse-integer (string)
  (loop for i = 0 then (1+ j)
    as j = (position #\Space string :start i)
    collect (parse-integer (subseq string i j))
    while j))

(defun sum (list)
  (if list
    (+ (car list) (sum (cdr list)))
    0))

(defun solve (ns)
  (let ((ds (sort (copy-list ns) #'>)))
    (let ((biggest (car ds))
          (others  (cdr ds)))
      (+ (* 10 biggest) (sum others)))))

(format t "~A" (solve (split-and-parse-integer (read-line))))


Measured memory_bytes: 12008
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 300005
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	//  WF("output.txt");
	DF("err.txt");

	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	printf("%d\n", min3(A + B, B + C, C + A));
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>>date(N, vector<int>(2));
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 2; j++){
      cin >> date.at(i).at(j);
    }
  }
  int judge = 0;
  for(int a = 0; a < N - 2; a++){
    if(date.at(a).at(0) == date.at(a).at(1)){
      if(date.at(a + 1).at(0) == date.at(a + 1).at(1)){
        if(date.at(a + 2).at(0) == date.at(a + 2).at(1)){
          judge = 1;
        }
      }
    }
    
   
  }
  if(judge == 1){
     cout << "Yes" << endl;
   }
    else{
      cout << "No" << endl;
    }
}

    

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>

using namespace std;

int main()
{
  int k;
  int pos[5];
  for (int i=0;i<5;i++)
    scanf("%d", &pos[i]);
  scanf("%d", &k);
  for (int i=0;i<4;i++)
    for(int j=i+1;j<5;j++) {
      if (pos[j] - pos[i] > k)
      {
        printf(":(\n");
        return 0;
      }
    }
  printf("Yay!\n");
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var A, B, C, K int
	fmt.Scan(&A,&B,&C,&K)

	if (K<=A) {
		fmt.Println(K)
	}else if (K<=A+B) {
		fmt.Println(A)
	}else {
		fmt.Println(2*A+B-K)
	}
}

Measured memory_bytes: 1752
let m = 9999973

let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let to_x = Array.make 128 0

let to_key s =
  let n = String.length s in
  let rec doit i p acc =
    if i = n then acc
    else doit (i + 1) (5*p) (acc + p*(to_x.(Char.code s.[i]))) in
  doit 0 1 0

let to_h1 k = k mod m
let to_h2 k = 1 + (k mod (m - 1))

let insert s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then ()
    else if t.(h) = "\000" then t.(h) <- s
    else doit (i + 1) in
  doit 0

let find s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then true
    else if t.(h) = "\000" then false
    else doit (i + 1) in
  doit 0

let () =
  to_x.(Char.code 'A') <- 1;
  to_x.(Char.code 'C') <- 2;
  to_x.(Char.code 'G') <- 3;
  to_x.(Char.code 'T') <- 4;
  let n = read_int () in
  let t = Array.make m "\000" in
  let rec doit i =
    if i < n then begin
      begin match split (read_line ()) ' ' with
      | ["insert"; s] -> insert s t
      | ["find"; s] -> print_endline (if find s t then "yes" else "no")
      | _ -> ()
      end;
      doit (i + 1)
    end in
  doit 0

Measured memory_bytes: 92036
#include <bits/stdc++.h>
using namespace std;
long long ta[399999];

int main()
{
    string str;
    cin >> str; 
    long long n;
    cin >> n;
    int ii=str.size()-1;
    int a=1;
    for(int i=0; i<str.size(); i++){
        if(str[i] != '1'){
            ii = i;
            a =  str[i] - 48;
            break;
        }
    }
    if(n <= ii){ cout << 1 <<endl;}
    else{ cout << a <<endl;}
}



Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}


int main(){
  int n;
  cin>>n;
  int c1=0;
  int c2=0;
  for(int i = 0; i < n; i++){
    int a;
    cin>>a;
    if(a%2==0)c1++;
    else c2++;
  }
  if(c2%2==1){
    cout<<"NO"<<endl;
  }
  else{
    cout<<"YES"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define INFTY 1000000001
#define N 500000

void merge(int,int,int,int);
void mergeSort(int,int,int);
int S[N],count=0;

int main(){
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  
  mergeSort(n,0,n);

  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    printf("%d",S[i]);
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

void merge(int n,int l,int m,int r){
  int n1,n2,L[N],R[N],k,i,j;
  n1=m-l;
  n2=r-m;
  for(i=0;i<n1;i++){
    L[i]=S[l+i];
  }
  for(i=0;i<n2;i++){
    R[i]=S[m+i];
  }
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=l;k<=r-1;k++){
    count++;
    if(L[i]<=R[j]){
      S[k]=L[i];
      i=i+1;
    }else{
      S[k]=R[j];
      j=j+1;
    }
  }
}

void mergeSort(int n,int l,int r){
  int m,i;
  if(l+1<r){
    m=(l+r)/2;
    mergeSort(n,l,m);
    mergeSort(n,m,r);
    merge(n,l,m,r);
  }
}

  



Measured memory_bytes: 5676
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lstd
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}



void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using namespace std;

class DPowerfulDiscountTickets {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, m;
		in >> n >> m;

		const int MAXN = 100005;
		int a[MAXN];
		priority_queue<int> pq;
		for (int i = 0; i < n; i++)
			in >> a[i], pq.push(a[i]);

		while(m--){
			int x = pq.top();
			pq.pop();
			pq.push(x/2);
		}

		ll ans = 0;
		while(!pq.empty())
			ans += pq.top(), pq.pop();

		out << ans;

	}
};

int main() {
	DPowerfulDiscountTickets solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 1148
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


i, o, t, j, l, s, z = map(int, input().split())
ans = 0
ans += o

def sub(i,j,l):
    best = 0
    if j>=1 and l>=1 and i>=1:
        v = (i if i%2 else i-1) + (j-1)//2*2 + (l-1)//2*2 + 2
        best = max(v, best)
    v = (i if i%2==0 else i-1) + (j//2)*2 + (l//2)*2
    best = max(v, best)
    return best
ans += sub(i,j,l)
print(ans)

Measured memory_bytes: 38420
#include <bits/stdc++.h>
#define fast_cin() ios_base::sync_with_stdio(0) 
typedef long long int ll;
using namespace std;
const int MOD=1e9+7;
const int size=1 << 10;

ll n,m;
char a[size][size];
int main()
{
	string s,t;
	cin >> s >> t;
	string p="UNRESTORABLE";
	ll x=s.length(),y=t.length();
	if(x<y)
	{
		cout << p;
		return 0;
	}
	//cout << x << " " << y<<endl;
	bool check=0;
	for(int i=x-y;i>=0;i--)
	{
		for(int j=0;j<y;j++)
		{
			if(s[i+j]!=t[j])
				break;
			if(j==y-1)
				check=1;
			//cout << s[i+j] << " "<< t[j] << " "<< " "<<i+j << " "<<j<<endl;
			
		}
		if(check)
		{
			for(int j=0;j<x;j++)
			{
				if(s[j]=='?')
				{
					s[j]='a';
				}
			}	
		}
	}
	if(check)
	{
		cout << s;
		return 0;
	}

	check=0;
	for(int i=x-y;i>=0;i--)
	{
		for(int j=0;j<y;j++)
		{
			if(s[i+j]!='?'&&s[i+j]!=t[j])
				break;
			if(j==y-1)
				check=1;
			//cout << s[i+j] << " "<< t[j] << " "<< " "<<i+j << " "<<j<<endl;
			
		}
		if(check)
		for(int j=0;j<y;j++)
		{
			if(s[i+j]=='?')
			{
				s[i+j]=t[j];
			}
		}
		if(check)
		{
			for(int j=0;j<x;j++)
			{
				if(s[j]=='?')
				{
					s[j]='a';
				}
			}	
		}
	}
	if(check)
		cout << s;
	else
		cout << p;

}


Measured memory_bytes: 256
N,C=map(int,input().split())
xv=[list(map(int,input().split())) for i in range(N)]
from itertools import accumulate
vc=list(accumulate([v for x,v in xv]))
vc=[vc[i]-x for i,(x,v) in enumerate(xv)]
va=list(accumulate([v for x,v in xv[::-1]]))
va=[va[i]-C+x for i,(x,v) in enumerate(xv[::-1])]
mc=[0]*N
for i in range(N):
    mc[i]=i if vc[mc[i-1]]<vc[i] else mc[i-1]
ma=[0]*N
for i in range(N):
    ma[i]=i if va[ma[i-1]]<va[i] else ma[i-1]
r=max(0,vc[mc[-1]])
for i in range(N-1):
    r=max(r,va[i]+vc[mc[-i-2]]-C+xv[-i-1][0])
r=max(r,va[ma[-1]])
for i in range(N-1):
    r=max(r,vc[i]+va[ma[-i-2]]-xv[i][0])
print(r)

Measured memory_bytes: 43256
fn input() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
}

fn main() {
    loop {
        let line = &input();
        let mut seg: Vec<i64> = line
            .split_whitespace()
            .map(|s| s.parse::<i64>().unwrap())
            .collect();
        if seg[0] == 0 && seg[1] == 0 {
            break;
        }
        seg.sort();
        println!("{} {}", seg[0], seg[1]);
    }
}


Measured memory_bytes: 5056
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, k; readV(n, k);
  int[] a; readA(n, a);

  a = a.filter!(ai => ai < k).array;
  a.sort();
  n = a.length.to!int;

  auto calc(R)(R b, int ai)
  {
    auto dp = new bool[](k), dp2 = new bool[](k);
    dp[0] = true;

    foreach (bi; b) {
      dp2[] = dp[];
      dp[bi..$][] |= dp2[0..$-bi][];
    }

    return dp[k-ai..k].any;
  }

  auto bs = iota(0, n).map!(i => calc(chain(a.take(i), a.drop(i+1)), a[i])).assumeSorted;
  writeln(bs.lowerBound(true).length);
}


Measured memory_bytes: 636
#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];
  }

  long long ans = 0;
  int MaxNum = 0;
  for (int i = 0; i < N; i++)
  {
      MaxNum = max(MaxNum, A[i]);
      int Bi = MaxNum;
      ans += Bi - A[i];
  }

  cout << ans << endl;

}


Measured memory_bytes: 3940
<?php

$n = (int)(trim(fgets(STDIN)));

$ts = $xs = $ys = [0];
for ($i = 1; $i <= $n; $i++) {
  list($ts[$i], $xs[$i], $ys[$i]) = array_map(
    function ($string) {
      return (int)$string;
    },
    explode(' ', trim(fgets(STDIN)))
  );
}

for ($i = 1; $i <= $n; $i++) {
  $dt = $ts[$i] - $ts[$i - 1];
  $dd = abs($xs[$i] - $xs[$i - 1]) + abs($ys[$i] - $ys[$i - 1]);
  if ($dt < $dd) {
    echo "No\n";
    exit;
  }
  if (($dt - $dd) % 2 === 1) {
    echo "No\n";
    exit;
  }
}

echo "Yes\n";
exit;


Measured memory_bytes: 18932
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cerr<<" #"<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=100005;
int a[N],n,mx;

void GG(){
	puts("Impossible");
	exit(0);
}

int main(){
	read(n);
	rep(i,1,n){
		read(a[i]);
		mx=max(mx,a[i]);
	}
	if(n==2&&a[1]==1&&a[2]==1){
		puts("Possible");
		return 0;
	}
	if(n==2)GG();
	for(int l=1,r=mx+1,t=mx;l<=r;l++,r--,t--){
		int p=0,q=0;
		rep(i,1,n){
			if(!p&&a[i]==t)p=i;
			else if(a[i]==t)q=i;
		}
		if(l!=r){
			if(!p||!q)GG();
			a[p]=a[q]=0;
		}
		else{
			if(!p)GG();
			a[p]=0;
		}
	}
	int mn=mx;
	rep(i,1,n)
		if(a[i])mn=min(mn,a[i]);
	if(mx%2==0&&mn<=mx/2)GG();
	if(mx%2==1&&mn<=mx/2+1)GG();
	puts("Possible");
	return 0;
}


Measured memory_bytes: 256
import bisect
import sys

f_inf = float('inf')


def cal(syurui, d, index):
    if d == 'e':
        return syurui[index]
    elif d == 'w':
        return syurui[index - 1]


A, B, Q = map(int, input().split())
s = [int(input()) for i in range(A)]
s.sort()
t = [int(input()) for i in range(B)]
t.sort()
ｓ.insert(0, -f_inf)
t.insert(0, -f_inf)
ｓ.append(f_inf)
t.append(f_inf)

for i in range(Q):
    x = int(sys.stdin.readline().rstrip('\n'))
    s_index = bisect.bisect_left(s, x)
    t_index = bisect.bisect_left(t, x)
    print(min(max(abs(x - s[s_index]), abs(x - t[t_index])), max(abs(x - s[s_index - 1]), abs(x - t[t_index - 1])), 2 * abs(x - s[s_index - 1]) + abs(x - t[t_index]),
              2 * abs(x - s[s_index]) + abs(x - t[t_index - 1]), abs(x - s[s_index - 1]) + 2 * abs(x - t[t_index]), abs(x - s[s_index]) + 2 * abs(x - t[t_index - 1])))


Measured memory_bytes: 12204
ints = input().split(" ")
N = int(ints[0])
maxW = int(ints[1])
ints = input().split(" ")
a = int(ints[0])
b = int(ints[1])
weight = [a, a+1, a+2, a+3] 
va = [[b],[],[],[]]
for i in range(1, N):
	ins = input().split(" ")
	w = int(ins[0])
	v = int(ins[1])
	for j in range(0, 4):
		if w == weight[j]:
			va[j].append(v)
for i in range(0, len(va)):
	va[i].sort(reverse=True)
	va[i].insert(0,0)
#print(va)
sum = [[0],[0],[0],[0]]
for j in range(0, 4):
	for i in range(1, len(va[j])):
		try:
			sum[j].append(sum[j][i-1] + va[j][i])
		except:
			pass
ans = 0
#print(sum)
for i in range(0, len(va[0])):
	for j in range(0, len(va[1])):
		for k in range(0, len(va[2])):
			for l in range(0, len(va[3])):
				sumw = weight[0]*i + weight[1]*j +weight[2]*k + weight[3]*l
				if(sumw <= maxW):
					ans = max(sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l],ans)
print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
int main(){
  int a,b,c,e,h=1,t,i=0,d[3]={0};
  while(scanf("%d %d %d",&a,&b,&c)!=EOF){
    if(h){
      if(a<b){
	t=a;
	a=b;
	b=t;
      }
      if(a<c){
	t=a;
	a=c;
	c=t;
      }
      if(a<b+c){
	e=b*b+c*c;
	i++;
	if     (a*a>e) d[0]++;
	else if(a*a==e)d[1]++;
	else           d[2]++;
      }
      else{
	printf("%d %d %d %d\n",i,d[1],d[2],d[0]);
	h=0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 596
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
vector<int> g[202020];
int n, q;
int p[202020];
long long ans[202020];
void dfs (int cur, int par, long long x) {
  ans[cur] += x + p[cur];
  for (int child : g[cur]) {
    if (child == par) continue;
    dfs (child, par, ans[cur]);
  }
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  //d
  cin >> n >> q;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
  }
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    p[a] += b;
  }
  dfs(0, -1, 0);
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 24960
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
  int num, a, b, c, a2, b2, c2;
  cin>>num;

  for (int i = 0; i < num; i++) {
    cin>>a>>b>>c;

    a2= a*a;
    b2= b*b;
    c2= c*c;

    if((a2+b2==c2)||(b2+c2==a2)||(a2+c2==b2)){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2980
N, M = list(map(int, input().split()))
submits = [[] for i in range(M)]
for i in range(M):
    submits[i] = input().split()
    submits[i][0] = int(submits[i][0])

AC_number = [0 for i in range(N)] #バケット
WA_number = [0 for i in range(N)] #バケット
for i in range(M):
    #WAが出て、まだ終わってない問題なら
    if submits[i][1] != 'AC' and AC_number[submits[i][0] - 1] != 1:
        WA_number[submits[i][0] - 1] += 1
    
    #ACが出たら
    if submits[i][1] == 'AC':
        AC_number[submits[i][0] - 1] = 1

AC_count = 0
WA_count = 0
for i in range(N):
    if AC_number[i] == 1:
        AC_count += 1
        WA_count += WA_number[i]
print(AC_count, WA_count)
    
    

Measured memory_bytes: 31508
n, k = map(int, input().split())
d = list(map(int, input().split()))

canidates = [i for i in range(10) if i not in d]

ans = 10**9
def bfs(s):
    global ans
    if len(s) > len(str(n))+1:
        return
    if len(s) > 0:
        res = int(s)
        if res >= n and res < ans:
            ans = res
    for i in canidates:
        bfs(s+str(i))
bfs('')
print(ans)



Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var N, M int
var xs, ys, zs []int

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &N, &M)

	xs = make([]int, N)
	ys = make([]int, N)
	zs = make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d %d", &xs[i], &ys[i], &zs[i])
	}

	fs := [](func(i int) int){ppp, ppn, pnp, pnn, npp, npn, nnp, nnn}
	ans := 0
	for _, f := range fs {
		ans = max(ans, run(f))
	}
	fmt.Println(ans)
}

func run(eval func(i int) int) int {
	dp := make([][]int, N+1)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([]int, M+1)
	}

	for j := 1; j <= M; j++ {
		for i := 1; i <= N; i++ {
			if i == 1 && j == 1 {
				dp[i][j] = eval(i - 1)
			} else if j == 1 {
				dp[i][j] = max(
					dp[i-1][j],
					eval(i-1),
				)
			} else if i == j {
				dp[i][j] = dp[i-1][j-1] + eval(i-1)
			} else {
				dp[i][j] = max(
					dp[i-1][j],
					dp[i-1][j-1]+eval(i-1),
				)
			}
		}
	}

	/*
		fmt.Println("----")
		for j := 1; j <= M; j++ {
			for i := 1; i <= N; i++ {
				fmt.Print(dp[i][j], ",")
			}
			fmt.Println()
		}
	*/

	return dp[N][M]
}

func ppp(i int) int {
	return xs[i] + ys[i] + zs[i]
}

func ppn(i int) int {
	return xs[i] + ys[i] - zs[i]
}

func pnp(i int) int {
	return xs[i] - ys[i] + zs[i]
}

func pnn(i int) int {
	return xs[i] - ys[i] - zs[i]
}

func npp(i int) int {
	return -xs[i] + ys[i] + zs[i]
}

func npn(i int) int {
	return -xs[i] + ys[i] - zs[i]
}

func nnp(i int) int {
	return -xs[i] - ys[i] + zs[i]
}

func nnn(i int) int {
	return -xs[i] - ys[i] - zs[i]
}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}


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

using namespace std;

class range {
private:
  struct Iterator {
    int val, inc;
    int operator*() {return val;}
    bool operator!=(Iterator& itr) {return val != itr.val;}
    void operator++() {val += inc;}
  };
  Iterator i, n;
public:
  range(int n) : i({0, 1}), n({n, 1}) {}
  range(int i, int n) : i({i, 1}), n({n, 1}) {}
  range(int i, int inc, int n) : i({i, inc}), n({n, inc}) {}
  Iterator& begin() {return i;}
  Iterator& end() {return n;}
};

template<class T> inline T at(const vector<T> &v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

template<class T> inline bool is_max(T &a, const T &b) {return a < b ? a = b, true : false;}
template<class T> inline bool is_min(T &a, const T &b) {return a > b ? a = b, true : false;}

class Parser {
private:
  string s;
  long long p;
  
  string factor() {
    string res;
    if (s[p] == '[') {
      ++p;
      res = expr();
      ++p;
      reverse(res.begin(), res.end());
      return res;
    }
    while (isalpha(s[p])) res += s[p++];
    return res;
  }
  
  string expr() {
    string res;
    while (true) {
      if (s[p] == '+') {
        ++p;
        string f = expr();
        if (f[0] == 'Z') f[0] = 'A';
        else ++f[0];
        res += f;
      } else if (s[p] == '-') {
        ++p;
        string f = expr();
        if (f[0] == 'A') f[0] = 'Z';
        else --f[0];
        res += f;
      } else if (isalpha(s[p]) || s[p] == '[') {
        res += factor();
      } else {
        break;
      }
    }
    return res;
  }
  
public:
  Parser(string s) : s(s + '@'), p(0) {}
  string eval() {return expr();}
};

string solve(string str) {
  int index = str.find("?");
  if (index == (int)string::npos) {
    Parser parser(str);
    return parser.eval();
  }
  string res;
  for (int i : range(100)) res += "Z";
  for (int i : range('A', 'Z' + 1)) {
    str[index] = i;
    is_min(res, solve(str));
  }
  return res;
}

int main() {
  while (true) {
    string str;
    cin >> str;
    if (str == ".") break;
    cout << solve(str) << endl;
  }
}

Measured memory_bytes: 1216
#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 <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#include <list>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

int main() {
    int direction = 1; //{1-> left to right: -1 reverse}
    string s; cin >> s;
    deque<char> ls;
    for (auto c : s) {
        ls.push_back(c);
    }
    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        int t; cin >> t;
        if (t == 1) {
            direction *= -1;
        }
        else if (t == 2) {
            int f; cin >> f;
            if (f == 1) {
                f = -1;
            }
            else if (f == 2) {
                f = 1;
            }
            int position = f * direction;
            char c; cin >> c;

            if (position < 0) {
                ls.push_front(c);
            }
            else {
                ls.push_back(c);
            }
        }
    }
    if (direction > 0) {
        for (auto l = ls.begin(); l != ls.end(); l++) {
            cout << *l;
        }
        cout << endl;
    }
    else {
        for (auto l = ls.rbegin(); l != ls.rend(); l++) {
            cout << *l;
        }
        cout << endl;
    }
}

Measured memory_bytes: 4048
N, *C = $<.read.split.map(&:to_i)

C << 0
s, g, h = 1, Hash.new(0), Hash.new(0)
N.times{|i|
	next if C[i-1] == C[i]
	h[C[i]] += s = (s -= g[C[i]]) + (g[C[i]] = h[C[i]])
}
p s%1000000007


Measured memory_bytes: 103304
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n,i;
        char c;
        String str;
        str=scan.nextLine();
        n=str.length();
        for(i=0;i<n;i++) {
        	if(Character.isUpperCase(str.charAt(i))) {
        		System.out.print(Character.toLowerCase(str.charAt(i)));
        	}
        	else if(Character.isLowerCase(str.charAt(i))) {
        		System.out.print(Character.toUpperCase(str.charAt(i)));
        	}
        	else {
        		System.out.print(str.charAt(i));
        	}
        }
        System.out.println("");
    }
}


Measured memory_bytes: 27176
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int main(){
	ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    int times=b/a;
    times=min(times,c);
    cout<<times<<"\n";



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll N, K, cnt = 0;
  cin >> N >> K;
  vector<ll> p(N);
  for(ll i = 0; i < N; i++) cin >> p.at(i);
  sort(p.begin(), p.end());
  for(ll i = 0; i < K; i++) cnt += p.at(i);
  cout << cnt << endl;
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    string s[3];
    rep(i,3) cin >> s[i];
    rep(i,3){
        cout << (char)(s[i][0]-'a'+'A');
    }
    cout << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  char c;
  string ans = "Three";
  for(int i = 0; i < n; i++){
    cin >> c;
    if(c == 'Y'){
      ans = "Four";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		System.out.println(((a-b)*(a-b)<=d*d && (b-c)*(b-c)<=d*d) || (a-c)*(a-c)<=d*d ? "Yes" : "No");
	}
}

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

static class D
{
    static void Main()
    {
        int n = Int32.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(Int32.Parse).ToArray();
        int[] b = Console.ReadLine().Split().Select(Int32.Parse).ToArray();

        var x = new int[n];
        var y = new int[n];

        int ans = -1;

        for (int bits = 0; bits < (1 << n); bits++)
        {
            for (int i = 0; i < n; i++)
            {
                int bit = (bits >> i) & 1;
                int x_i = (bit == 0) ? a[i] : b[i];
                x[i] = x_i;
            }

            Array.Sort(x);

            for (int i = 0; i < n; i++)
            {
                int bit = (bits >> i) & 1;
                int x_i = (bit == 0) ? a[i] : b[i];

                y[i] = -1;

                for (int j = 0; j < n; j++)
                {
                    if (x[j] == x_i && Math.Abs(j - i) % 2 == bit)
                    {
                        x[j] = 0;
                        y[i] = j;
                        break;
                    }
                }
                if (y[i] == -1) goto fail;
            }

            int flips = 0;

            for (int i = 0; i < n; i++)
            for (int j = 0; j < i; j++)
            {
                if (y[j] > y[i]) ++flips;
            }

            if (ans == -1 || ans > flips)
                ans = flips;
        fail: ;
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

//AtCoder Beginner Contest 126
//B	YYMM or MMYY
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();

		sc.close();

		int a = Integer.valueOf(S.substring(0, 2)).intValue();
		int b = Integer.valueOf(S.substring(2)).intValue();

		boolean aIsMonth = (a > 0 && a < 13);
		boolean bIsMonth = (b > 0 && b < 13);

		String ans = "NA";
		if (aIsMonth) {
			if (bIsMonth) {
				ans = "AMBIGUOUS";
			} else {
				ans = "MMYY";
			}
		} else {
			if (bIsMonth) {
				ans = "YYMM";
			}
		}

		System.out.print(ans);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int in(){int x; scanf("%d",&x); return x;}
static const int MAX = 100;


int main() {
  long long A[MAX];
  int N = in();

  rep(i, N) A[i] = in();
  sort(A, A+N);

  cout << abs(A[0] - A[N-1]) << endl;
}

Measured memory_bytes: 256
import math
N = int(input())

ans = 0
for m in range(1, int(math.sqrt(N))+2):
    if N % m == 0:
        t = N//m - 1
        if t <= 0:
            continue
        a = N//t
        b = N % t
        if a == b:
            ans += t
print(ans)


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    rep(i, M) cin >> X[i];
    sort(X.begin(), X.end());

    vector<int> L(M-1);
    rep(i, M-1) L[i] = X[i+1] - X[i];
    sort(L.begin(), L.end(), greater<int>());

    // rep(i, L.size()) cout << L[i] << " ";
    // cout << endl;

    int ans = 0;
    if (N >= M) ans = 0; // cout << 0 << endl;
    else {
        ans = X[M-1] - X[0];
        rep(i, N-1) {
            ans -= L[i];
        }
    }
    cout << ans << endl;
}

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

int findsum(int n){
    int sum=0;
    while (n>0){
        sum += n%10;
        n /= 10;
    }
    return sum;
}

int main(){
 int n,a,b;
 cin >> n >> a >> b;
 int count = 0;
 for(int i=1;i<n+1;i++){
     if(a<=findsum(i)&&findsum(i)<=b) count+=i;
 }
 cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	while(1){
		int H,W;
		cin >> H >> W;
		if(H==0 && W==0)break;
		for(int i=0;i<H;++i){
			for(int j=0;j<W;++j){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

struct edge { int to, cost; };
typedef pair<int, int> P;

vector<edge> g[(int)1e5+1];
long long d[(int)1e5+1];

void dfs(int v, int p) {
  for (auto e: g[v]) {
    if (e.to == p) {
      continue;
    }
    d[e.to] = d[v] + e.cost;
    dfs(e.to, v);
  }
}
int main() {
  int n;
  cin>>n;

  for (int i=0; i<n-1; i++) {
    int a, b, c;
    cin>>a>>b>>c;
    edge e1, e2;
    e1.to = b;
    e1.cost = c;
    e2.to = a;
    e2.cost = c;
    g[a].push_back(e1);
    g[b].push_back(e2);
  }
  int q, k;
  cin>>q>>k;

  d[k] = 0;

  dfs(k, -1);

  for (int i=0; i<q; i++) {
    int x, y;
    cin>>x>>y;
    cout<<d[x] + d[y]<<endl;
  }
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int n,k;
    cin >> n >> k;
    vector <long long> h(n);
    rep(i,n) cin >> h[i];

    sort(all(h));

    long long ans = abs(h[0] - h[k-1]);
    
    for(int i=0; i<=n-k; i++){
        long long des = abs(h[i+k-1] - h[i]);
        if(ans > des){
            ans = des;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 4028
import numpy as np
n = int(input())
lst = sorted(list(map(int,input().split())))

res = np.cumsum(lst).tolist()
cnt = 0
for i in range(n-1):
    x = res[i]
    if lst[i+1] <= x*2:
        cnt += 1
    else:
        cnt = 0
print(cnt+1)

Measured memory_bytes: 23120
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

// 約数列挙
template<typename T>
vector<T> calc_divisor(T n) {
   vector<T> res;
   for (T i = 1LL; i*i <= n; ++i) {
       if (n % i == 0) {
           res.push_back(i);
           T j = n / i;
           if (j != i) res.push_back(j);
       }
   }
   sort(res.begin(), res.end());
   return res;
}

// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    double l;
    cin >> l;
    double tmp = l / 3.0;
    print(tmp * tmp * tmp);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int x, y;
int main() {
	cin >> x >> y;
	if(x==2){
		if(y==2){
			cout << "Yes";
		}else{
			cout << "No";
		}
	}else{
		if((x==4)||(x==6)||(x==9)||(x==11)){
			if((y==4)||(y==6)||(y==9)||(y==11)){
				cout << "Yes";
			}else{
				cout << "No";
			}
		}else{
			if((y==3)||(y==1)||(y==5)||(y==7)||(y==8)||(y==10)||(y==12)){
				cout << "Yes";
			}else{
				cout << "No";
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define fore(i,a,b) for(int i=a;i<b;++i)
#define sorte(a) sort(a.begin(), a.end())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
int main(){
	char s[5];
	scanf("%s",s);
	if(s[0]==s[1] || s[1]==s[2] ||s[2]==s[3])
		printf("Bad\n");
	else
		printf("Good\n");
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
Ps = list(map(int,input().split()))

def solve(Ps):
    n = len(Ps)
    As = [x * 30000 + 1 for x in range(n)]
    Bs = list(reversed(As[:]))
    for i, p in enumerate(Ps):
        Bs[p-1] += i
    return As, Bs

As, Bs = solve(Ps)
print(*As)
print(*Bs)


Measured memory_bytes: 6436
def main():
    n, *abcd = map(int, open(0).read().split())
    red = list(zip(abcd[0:2 * n + 1:2], abcd[1:2 * n + 1:2]))
    blue = list(zip(abcd[2 * n::2], abcd[2 * n + 1::2]))

    r = sorted(red, key=lambda p: p[1], reverse=True)
    b = sorted(blue)
    ans = 0
    done = []
    for xb, yb in b:
        for xr, yr in r:
            if xr < xb and yr < yb:
                if [xr, yr] not in done:
                    done.append([xr, yr])
                    ans += 1
                    break
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064