akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;
typedef double ld;
typedef pair<ld, ld> pdd;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  fastIO;
  int n;
  cin >> n;
  int k = (1 << n);
  multiset<int> cur;
  multiset<int> val;
  int x;
  for(int i = 0 ; i < k ; i ++ ){
    cin >> x;
    x=-x;
    val.insert(x);
  }
  cur.insert(*(val.begin()));
  val.erase(val.begin());
  while(!val.empty()){
    vector<int> sol;
    for(auto x : cur){
      auto it = val.upper_bound(x);
      if(it == val.end()){
        cout << "No\n";
        return 0;
      }
      sol.push_back(*it);
      val.erase(it);
    }
    for(auto y : sol) cur.insert(y);
  }
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 13304
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int n;
vector<int> G[100001];
int par[100001];
int root;
int main(){
  for(int i=0;i<100001;i++)par[i]=-1;
  cin >> n;
  for(int i=0;i<n;i++){
    int id,k;
    cin >> id >> k;
    int u;
    for(int i=0;i<k;i++){cin >> u;
      G[id].push_back(u);
      par[u]=id;
    }
  }
  for(int i=0;i<n;i++)if(par[i]==-1)root=i;

  for(int i=0;i<n;i++){
    int dep=0;
    int p=par[i];
    while(1){
      if(p==-1)break;
      p=par[p];
      dep++;
    }
    printf("node %d: parent = %d, depth = %d, ",i,par[i],dep);
    if(root==i)printf("root, ");
    else if(G[i].size()==0)printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    for(int j=0;j<G[i].size();j++){
      printf("%d",G[i][j]);
      if(j==G[i].size()-1)break;
      printf(", ");
    }
    printf("]\n");
  }
  return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N)
    {
        cin >> v.at(i);
    }
    sort(all(v));
    double ans = (v.at(0) + v.at(1)) / 2.;
    for (int i = 2; i < N; i++)
    {
        ans = (ans + v.at(i)) / 2.;
    }
    cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Affine Cipher
 */
public class Main {

	static final char[][] hints = {{'t', 'h', 'i', 's'}, {'t', 'h', 'a', 't'}};

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = parseInt(br.readLine());

		for (int i = 0; i < n; i++) {
			String s = br.readLine();
			int[] c = cipher(s);
			int[] d = new int[26];
			for (int j = 0; j < 26; j++) {
				d[(c[0] * j + c[1]) % 26] = j;
			}
			StringBuilder sb = new StringBuilder();
			for (int j = 0; j < s.length(); j++) {
				if (s.charAt(j) == ' ') {
					sb.append(' ');
				} else {
					sb.append((char) (d[s.charAt(j) - 'a'] + 'a'));
				}
			}
			System.out.println(sb.toString());
		}
	}

	static int[] cipher(String s) {

		int[] ret = new int[2];

		StringTokenizer st = new StringTokenizer(s);

		while (st.hasMoreTokens()) {

			String w = st.nextToken();

			if (w.length() == 4) {

				char[] hint;

				if (w.charAt(0) != w.charAt(w.length() - 1)) {
					hint = hints[0];
				} else {
					hint = hints[1];
				}

				for (int a = 0; a < 26; a++) {
					if (a % 2 != 0 && a % 13 != 0) {
						for (int b = 0; b < 26; b++) {
							StringBuilder h = new StringBuilder();
							for (int i = 0; i < hint.length; i++) {
								h.append((char) (((a * (hint[i] - 'a') + b) % 26) + 'a'));
							}
							if (w.equals(h.toString())) {
								ret[0] = a;
								ret[1] = b;
								return ret;
							}
						}
					}
				}
			}
		}

		return ret;
	}
}

Measured memory_bytes: 27600
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL getPre(LL i){
	if(i % 4 == 0){
		return i;
	}else if(i % 4 == 1){
		return 1;
	}else if(i % 4 == 2){
		return i + 1;
	}else if(i % 4 == 3){
		return 0;
	}
}
int main(){
	LL a,b;
	cin>>a>>b;
	b = getPre(b);
	if(a) a = getPre(a-1);
	// cout<<"a = "<<a<<"  b = "<<b<<endl;
	cout<<(a^b)<<endl;
	return 0;
}

Measured memory_bytes: 256
# 2019-11-16 21:01:15(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 


def comb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6 # 問題によってNの大きさは変える
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


def main():
    x, y = [int(x) for x in sys.stdin.readline().split()]
    # n(+1, +2), m(+2, +1)
    n, m = (2 * y - x) / 3, (2 * x - y) / 3

    if n != abs(int(n)) or m != abs(int(m)):
        print(0)
        sys.exit()
    else:
        n, m = int(n), int(m)
        ans = comb(n+m, m, mod)
        print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 122128
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <list>

using namespace std;

// 最大公約数
long long gcd(long long a, long long b)
{
    if (a < 0)
        a = -a;
    if (b < 0)
        b = -b;
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

// 最小公倍数
long long lcm(long long a, long long b)
{
    long long g = gcd(a, b);
    return a / g * b;
}

int main()
{
    long n, m;
    cin >> n >> m;
    long temp, temp2 = 0;
    for (long long i = 0; i < m; i++)
    {
        cin >> temp;
        temp2 += temp;
    }
    long temp3 = n - temp2;
    if (temp3 < 0)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << temp3 << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
import bisect

def main():
  n, k, *lst = map(int, open(0).read().split())
  z = bisect.bisect_left(lst, 0)
  if not z:
    print(lst[k - 1])
  elif z >= n - 1:
    print(-lst[-k])
  else:
    idx = max(z - k + 1, 0)
    print(min(min(abs(i), j) + j - i for i, j in zip(lst[idx:], lst[idx + k - 1:])))

if __name__ == '__main__':
  main()

Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
int h, w;
vector<vector<char>> s;
vector<vector<int>> sb;
vector<int> dx = {-1, 0, 1, 0};
vector<int> dy = {0, -1, 0, 1};

struct xydata {
    int x, y;
};

void refresh() {
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            sb.at(i).at(j) = 1000;
        }
    }
}

int bfs(int sx, int sy, int gx, int gy) {
    sb = vector<vector<int>>(h, vector<int>(w, 1000));
    xydata first;
    first.x = sx;
    first.y = sy;
    queue<xydata> que;
    que.push(first);
    refresh();
    sb.at(first.y).at(first.x) = 0;

    int depth = 0;
    while(!que.empty()) {
        xydata now = que.front();
        que.pop();
        if(now.x == gx && now.y == gy) {
            depth = sb.at(gy).at(gx);
            break;
        }
        for(int i = 0; i < 4; ++i) {
            xydata next;
            next.x = now.x+dx.at(i);
            next.y = now.y+dy.at(i);
            if(next.x >= 0 && next.x < w && next.y >= 0 && next.y < h) {
                if(s.at(next.y).at(next.x) == '.') {
                    if(sb.at(now.y).at(now.x)+1 < sb.at(next.y).at(next.x)) {
                        sb.at(next.y).at(next.x) = sb.at(now.y).at(now.x) + 1;
                        que.push(next);
                    }
                }
            }
        }
    }
    return depth;
}

int main() {
    cin >> h >> w;
    s = vector<vector<char>>(h, vector<char>(w, '.'));
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cin >> s.at(i).at(j);
        }
    }

    int maxlen = 0;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(s.at(i).at(j) == '.') {
                for(int k = 0; k < h; ++k) {
                    for(int l = 0; l < w; ++l) {
                        if(i != k || j != l) {
                            if(s.at(k).at(l) == '.') {
                                // cout << j << i << l << k << " ";
                                int len = bfs(j, i, l, k);
                                // cout << len << endl;
                                maxlen = max(maxlen, len);
                            }
                        }
                    }
                }
            }
        }
    }
    
    cout << maxlen << endl;
}


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


def gen_hash(panel):
    _hash = ""
    for i in range(3):
        for j in range(3):
            _hash += str(panel[i][j])
    return _hash


def get_matchings(_hash):
    ans = "123456780"
    cnt = 0
    for i in range(9):
        if _hash[i] == str(ans[i]):
            cnt += 1
    return cnt


def bfs(panel):
    swap_candidates = {
        0: (1, 3),
        1: (0, 2, 4),
        2: (1, 5),
        3: (0, 4, 6),
        4: (1, 3, 5, 7),
        5: (2, 4, 8),
        6: (3, 7),
        7: (4, 6, 8),
        8: (5, 7)
    }
    dq = deque()
    dq.append((gen_hash(panel), 0))
    seen = set()
    seen.add(gen_hash(panel))
    while dq:
        _hash, cnt = dq.popleft()
        if get_matchings(_hash) == 9:
            return cnt
        z_ptr = _hash.index("0")
        for n_ptr in swap_candidates[z_ptr]:
            next_hash = list(_hash)
            next_hash[z_ptr], next_hash[n_ptr] = next_hash[n_ptr], next_hash[z_ptr]
            next_hash = "".join(next_hash)
            if next_hash not in seen:
                seen.add(next_hash)
                dq.append((next_hash, cnt + 1))


panel = []
for _ in range(3):
    panel.append([int(i) for i in input().split()])

ans = bfs(panel)
print(ans)



Measured memory_bytes: 30280
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int sum = a + b;
		int dif = a - b;
		int pro = a * b;
		System.out.println(Math.max(sum, Math.max(dif, pro)));
	}
}

Measured memory_bytes: 23124
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

N = I()
A = III()

print(gcd_list(A))

Measured memory_bytes: 88428
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()

typedef long long int ll;

//ll num[50];
//ll num2[50];
ll num[ten52];
//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<string,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;


int main(void)
{
    double ans=0.0,d,d1,d2;
    //float f,g,h;
    long long int m,n,i,j,k=1;
    long long int a,a1,a2,a3,sum;
    string s,s1,s2;
    char c,c1;
    sum=a=a1=a2=a3=0;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
    else cout<<"No";

    return 0;
}





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

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

    int a, b, c, d, e, f;
    std::cin >> a >> b >> c >> d >> e >> f;

    double max = 0;
    int w = 100 * a, s = 0;
    int cd = 0;
    while (true) {
        if (c * cd > f * e / 100.0) break;
        int cc = 0;
        while (true) {
            int sugar = c * cc + d * cd;
            if (sugar > f * e / 100.0) break;
            int bc = 0;
            while (true) {
                if (b * bc + sugar > f) break;
                int ac = 0;
                while (true) {
                    int water = 100 * (a * ac + b * bc);
                    if (water + sugar > f) break;
                    if (sugar <= water * e / 100) {
                        double den = (double)sugar / (water + sugar);
                        if (max < den) {
                            max = den;
                            w = water;
                            s = sugar;
                        }
                    }
                    ac++;
                }
                bc++;
            }
            cc++;
        }
        cd++;
    }

    std::cout << w + s << ' ' << s << std::endl;

    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
from bisect import bisect_right

def main():
    S = input()
    T = input()
    lens = len(S)
    s = set(S)
    t = set(T)
    for i in t:
        if not i in s:
            return -2
    S = S + S
    alpha = [[] for i in range(26)]
    for i, v in enumerate(S):
        alpha[ord(v)-ord('a')].append(i)
    ans = 0
    idx = -1
    cnt = 0
    for i in T:
        # 二分探索で探す
        idx = bisect_right(alpha[ord(i)-ord('a')], idx)
        idx = alpha[ord(i)-ord('a')][idx]
        cnt += idx // lens
        idx %= lens
        ans = cnt * lens + idx
    return ans

print(main()+1)


Measured memory_bytes: 54312
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
 
var mod = 998244353;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var fac=[],finv=[],invs=[];
function fset(n){
  //fac.length=n+1,fac[0]=fac[1]=1;
  //for(var i=2;i<=n;)fac[i]=mul(fac[i-1],i++);
  //finv.length=n+1,finv[0]=finv[1]=1,finv[n]=inv(fac[n]);
  //for(i=n;2<i;)finv[i-1]=mul(finv[i],i--);
  //invs.length=n+1,invs[0]=invs[1]=1;
  //for(i=2;i<=n;)invs[i]=mul(fac[i-1],finv[i++]);
}
function inv(b){for(var a=mod,u=0,v=1,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function ncr(n,r){return mul(fac[n],finv[r],finv[n-r]);}
function npr(n,r){return mul(fac[n],finv[r]);}
 
console.log(main());
function main(){
  var n = o.a();
  var d = o.l();
  if(d[0] > 0)return 0;
  if(n === 1)return 1;
  var map = xArray(0,n);
  for(var i = 1; i < n; i++){
    if(d[i] === 0)return 0;
    map[d[i]]++;
  }
  var ans = 1;
  for(var i = 2; i < n; i++){
    if(map[i-1] === 0 && map[i])return 0;
    ans = mul(ans, pow(map[i-1],map[i]));
  }
  return ans;
}

Measured memory_bytes: 28748
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)


def input():
    return stdin.readline().strip()


N, K = map(int, input().split())

s = set()
for i in range(K):
    d = int(input())
    s |= set(map(int, input().split()))

ans = N - len(s)
print(ans)


Measured memory_bytes: 9184
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        var x = int.Parse(Console.ReadLine());
        var result = (x % 2 == 0) ? x / 2 : x / 2 + 1;

        Console.WriteLine(result);
        ReadKey();
    }
}

static class MyUtil
{
    /// <summary>
    /// 指定の桁のビットを取得します。
    /// </summary>
    /// <param name="num"></param>
    /// <param name="count">取得する桁。</param>
    /// <returns></returns>
    public static int GetBit(this int num, int count)
    {
        int mask = (int)Math.Pow(2, count - 1);
        return (num & mask) == 0 ? 0 : 1;
    }

    /// <summary>
    /// <c>int</c>を2進数ビット配列に変換します。
    /// </summary>
    /// <param name="num"></param>
    /// <returns></returns>
    public static int[] ToBitArray(this int num)
    {
        const int size = sizeof(int) * 8;
        var array = new int[size];
        for (int i = 0; i < size; i++)
        {
            array[i] = num.GetBit(size - i);
        }
        return array;
    }

    public static long[] ReadlongArray()
    {
        return ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
    }

    public static int[] ReadintArray()
    {
        return ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

    /// <summary>
    /// <see cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="ts"></param>
    public static void WriteToConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        Console.WriteLine(stringBuilder.ToString());
    }

    public static void WriteToDebugConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        System.Diagnostics.Debug.WriteLine(stringBuilder.ToString());
    }
}



Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define ri register int
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> poly;
#define pb push_back
const int rlen=1<<18|1,inf=0x3f3f3f3f;
const ll Inf=1e18;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read() {
  int ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline ll readl() {
  ll ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline int Read(char*s) {
  int tp=0;
  char ch=gc();
  while(!isdigit(ch)&&!isalpha(ch)) ch=gc();
  while(isdigit(ch)||isalpha(ch)) s[++tp]=ch,ch=gc();
  return tp;
}
namespace modular {
  const int mod=1e9+7;
  inline int add(int a,int b) { return a+b<mod?a+b:a+b-mod; }
  inline int dec(int a,int b) { return a<b?a-b+mod:a-b; }
  inline int mul(int a,int b) { return (ll)a*b%mod; }
  inline void Add(int&a,int b) { a=a+b<mod?a+b:a+b-mod; }
  inline void Dec(int&a,int b) { a=a<b?a-b+mod:a-b; }
  inline void Mul(int&a,int b) { a=(ll)a*b%mod; }
  inline int ksm(int a,int p) { int ret=1;for(;p;p>>=1,Mul(a,a)) (p&1)&&(Mul(ret,a),1);return ret; }
  inline int Inv(int a) { return ksm(a,mod-2); }
  inline int sqr(int a) { return mul(a,a); }
  inline int cub(int a) { return (ll)a*a%mod*a%mod; }
}
using namespace modular;
template<typename T> inline void ckmax(T&a,T b) { a<b?a=b:0; }
template<typename T> inline void ckmin(T&a,T b) { a>b?a=b:0; }
template<typename T> inline T gcd(T a,T b) { T t;while(b)t=a,a=b,b=t-t/a*a;return a; }
template<typename T> inline T Abs(T x) { return x<0?-x:x; }
inline int rd() { return rand()|(rand()<<15); }
const int N=5e5+5;
int n,pre[N],suf[N];
pii a[N];
int main() {
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  n=read();
  for(ri i=1;i<=n;++i) a[i].fi=read(),a[i].se=read();
  sort(a+1,a+n+1);
  pre[0]=0x3f3f3f3f,suf[n]=0x3f3f3f3f;
  for(ri i=1;i<n;++i) pre[i]=min(pre[i-1],a[i].se);
  for(ri i=n-1;i;--i) suf[i]=min(suf[i+1],a[i].se);
  int res=0;
  for(ri mn,r1,r2,t,i=1;i<n;++i) {
    r1=a[i].se,r2=min(max(suf[i+1],a[n].fi-1),a[n].se);
    t=(r1-a[i].fi+1)+(r2-a[n].fi+1);
    mn=pre[i-1];
    ckmax(res,t-max(0,min(r1-max(a[i].fi-1,mn),r2-max(a[n].fi-1,mn))));
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 5504
'use strict'
function main(i) {
  i = i.trim().split('\n')
  const n = i[0] - 0
  i = i[1].split(' ').map(v => v - 0).sort((a, b) => a - b)
  let c = Math.floor(n/2)-1
  console.log(i[c+1] - i[c])
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 28376
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, a, b, c[300005] = {};
    cin >> n >> a >> b;
    if (n >= a + b - 1 && n <= (ll)a * b) {
        c[0] = a;
        int m = n - a;
        fr1(b - 1) c[i] = 1, m--;
        fr1(b - 1) {
            if (m >= a - 1) c[i] += a - 1, m -= a - 1;
            else {c[i] += m; break;}
        }
        //fr(b) cout << c[i] << ' ';
        int l = n;
        fr(b) {
            l -= c[i];
            for (int j = l + 1; j <= l + c[i]; j++) cout << j << ' ';
        }
    } else cout << -1;
}


Measured memory_bytes: 3328
n,m=io.read("*n","*n")
c,d={},{}
for i=1,m do
	local a,b=io.read("*n","*n")
	if a==1 then c[#c+1]=b end
	if b==n then d[a]=true end
end
for _,i in ipairs(c)do
	if d[i] then
		print("POSSIBLE")
		os.exit()
	end
end
print("IMPOSSIBLE")

Measured memory_bytes: 5044
# coding : utf-8

import numpy as np

N = int(input())
X = np.array([int(i) for i in input().split()])

X = np.sort(X)
maxl = np.max(X)
Xed = (X - maxl/2)**2
com = X[np.where(Xed == np.min(Xed))]

print(maxl,com[0])


Measured memory_bytes: 23352
#include <bits/stdc++.h>
using namespace std;
const int N=200010;
int n,a[N],b[N];
long long ans=LLONG_MAX,sum1,sum2,sum[N];
int main(){
    scanf("%d",&n);
    for (int i=1; i<=n; ++i) scanf("%d%d",&a[i],&b[i]);
    long long sum1=0,sum2=0;
    multiset<int> s;
    for (int i=1; i<=n; ++i){
	sum1+=a[i];
	sum2+=b[i];
	s.insert(a[i]);
	s.insert(b[i]);
    }
    for (int i=1; i<=n; ++i){
	sum[i]=sum[i-1]+(*s.begin());
	s.erase(s.begin());
    }
    for (int i=1; i<=n; ++i){
	int x=a[i],y=b[i];
	if (x>y) swap(x,y);
	if (x<=sum[n-1]-sum[n-2]){
	    if (y<=sum[n]-sum[n-1]) ans=min(ans,sum[n]);
	    else ans=min(ans,sum[n-1]+y);
	}
	else ans=min(ans,sum[n-2]+x+y);
    }
    cout<<min(min(ans,sum1),sum2);
}

Measured memory_bytes: 11136
function Main(input){
    input = input.split(" ");
    tmp = parseInt(input[0]) + parseInt(input[1]) + parseInt(input[2]);
    if(tmp > 21){
     console.log("bust");   
    }else{
     console.log("win");
    }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
from sys import stdin
import sys

T = input()
if T == '?':
    print('D')
    sys.exit()
if T[0] == '?' and T[1] == '?':
    T = 'P'+T[1:]
    # print(T)
t = T[0]
ans = []
if t == '?' and T[1] == 'D':
    ans.append('P')
elif t == '?' and T[1] == 'P':
    ans.append('D')
else:
    ans.append(t)

for i in range(1, len(T)):
    if t == 'P':
        if T[i] == '?':
            ans.append('D')
            t = 'D'
        else:
            ans.append(T[i])
            t = T[i]
    elif t == 'D' and i < len(T)-1 and T[i+1] == '?':
        if T[i] == '?':
            ans.append('P')
            t = 'P'
        else:
            ans.append(T[i])
            t = T[i]
    elif t == 'D' and i < len(T)-1 and T[i+1] == 'D':
        if T[i] == '?':
            ans.append('P')
            t = 'P'
        else:
            ans.append(T[i])
            t = T[i]
    else:
        if T[i] == '?':
            ans.append('D')
            t = 'D'
        else:
            ans.append(T[i])
            t = T[i]
print(''.join(ans))


Measured memory_bytes: 11096
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; ll k; cin>>n>>k;
    ll a[510];
    ll s=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        s+=a[i];
    }
    vector<ll> vd;
    for(ll i=1; i*i<=s; i++){
        if(s%i==0){
            vd.push_back(i);
            if(i*i<s) vd.push_back(s/i);
        }
    }
    sort(vd.begin(), vd.end());
    ll ans=1;
    for(auto d:vd){
        ll x[510];
        ll sr=0, m;
        for(int i=0; i<n; i++){
            x[i]=a[i]%d;
            sr+=x[i];
        }
        m=sr/d;
        if(m==0){
            ans=d;
            continue;
        }
        sort(x, x+n);
        int i=0;
        while(x[i]==0) i++;
        ll sum=0;
        for(int j=0; j<n-i-m; j++){
            sum+=x[i+j];
        }
        if(sum<=k) ans=d;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
    #define DEBUG(x) cout << '>' << #x << ':' << x << endl;
    using namespace std;
    typedef long long LL;

    int main() {
        LL N;
        scanf("%lld", &N);
        int res = 2;
        // DEBUG(N);
        if (N == 2) {puts("1"); return 0;}
        if (N == 3) {puts("2"); return 0;}
        if (N == 4) {puts("3"); return 0;}
        // int res1 = 2;
        // for (int i = 2; i <= N - 2; i++) {
        //     if (N % i == 0) {
        //         int n = N;
        //         while (n % i == 0) n /= i;
        //         if (n % i == 1) { cout << "gena" << i << endl; res1++;}
        //     } else if (N % i == 1) {
        //         cout << "gene" << i << endl;
        //         res1++;
        //     }
        // }
        for (int i = 2; i <= sqrt(N); i++) {
            if ((N - 1) % i == 0) res += 1 + (i != (N - 1) / i);
            if (N % i != 0) continue;
            LL n = N;
            while (n % i == 0) n /= i;
            if (n % i == 1) res++;
        }
        // cout << res1 << endl;
        cout << res << endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define incant() cin.tie(0), ios::sync_with_stdio(false)
#define int long long
#define uint unsigned long long
#define double long double
using str = string;
template <class T> using vec = vector<T>;
template <class T> using vvec = vec<vec<T>>;
template <class T> using que = queue<T>;
template <class T> using pque = priority_queue<T>;
template <class... T> using tup = tuple<T...>;
using vint = vec<int>;
using vvint = vvec<int>;
using vstr = vec<str>;
using pint = pair<int, int>;
using vp = vec<pint>;
using tll = tup<int, int, int>;
using vt = vec<tll>;
using mint = map<int, int>;
using dict = map<str, int>;
using qint = que<int>;
using qp = que<pint>;
using pqint = pque<int>;
using pqp = pque<pint>;
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fir first
#define sec second
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define sz(x) x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define ms(v, x) memset(v, x, sizeof(v))
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload3(__VA_ARGS__, revi, _rev,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) out(x), indent()
#define debug(x) cerr << __LINE__ << ": " << #x << ": " << (x) << '\n'
#define YN(x) print((x) ? "YES" : "NO")
#define Yn(x) print((x) ? "Yes" : "No")
#define yn(x) print((x) ? "yes" : "no")
#define POS(x) print((x) ? "POSSIBLE" : "IMPOSSIBLE")
#define Pos(x) print((x) ? "Possible" : "Impossible")
#define pos(x) print((x) ? "possible" : "impossible")
const int INF = 1e16, MOD = 1e9 + 7, LIMIT = 100001;
const int dx4[] = {-1, 0, 1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const double EPS = 1e-9;
int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}
int lcm(int a, int b){return a / gcd(a, b) * b;}
int factorial(int a){return a < 2 ? 1 : factorial(a - 1) * a;}
int summation(int a){return a < 1 ? 0 : (a * a + a) / 2;}
int combination(int n, int r){int res = 1; rep(i, 1, r + 1) res *= n--, res /= i; return res;}
const str alphabet = "abcdefghijklmnopqrstuvwxyz";
int a, b, c, n, m, x, y, z, w, h, res = 0, cnt = 0, sum = 0, mx = -INF, mn = INF;
str s, t;
bool flag = true;

signed main(){
    incant();
    cin >> n >> x;
    int v[n + 1] = {}, dp[n + 1] = {};
    rep(i, n){
        cin >> v[i];
    }
    rep(i, 1, n){
        dp[i] = INF;
        rep(j, 1, min(i + 1, x + 1)){
            chmin(dp[i], dp[i - j] + abs(v[i] - v[i - j]));
        }
    }
    print(dp[n - 1]);
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

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

lli f(lli a, lli b, lli c)
{
  lli n = a / 2;

  lli x = n * b * c;
  lli y = (a - n) * b * c;
  return labs(x - y);
}

int main(int argc, char *argv[])
{
  lli a, b, c;
  while (cin >> a >> b >> c) {
    lli mn = 1LL << 60;
    vector<lli> v = {a, b, c};
    sort(v.begin(), v.end());
    do {
      mn = min(mn, f(v[0], v[1], v[2]));
    } while (next_permutation(v.begin(), v.end()));
    cout << mn << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
            string s = Console.ReadLine();
            char c = char.Parse(s) ;
            int i = Convert.ToInt32(c) + 1;
            char ans = Convert.ToChar(i);
            Console.WriteLine(ans);
            */

            Console.WriteLine((char)((int)Convert.ToChar(Console.ReadLine()) + 1));
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



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

using namespace std;


typedef int32_t h_int32;
typedef int64_t h_int64;
typedef uint32_t uh_int32;
typedef uint64_t uh_int64;
typedef h_int64 h_int;

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

#define VINIT( v, type, n )vector<type> v; v.resize( n );
#define VINIT2( v, type, n, a )vector<type> v; v.resize( n, a );
#define VCIN( v, type, n ) VINIT( v, type, n ) REP( i, n ) cin >> v[i];

#define DOUT( x ) cerr << #x << " = " << x << "\n";
#define COUT( x ) cout << ( x ) << "\n";

#define INF 999999999



int N = 50;
h_int K;
h_int f( h_int x )
{
        return N - K - 1 + ( N + 1 ) * x;
}


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

        cin >> K;
        h_int a = K / N;
        h_int b = K % N;
        COUT( N );

        REP( i, N )
        {
                h_int x = a;
                if( i < b)
                {
                        x += 1;
                }
                if( i == N - 1)
                        cout << f( x ) << "\n";
                else
                        cout << f( x ) << " ";
        }


        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main()
{
  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  sort(a,a+n);

  int tmp=a[n-1],first=0,second=0,cnt;
  for(int i=n-2;i>=0;i--)
  {
    if(tmp==a[i])
    {
      first=a[i];
      cnt=i-=2;
      break;
    }
    else tmp=a[i];
  }
  tmp=a[cnt+1];
  for(int i=cnt;i>=0;i--)
  {
    if(tmp==a[i])
    {
      second=a[i];
      break;
    }
    else tmp=a[i];
  }

  cout<<(ll)first*second<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    int n,w,t;
    cin>>n>>w;
    vector<ii> v(n);
    for(auto &i:v) cin>>i.fi>>i.se;
    vector<ll> dp(100005,1e18);
    dp[0]=0;
    rep(i,n) {
        Repp(j,100000,v[i].se) {
            dp[j]=min(dp[j],dp[j-v[i].se]+v[i].fi);
        }
    }
    rep(i,100005) if(dp[i]<=w) t=i;
    cout<<t;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC066A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, s;

            string[] word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            int m = a;
            if (b > m) m = b;
            if (c > m) m = c;
            s = a + b + c - m;

  
            Console.WriteLine(s);

            //Console.ReadKey();
            
            

                
        }
    }
}


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n;
    cin>>n;
    cout<<n/2+n%2<<endl;
    return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 N;
    cin >> N;
    vector<i64> A(N);
    rep(i, 0, N) cin >> A[i];

    vector<i64> p(N), q(N);
    p[0] = 0;
    q[0] = 2;
    rep(i, 1, N) {
        p[i] = 2 * A[i] - p[i - 1];
        q[i] = -q[i - 1];
    }

    i64 x=(2 * A[0] - (p[0] + p[N - 1]))  / (q[0] + q[N - 1]);

    vector<i64> ans(N);
    rep(i,0,N){
        ans[i]=p[i]+q[i]*x;
    }
    rep(i,0,N){
        cout << ans[(i+N-1)%N];
        if(i==N-1) cout << endl;
        else cout << " ";
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 4480
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  ll K;
  cin>>K;
  if(S[0]!=S[S.size()-1]) {
    ll ans = 0;
    for(int i=0;i<S.size()-1;++i) {
      if(S[i]==S[i+1]) {
        ans++;
        i++;
      }
    }
    cout<<ans*K<<endl;
    return 0;
  }
  int index1=0, index2=0;
  bool ok = false;
  for(int i=0;i<S.size();++i) {
    index1 = i;
    if(S[i]!=S[0]) {
      ok = true;
      break;
    }
  }
  for(int i=S.size()-1;i>=0;--i) {
    index2 = i+1;
    if(S[i]!=S[S.size()-1]) {
      ok = true;
      break;
    }
  }
  if(!ok) {
    cout<<S.size()*K/2<<endl;
    return 0;
  }
  ll ans = 0;
  for(int i=index1;i<index2;++i) {
    if(S[i]==S[i+1]) {
      ans++;
      i++;
    }
  }
  ll zero = 0;
  ans *= max(zero, (K-2));
  ans += (index1+(S.size()-index2))/2*(K-1);
  for(int i=0;i<index2;++i) {
    if(S[i]==S[i+1]) {
      ans++;
      i++;
    }
  }
  for(int i=S.size()-1;i>=index1;--i) {
    if(S[i]==S[i-1]) {
      ans++;
      i--;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3636
#include <iostream>
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <queue>

using namespace std;

int main()
{
    int H, W;

    cin >> H >> W;
    array<int, 26> num_alpha;
    fill(num_alpha.begin(), num_alpha.end(), 0);

    for (int y = 0; y < H; y++)
    {
        for (int x = 0; x < W; x++)
        {
            char temp;
            cin >> temp;
            num_alpha[temp - 'a']++;
        }
    }

    for (int w = 0; w < (W / 2); w++)
    {
        int n4 = H / 2;
        int n2 = H % 2;
        while (n4 > 0)
        {
            int i;
            for (i = 0; i < 26; i++)
            {
                if (num_alpha[i] >= 4)
                {
                    num_alpha[i] -= 4;
                    n4--;
                    break;
                }
            }
            if (i == 26)
            {
                std::cout << "No" << std::endl;
                return 0;
            }
        }
        sort(num_alpha.begin(), num_alpha.end());
        while (n2 > 0)
        {
            int i;
            for (i = 0; i < 26; i++)
            {
                if (num_alpha[i] >= 2)
                {
                    num_alpha[i] -= 2;
                    n2--;
                    break;
                }
            }
            if (i == 26)
            {
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }

    if (W % 2 == 1)
    {
        int n2 = H / 2;
        while (n2 > 0)
        {
            int i;
            for (i = 0; i < 26; i++)
            {
                if (num_alpha[i] >= 2)
                {
                    num_alpha[i] -= 2;
                    n2--;
                    break;
                }
            }
            if (i == 26)
            {
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "Yes" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
const int MX = 100005;



struct Sieve {
        int n;
        vector<int> f,primes;
        
        Sieve(int n=1):n(n),f(n+1){
                f[0] = f[1] = -1;
                for(long long i=2;i<=n;++i){
                        if(f[i]) continue;
                        primes.push_back(i);
                        f[i] = i;
                        for(long long j = i*i;j <= n;j += i) {
                                if(!f[j]) f[j] = i;
                        }
                }
        }
        
        bool isPrime(int x){return f[x] == x;}
        
        vector<int> factorList(int x){
                vector<int> res;
                while(x != 1){
                        res.push_back(f[x]);
                        x /= f[x];
                }
                return res;
        }
        
        vector<pair<int,int>> factor(int x){
                vector<int> fl = factorList(x);
                if(fl.size() == 0) return {};
                vector<pair<int,int>> res(1,pair<int,int>(fl[0],0));
                for(int p:fl){
                        if(res.back().first == p){
                                res.back().second ++;
                        }else{
                                res.emplace_back(p,1);
                        }
                }
                return res;
        }
        
};


int main(){
    Sieve sieve(MX);
    while(1){
        int n;
        cin >> n;
        if(n==0) break;
        int res = 0;
        int right = 0;
        int now = 0;
        for(int left=0;left<sieve.primes.size();left++){
            while(now + sieve.primes[right] <= n && right < sieve.primes.size()){
                now += sieve.primes[right];
                ++ right;
            }

            if(now==n){
                res ++;
            }

            if(left == right) right ++;
            else now -= sieve.primes[left];

        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
  int A;

  cin >> A;

  int count = 0;

  for (int i = 0; i < A; i++)
  {
    if((i+1)<10){
      count++;
    }
    else if ((i + 1) >= 100 && (i + 1) < 1000)
    {
      count++;
    }
    else if ((i + 1) >= 10000 && (i + 1) < 100000){
      count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
int ans[100005];
int x[100005];
int main(void){
    int n;
    int q;
    string s;
    cin>>n>>q>>s;
    for(int i=0;i<n-1;i++){
        if(s[i]=='A'&&s[i+1]=='C'){
            ans[i+1]++;
            x[i]=1;
        }
        if(i>0){
            ans[i+1]=ans[i+1]+ans[i];
        }
        //cout<<i<<" "<<ans[i+1]<<endl;
    }
    ans[n]=ans[n-1];
    while(q--){
        int l,r; cin>>l>>r;
        cout<<ans[r]-ans[l-1]-x[r-1]<<endl;
    }
    
}


Measured memory_bytes: 4504
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
signed main() {
    int N;cin>>N;
    priority_queue<int,vector<int>,greater<int>>Q;
    rep(i,N){
        int M;cin>>M;
        int x;cin>>x;
        Q.push(x);
        rep(j,M-1){
            int p;cin>>p;
            int now=Q.top();Q.pop();
            if(now<p)Q.push(p);
            else Q.push(now);
        }
    }
    int ans=0;
    while(!Q.empty()){
        int x=Q.top();Q.pop();
        ans+=x;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 6988
import math
N = int(input())
x = [0] * N 
y = [0] * N 
for i in range(N):
    X,Y = map(int,input().split())
    x[i] = X 
    y[i] = Y
    
total = 0
cnt = 0
def dfs(now,rest):
    global total,cnt
    for next in rest:
        #cnt += 1 * factorial(len(rest)-1)
        total += math.sqrt((x[now]-x[next])**2 + (y[now]-y[next])**2) * factorial(len(rest)-1)
        rest2 = rest.copy()
        rest2.remove(next)
        dfs(next,rest2)
    return 

def factorial(N):
    if N == 1 or N == 0:
        return 1
    else:
        return N * factorial(N-1)
        
for i in range(N):
    A = [j for j in range(N)]
    A.remove(i)
    dfs(i,A)
    
#print(total)
#print(cnt) #has to be 282240 when N=8
#print(factorial(N))
print(total / factorial(N))
        
    
    

Measured memory_bytes: 9028
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define stp setprecision(15)
#define eps 0.000001
#define endl '\n'
#define mod2 998244353
#define ll lli

using namespace std ;

#define N 200000+5 

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main() 
{
/////////////////////////////////////
    
    fastio;

    lld w,h,x,y;
    cin>>w>>h>>x>>y;

    lld k=(w/2) , kk = (h/2);

    lld ans = w*h;

    cout<<fixed<<stp<<ans/2<<" ";

    if(k == x && kk == y) cout<<1;
    else cout<<0;
}



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

int func(int n)
{
    int cnt=0;
    while(n)
        cnt++,n/=10;
    return cnt;
}

int main()
{
    int a,b;
    cin>>a>>b;
    int m=func(b);
    for(int i=1;i<=m;i++)
        a*=10;
    a=a+b;
    if(int(sqrt(a))==sqrt(a))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3520