akhauriyash/Code-Regression huggingface dataset:
import copy


def move(lon, lat, news):
    target, other, pop_index, insert_index = lon, lat, 0, 3
    if news == "E" or news == "W":
        target, other = lat, lon
    if news == "S" or news == "W":
        pop_index, insert_index = 3, 0
    target.insert(insert_index, target.pop(pop_index))
    other[0], other[2] = target[0], target[2]


def set_upper(lon, lat, upper):
    news = "N" if upper in lon else "E"
    while lon[0] != upper:
        move(lon, lat, news)


def rotate(lon, lat, com):
    if com == "R":
        lon[1], lat[1], lon[3], lat[3] = lat[3], lon[1], lat[1], lon[3]
    elif com == "L":
        lon[1], lat[1], lon[3], lat[3] = lat[1], lon[3], lat[3], lon[1]


def compare(val1, val2):
    lon2, lat2 = copy.copy(longitude), copy.copy(latitude)
    for u in range(6):
        set_upper(lon2, lat2, u)
        for f in range(4):
            rotate(lon2, lat2, "R")
            if False not in map(lambda x1, x2: val1[x1] == val2[x2], longitude + latitude, lon2 + lat2):
                return True
    return False


longitude = [0, 1, 5, 4]
latitude = [0, 3, 5, 2]
# values = input().split()
# newses = input()
# for c in newses:
#     move(longitude, latitude, c)
# print(values[longitude[0]])

# values = input().split()
# n = int(input())
# for i in range(n):
#     x, y = map(lambda z: values.index(z), input().split())
#     lon_work, lat_work = copy.copy(longitude), copy.copy(latitude)
#     set_upper(lon_work, lat_work, x)
#     while y != lon_work[1]:
#         rotate(lon_work, lat_work, "R")
#     print(values[lat_work[3]])

# values1 = input().split()
# values2 = input().split()
# print("Yes" if compare(values1, values2) else "No")

values = []
n = int(input())
for i in range(n):
    values.append(input().split())
value1, *tail = values
while tail:
    for value2 in tail:
        if compare(value1, value2):
            print("No")
            exit()
    head, *tail = tail
print("Yes")



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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while(b<=a){
        b*=2;
        k --;
    }
    while(c<=b){
        c*=2;
        k --;
    }

    if(k>=0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main{
	
	//2213 start
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0)break;
			int ans = 0;
			for(int i = 1 ; i < n; i++){
				int sum = i;
				for(int j = i+1; j <= n; j++){
					sum += j;
					if(sum == n){
						ans++;
						break;
					}
					else if(sum > n){
						break;
					}
				}
			}
			System.out.println(ans);
		}
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

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

public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        int n = obj.nextInt(),arr[] = new int[n];
        for(int i=0;i<n;i++) arr[i] = obj.nextInt();
        boolean flag = true;
        for(int i=0;i<n;i++)
        {
            if((arr[i]%2==0 && (arr[i]%3!=0 && arr[i]%5!=0)))
            {
                flag = false;
                break;
            }
        }
        System.out.println((flag)?"APPROVED":"DENIED");
    }
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const int Max_Num=1e5+10;

vector<vector<P>> G(Max_Num);
int ans[Max_Num];
int K;
void dfs(int n, int col=0, int par=-1){
	int c=1;
	rep(i,G[n].size()){
		int next=G[n][i].first;
		int num=G[n][i].second;
		if(next==par) continue;
		if(c==col) c++;
		ans[num]=c;
		K=max(K,c);
		dfs(next, c, n);
		c++;
	}
}

int main(){
	int N;
	cin >> N;
	K=0;
	rep(i,N-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].emplace_back(P(b,i));
		G[b].emplace_back(P(a,i));
	}
	dfs(0);
	cout << K << endl;
	rep(i,N-1) cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 9344
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int a, b;
	cin >> a >> b;

	int l = a - 2 * b;
	if (l < 0) {
		l = 0;
	}
	cout << l << endl;

}


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

int main() {
  string S, T; cin >> S >> T;
  bool ok = false;
  for (int rotation = 0; rotation < 2*S.length(); rotation++) {
    char S_tail = S.back();
    S.pop_back();
    S = S_tail+S;
    if (S == T) {
      ok = true;
      break;
    }
  }
  cout << (ok?"Yes":"No") << endl;
  return 0;
}


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

int main() {
	int x;
  
    rep(i, 5)  {
      cin >> x;
      if (x==0) {
        cout << i+1 << endl;
      }
    }
  
    return 0;
}

Measured memory_bytes: 3624
package main

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

type Graph [][]int

var INF = math.MaxInt32

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func (g Graph) floyd() {
	for k := 0; k < len(g); k++ {
		for i := 0; i < len(g); i++ {
			if g[i][k] == INF {
				continue
			}
			for j := 0; j < len(g); j++ {
				if g[k][j] == INF {
					continue
				}
				g[i][j] = min(g[i][j], g[i][k]+g[k][j])
			}
		}
	}
}

func (g Graph) printAPSP() {
	negative := false

	// 負の閉路がないかチェック
	for i := 0; i < len(g); i++ {
		if g[i][i] < 0 {
			negative = true
		}
	}

	if negative {
		fmt.Println("NEGATIVE CYCLE")
		return
	}

	for _, v := range g {
		ans := ""
		for _, d := range v {
			if d == INF {
				ans += fmt.Sprintf("INF ")
			} else {
				ans += fmt.Sprintf("%d ", d)
			}
		}
		ans = strings.Trim(ans, " ")
		fmt.Println(ans)
	}

}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)
	e := nextInt(sc)

	G := make(Graph, n)
	for i := 0; i < n; i++ {
		g := make([]int, n)
		for j := 0; j < n; j++ {
			g[j] = INF
			if i == j {
				g[j] = 0
			}
		}
		G[i] = g
	}

	var s, t, d int
	for i := 0; i < e; i++ {
		s = nextInt(sc)
		t = nextInt(sc)
		d = nextInt(sc)
		G[s][t] = d
	}
	G.floyd()
	G.printAPSP()
}



Measured memory_bytes: 5304
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int n,k;
int main(){
    cin>>n>>k;
    vector<int> v(n);
    rep(i,n) cin>>v[i];
    int sum=0;
    rep(i,n){
        sum+=min(abs(v[i]),abs(v[i]-k))*2;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _011_B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            long[] array = ReadLongs();
            Array.Sort(array);
            long[] sums = new long[n];
            sums[0] = array[0];
            for(int i =1; i < n; i++)
            {
                sums[i] = sums[i - 1] + array[i];
            }
            int cnt = 1;
            for(int i = n - 2; i >= 0; i--)
            {
                if (sums[i]*2 < array[i + 1])
                {
                    Console.WriteLine(cnt);
                    return;
                }
                cnt++;
            }
            Console.WriteLine(cnt);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

long H = 0;
long A[2000000];

void maxHeapify(long i) {
  long largest;
  long l = 2*i;
  long r = 2*i+1;

  if (l <= H && A[l] > A[i]) largest = l;
  else largest = i;

  if (r <= H && A[r] > A[largest]) largest = r;

  if (largest != i) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

long extractMax() {
  long c_max = A[1];
  swap(A[1], A[H]);
  H--;
  maxHeapify(1);
  return c_max;
}

void insert(long k) {
  A[++H] = k;
  long i = H;
  while (i > 1 && A[i/2] < A[i]) {
    swap(A[i/2], A[i]);
    i /= 2;
  }
}

int main() {
  string op; cin >> op;

  while (op != "end") {
    if (op[0] == 'i') {
      long k; cin >> k;
      insert(k);
    } else {
      cout << extractMax() << endl;
    }
    cin >> op;
  } 

  return 0;
}

Measured memory_bytes: 9396
#pragma warning(disable:4996)
#include "bits/stdc++.h"
using namespace std;

//macro
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,a,b) for(int i=(int)(b) - 1;i>=(int)(a);i--)
#define rrep(i,n) RREP(i,0,n)
#define each(i, ctn) for (auto &&i : (ctn))
#define all(a) (a).begin(),(a).end()
#define mp make_pair
#define INFL 1145148100000000000LL
#define EPS (1e-8)
#define MOD 1000000007
#define PI 3.141592653589793
#define equals(a,b)(fabs((a)-(b))<EPS)

//alias
using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vs = vector<string>;
using P = pair<ll, ll>;
template<class T> using heap = priority_queue<T>;
template<class T> using minheap = priority_queue<T, vector<T>, greater<T>>;

//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H);	rep(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n)os << v[i] << (i == n - 1 ? "\n" : " "); return os; }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template<class T> inline void print(const T &x) { cout << x << '\n'; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;


int main()
{
	int N;
	cin >> N;
	vll ans(87);
	ans[0] = 2;
	ans[1] = 1;
	for(int i = 2; i<=N;++i){
		ans[i] = ans[i - 1] + ans[i - 2];
	}
	print(ans[N]);

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N,L = map(int, input().split())
A = []
ans = 0

for i in range(1, N + 1):
	A.append(L + i - 1)

if A[0] > 0:
	for j in range(1, N):
		ans += A[j]

elif A[N - 1] < 0:
	for j in range(0, N - 1):
		ans += A[j]

else:
	for j in range(N):
		ans += A[j]
print(ans)

Measured memory_bytes: 3064
n = gets.to_i
h = gets.split.map(&:to_i)
flag = true
hm = -1

if n == 1
  puts 'Yes'
else
  (n-1).times do |i|
    if h[i] < hm
      flag = false
      break
    end

    if h[i] > h[i+1]
      if h[i] - h[i+1] > 1
        flag = false
        break
      else
        if hm < h[i] - 1
          hm = h[i] - 1
        end
      end
    else
      if hm < h[i] - 1
        hm = h[i] - 1
      end
    end
  end

  if hm > h[-1]
    flag = false
  end


  if flag
    puts 'Yes'
  else
    puts 'No'
  end
end



Measured memory_bytes: 8588
#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,sum;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        sum=a+b;
        sum=(log10(sum))+1;
        printf("%d\n",sum);
    }
    return 0;

}

Measured memory_bytes: 644
def test():

	i = list(map(float,input().split()))

	area = i[0] * i[0] * 3.141592653589
	circ = 2 * i[0] * 3.141592653589

	print(f"{area:.6f} {circ:.6f}")

if __name__ == "__main__":
	test()



Measured memory_bytes: 5600
#include<iostream>
using namespace std;
int main(){
	char s[4];
	int i,p=0;
	for(i=0;i<4;i++){
		cin>>s[i];
	}
	if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])p=1; 
	if(s[0]==s[2]&&s[3]==s[1]&&s[0]!=s[3])p=1;
	if(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1])p=1;
	if(p==1){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int main() {
	int a, b;
	cin >> a >> b;
	a--; b--;
	cout << a * b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string N;
    cin>>N;
    int sum = 0;
    for(int i=0;i<N.length();++i){
        sum += (N[i]-'0');
        sum = sum%9;
    }
    if(sum!=0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}

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

int main(){
	// sengen
	long long n,q;
	// nyuryoku
	cin >> n;
	long long a[n];
	long long count[1000000] = {};
	long long sum = 0;
	for(long long i=0;i<n;i++){
		cin >> a[i];
		sum += a[i];
		count[a[i]]++;
	}
	cin >> q;
	long long b[q],c[q];
	for(long long i=0;i<q;i++){
		cin >> b[i] >> c[i];
	}
	// keisan
	for(long long i=0;i<q;i++){
		if(count[b[i]] > 0){
			sum -= b[i]*count[b[i]];
			sum += c[i]*count[b[i]];
			count[c[i]] += count[b[i]];
			count[b[i]] = 0;
		}
		cout << sum << endl;
	}
	// syutsuryoku
}

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

using namespace std;

int num_n;

struct data_p
{
	int num;
	int juni;
	int n;

	bool operator<(const data_p& right) const {
		if (num_n == 0)
			return num < right.num;
		else
			return n < right.n;
	}
};

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

	vector<data_p> table;

	for (int i = 0; i < n; i++)
	{
		data_p d;
		cin >> d.num;
		d.n = i;
		table.push_back(d);
	}

	num_n = 0;

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

	for (int i = 0; i < n; i++)
	{
		table[i].juni = i;
	}

	int ans[2] = { table[n / 2].num,table[n / 2 - 1].num };

	num_n = 1;

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

	for (int i = 0; i < n; i++)
	{
		if (table[i].juni < n / 2)
			cout << ans[0] << endl;
		else
			cout << ans[1] << endl;
	}

	return 0;
}

Measured memory_bytes: 5232
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    X=I()
    ans=(X//500)*1000
    ans+=((X%500)//5)*5
    print(ans)

main()


Measured memory_bytes: 38256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n,k = f()
    s = input()
    for i in range(n):
        if i == k-1:
            if s[i] == 'A':
                print('a', end= '')
            if s[i]== 'B':
                print('b', end='')
            if s[i] == 'C':
                print('c', end='')
        else:
        
            print(s[i], end = '')
    
    print()

solve()


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

string solve(string a,string b,int x,int y){
//	assert(a.size()+b.size()<=20);
//	cerr<<a<<" "<<b<<" "<<x<<" "<<y<<endl;
	if(b+a<a+b) swap(a,b),swap(x,y);
	if(!x||!y){
		string res;
		rep(i,1,x) res+=a;
		rep(i,1,y) res+=b;
		return res;
	}
	if(x<y){
		int u=y/x,v=y%x;
		string A=a,B;
		while(u--) A+=b; B=A+b;
		return solve(A,B,x-v,v);
	}
	int u=x/y,v=x%y;
	string A,B;
	while(u--) A+=a; A+=b; B=a+A;
	return solve(A,B,y-v,v);
}

string solve(string a,string b,string c,int x,int y,int z){
	if(b+a<a+b) swap(a,b),swap(x,y);
	if(c+a<a+c) swap(a,c),swap(x,z);
	if(c+b<b+c) swap(b,c),swap(y,z);
	if(!x) return solve(b,c,y,z);
	if(!y) return solve(a,c,x,z);
	if(!z) return solve(a,b,x,y);
	vector<string> s(x,a);
	REP(i,z) s[i%x]+=c;
	int cur=z%x;
	REP(i,y){
		s[cur++]+=b;
		if(cur==x) cur=z%x;
	}
	map<string,int> t;
	REP(i,x) t[s[i]]++;
	string S[3]; int C[3]={0,0,0},k=0;
	for(auto x:t) S[k]=x.fi,C[k++]=x.se;
	return solve(S[0],S[1],S[2],C[0],C[1],C[2]);
}

int main(){
	int x,y,z;
	cin>>x>>y>>z;
	cout<<solve("a","b","c",x,y,z)<<endl;	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
//解説でdeque（デック）型も
//やっていたので載せておく
//通常、先頭に要素を追加するとき計算量が大きくなるがこの方を使えば解決する
int main(){
    string s;
    cin >> s;
    deque<char> q;
    for(char c : s) q.push_back(c);
    bool flip = false;
    int Q;
    cin >> Q;
    rep(i,Q){
        int type;
        cin >> type;
        if(type == 1){
            flip = !flip;
        }else{
            int f;
            char c;
            cin >> f >> c;
            if(flip) f=3-f;
            if(f==1){
                q.push_front(c);
            }else{
                q.push_back(c);
            }
        }
    }
    if(flip){
        reverse(q.begin(),q.end());
    }
    string ans;
    for(char c : q) ans += c;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1412
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
const int MAXN=1e5+10;
int a[MAXN];
int m,n,l,p,k,ans,tot;
int inline read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main()
{
	n=read();
	for (int i=0;i<=14;i++)
	{
		p=i*7;
		m=n-p;
		if (m<0) break;
		if ((m%4)==0)
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;


	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include<unordered_map>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int>count(100004);
	rep(i, n) {
		int a;
		cin >> a;
		FOR(j, a, a + 3) {
			count[j]++;
		}
	}
	ll ans = *max_element(all(count));
	cout << ans << endl;
}


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

#define all(s) s.begin(), s.end()
#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second

const int MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    string s;
    cin >> s;
    int cnt[30] = {0};
    for (auto u : s) {
        cnt[u - 'a']++;
    }
    int ans = 1;
    for (int i = 0; i < 26; i++) {
        ans = (1LL * ans * cnt[i] + ans) % MOD;
    }
    cout << ans - 1;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

ll a[17], b[17];

int main(void) {
  cin >> n;
  if (n == 0) {
	cout << n << endl;
	return 0;
  }
  MAP mp;
  tmp = 1;
  rep(i, 17) {
	a[i] = tmp;
	tmp *= -2;
  }
  tmp = powl(-2, 17);
  b[0] = tmp;
  FOR(i,1, 16) {
	b[i] = b[i - 1] * (-2);
  }
  rep(bit, 1 << 17) {
	tmp = 0;
	rep(i, 17) if (bit >> i & 1) tmp += a[i];
	if (tmp == n) {
	  rrep(j, 17) {
		if (bit >> j & 1) {
		  cout << "1";
		  flag = true;
		}
		else if(flag) cout << "0";
	  }
	  cout << endl;
	  return 0;
	}
	mp[tmp]++;
  }

  rep(bit, 1 << 16) {
	tmp = 0;
	rep(i, 16) if (bit >> i & 1) tmp += b[i];
	if (mp[n - tmp]) {
	  ans = n - tmp;
	  rrep(j, 16) {
		if (bit >> j & 1) {
		  cout << "1";
		  flag = true;
		}
		else if(flag) cout << "0";
	  }
	}
  }

  rep(bit, 1 << 17) {
	tmp = 0;
	rep(i, 17) if (bit >> i & 1) tmp += a[i];
	if (tmp == ans) {
	  rrep(j, 17) {
		if (bit >> j & 1)cout << "1";
		else cout << "0";
	  }
	}
  }
  cout << endl;

  return 0;
}

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

int main() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	
	int count=0;
	
	for(int i=1;i<n;i++){
		if(s[i]==s[i-1])count++;
	}
	
	cout<<n-count<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 10000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int N, x;
int m;

int main(){
    scanf("%d%d", &N, &x);
    int res=INF;

    REP(i, N){
        scanf("%d", &m);
        x -= m;
        res = min(res, m);
    }

    int d = x / res;

    printf("%d\n", N+d);

	return 0;
}

Measured memory_bytes: 256
N,M=map(x->parse(Int,x),split(readline()))
s=zeros(Int,M,N)
for i=1:M
	t=map(x->parse(Int,x),split(readline()))
	for j=t[2:end]
		s[i,j]=1
	end
end
p=map(x->parse(Int,x),split(readline()))
ans=0
for i=0:(1<<N)-1
	flag=true
	for j=1:M
		now=p[j]
		for k=1:N
			now+=(i>>(k-1))%2*s[j,k]
		end
		if now%2!=0
			flag=false
		end
	end
	ans+=flag
end
println(ans)


Measured memory_bytes: 118664
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define reprd(i,a,b) for (int i=(a);i>=(b);--i)
#define repr(i,n) reprd(i,n,0)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 310;
int H, W, K;
char s[Max][Max];
int a[Max][Max];

bool isEmptyRow(int row) {
    rep(i, W) {
        if (s[row][i] == '#') return false;
    }
    return true;
}

int main(int argc, const char * argv[]) {
    cin >> H >> W >> K;
    rep(i, H) {
        string Si;
        cin >> Si;
        rep(j, W) {
            s[i][j] = Si[j];
        }
    }
    memset(a, 0, sizeof(int)*Max*Max);

    int firstRow = -1;
    int currentNo = 0;
    rep(i, H) {
        if (isEmptyRow(i)) {
            if (firstRow >= 0) {
                rep(j, W) {
                    a[i][j] = a[i-1][j];
                }
            }
        } else {
            if (firstRow < 0) firstRow = i;
            int firstCol = -1;
            rep(j, W) {
                if (s[i][j] == '#') {
                    if (firstCol < 0) firstCol = j;
                    currentNo++;
                }
                a[i][j] = currentNo;
            }
            rep(j, firstCol) {
                a[i][j] = a[i][firstCol];
            }
        }
    }

    rep(i, firstRow) {
        rep(j, W) {
            a[i][j] = a[firstRow][j];
        }
    }

    rep(i, H) {
        rep(j, W) {
            printf("%d ", a[i][j]);
        }
        printf("\n");
    }

    return 0;
}

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

bool ch[10] = {};

bool check(int n){
    while(n!=0){
        if(ch[n%10]) return false;
        n /= 10;
    }
    return true;
}

int main(){
    int N,K,D;
    cin >> N >> K;
    for(int i=0; i<K; ++i){
        cin >> D;
        ch[D] = true;
    }

    int res=N;
    for(int i=N; i<100000; i++){
        if(check(i)){
            res = i;
            break;
        }
    }
    cout << res << endl;
    
}


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


int main(){
    int n,cnt=0;
    cin>>n;
    vector<long int> v(n),b(n,0);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    
    int top=0,tail=n-1;
    for(int i=n-1;i>=0;i--){
        if(cnt%2==0){
            b[top]=v[i];
            top++;
        }else{
            b[tail]=v[i];
            tail--;
        }
        cnt++;
    }
    for(int i=0;i<n;i++){
        cout<<b[i]<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 5248
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++)
            d[i] = sc.nextInt();
        Arrays.sort(d);

        int ans = 1;

        for (int i = 0; i < n - 1; i++) {
            if (d[i] != d[i + 1])
                ans++;
        }

        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    cout<<(n+1)/2<<endl;
    return 0;
}


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

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009ll
#define INFL 1000000000000000018ll
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mk make_pair
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<pair<int, PA> , vector<pair<int, PA> >, greater<pair<int, PA> > >PQG;

int N, M;
string s, t;

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

map<int, char> used;

signed main()
{
    cin >> N >> M;
    cin >> s >> t;
    int L = N * M / gcd(N, M);
    for(int i = 0; i < max(N, M); i++){
        //printf("%lld\n", i);
        if(i == 0){
            if(s[i] != t[i]){
                printf("-1\n");
                return 0;
            }
            used[i + 1] = s[i];
        }
        else{
            if(i < N){
            if(used[i * (L / N) + 1] == '\0'){
                used[i * (L / N) + 1] = s[i];
            }
            else if(used[i * (L / N) + 1] != s[i]){
                printf("-1\n");
                return 0;
            }}
            if(i < M){
            if(used[i * (L / M) + 1] == '\0'){
                used[i * (L / M) + 1] = t[i];
            }
            else if(used[i * (L / M) + 1] != t[i]){
                printf("-1\n");
                return 0;
            }}
        }
    }
    printf("%lld\n", L);

    return 0;
}
/*



*/


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;

double eps=1e-8;

bool eq(double a,double b){
  return (-eps<a-b&&a-b<eps);
}

int main(){
  int n;
  double ax,ay,bx,by,cx,cy,dx,dy;
  scanf("%d",&n);
  while(n--){    
    scanf("%lf %lf %lf %lf",&ax,&ay,&bx,&by);
    scanf("%lf %lf %lf %lf",&cx,&cy,&dx,&dy);
    P A=P(ax,ay),B=P(bx,by);
    P C=P(cx,cy),D=P(dx,dy);
    A-=B;
    C-=D;
    if(eq(0,imag(A/C)))printf("2\n");
    else if(eq(0,real(A/C)))printf("1\n");
    else printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, mi = INF, ma = 0;
	bool F = true;
	cin >> N;
	VI A(N);
	REP(i, N) {
		cin >> A[i];
		mi = min(mi, A[i]);
		ma = max(ma, A[i]);
	}
	if (ma - mi >= 2) {
		cout << "No" << endl;
		return 0;
	}
	if (mi == ma) {
		bool f = true,ff=true;
		REP(i, N) {
			if (A[i] != N - 1)f = false;
			if (A[i]*2 > N)ff = false;
		}
		cout << (f||ff ? "Yes" : "No") << endl;
		return 0;
		
	}
	else {
		int a = 0, b = 0;
		REP(i, N) {
			if (A[i] == ma)a++;
			else b++;			
		}
		cout << ((b<ma)&&2*(ma-b)<=a ? "Yes" : "No") << endl;
	}
	
	return 0;
}



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

int n, m, k;
int main()
{
    while(~scanf("%d%d%d", &n, &m, &k))
    {
        int a, b, x, y, ans = 0;
        scanf("%d%d", &a, &b);
        for(int i = 1; i < k; i++)
        {
            int x, y;
            scanf("%d%d", &x, &y);
            if(x > a && y > b) ans += max(abs(x - a), abs(y - b));
            else if(x < a && y < b) ans += max(abs(x - a), abs(y - b));
            else ans += abs(x - a) + abs(y - b);
            a = x, b = y;
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<ll, int> P;

int main(){
	int N; cin >> N;
	int a[N+1], b[N+1];
	for(int i=1; i<=N; i++){ a[i] = 20000*i; b[i] = 20000*(N-i+1); }
	for(int i=0; i<N; i++){
		int p; cin >> p;
		a[p] += i; b[p] += i;
	}
	for(int i=1; i<=N; i++){
		cout << a[i] << " ";
	}
	cout << "\n";
	for(int i=1; i<=N; i++){
		cout << b[i] << " ";
	}
	cout << "\n";
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

/*  divisor(n)
    入力：整数 n
    出力：nのすべての約数
    計算量：O(√n)
*/
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

/*  prime_factor(n)
    入力：整数 n
    出力：nの素因数分解
    計算量：O(√n)前後
*/
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;  // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;
/*  is_prime(n)
    入力：整数 n
    出力：nが素数かの真偽値
    計算量：O(√n)
*/
bool is_prime(long long n) {  // is n prime or not
    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}
int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    auto div = divisor(N - 1);
    ans += (int)div.size() - 1;

    //debug(ans);

    auto pf = divisor(N);
    for (auto k : pf) {
        if (k == 1 || k == N) continue;
        ll now = k;
        while (N % now == 0) {
            if ((N / now - 1) % k == 0) { ans++; }
            //            if (N / now == now) ans--;
            now *= k;
        }
    }
    //if (!is_prime(N)) ans++;
    cout << ans + 1 << endl;
}


Measured memory_bytes: 384
'''
考え方
n行 m列の行列
「全ての行に登場する数字」の種類数を数える

'''

n, m = map(int, input().split())
k_rows = [list(map(int, input().split())) for i in range(n)]

# print(k_rows)

## 全行の積集合を取得
# 全てのmをリスト化
k_intersection = range(1,m+1)
for k_row in k_rows:
    # print(k_intersection)
    # print(k_row[1:])
    k_intersection = set(k_intersection) & set(k_row[1:])

# print(k_intersection)
print(len(k_intersection))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int Q = sc.nextInt();
        int[][] a = new int[n + 1][n + 1];
        for (int i = 0; i < m; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            a[l][r]++;
        }
        int[][] c = new int[n + 1][n + 1];
        for (int i = 0; i <= n; i++) {
            int sum = 0;
            for (int j = 0; j <= n; j++) {
                sum += a[i][j];
                c[i][j] = sum;
            }
        }
        int[] p = new int[Q];
        int[] q = new int[Q];
        for (int i = 0; i < Q; i++) {
            p[i] = sc.nextInt();
            q[i] = sc.nextInt();

        }
        for (int i = 0; i < Q; i++) {
            int pp = p[i];
            int qq = q[i];
            int ans = 0;
            for (int j = pp; j <= qq; j++) {
                ans += c[j][qq] - c[j][pp - 1];
            }
            System.out.println(ans);
        }

    }

}

Measured memory_bytes: 154548
#include <algorithm>
#include <ctype.h>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;

struct shop_t {
    string S;
    int P;
    int num;

    bool operator<(const shop_t &shop) const {
        return S == shop.S ? P > shop.P : S < shop.S;
    }
};

int main() {

    int N, i;
    cin >> N;

    vector<shop_t> v(N);

    REP(i, N) {
        cin >> v[i].S >> v[i].P;
        v[i].num = i+1;
    }

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

    REP(i, N) cout << v[i].num << endl;
}

Measured memory_bytes: 256
// Comment
//

#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 100;
const int CONST = MAX_N;

struct BIT {
	int P; vector<int> val;
	BIT(int n) {
		P = n + CONST + 100;
		val = vector<int>(P, 0);
	}
	void update(int v, int k) {
		for(v+=CONST; v<P; v+=v&-v) val[v] += k;
	}
	int getSum(int v) {
		int res = 0;
		for(v+=CONST; v>0; v-=v&-v) res += val[v];
		return res;
	}
	int getSum(int a, int b) {
		return getSum(b) - getSum(a);
	}
};

vector<int> Xs;
int N, Nr[MAX_N];

int main() {
	cin >> N;
	for(int i=0; i<N; i++) {
		scanf("%d", &Nr[i]);
		Xs.push_back(Nr[i]);
	}
	sort(ALL(Xs));
	Xs.erase(unique(ALL(Xs)), Xs.end());
	int ans = -1;
	ll all = 1ll * N * (N+1) / 2;
	for(int l=0, r=SZ(Xs)-1; l<=r; ) {
		int m = (l+r)>>1;
		int nr = Xs[m];

		int sum = 0;
		ll cnt = 0;
		BIT bit = BIT(MAX_N);
		bit.update(0, 1);

		for(int i=0; i<N; i++) {
			int v = (Nr[i] >= nr) * 2 - 1;
			sum += v;
			cnt += bit.getSum(sum);
			bit.update(sum, 1);
		}
		if (cnt >= all - (all/2+1) + 1) {
			ans = m;
			l = m+1;
		} else {
			r = m-1;
		}
	}
	printf("%d\n", Xs[ans]);
	return 0;
}


Measured memory_bytes: 5000
N = int(input())
X = list(map(int, input().split()))
X2 = [i**2 for i in X]
temp1 = sum(X2)
temp2 = sum(X)
result = 0

for P in range(1, max(X) + 1):
    if P == 1:
        rsum = temp1 - 2* temp2 * P + N * P**2
    rsum = min(rsum, temp1 - 2* temp2 * P + N * P**2)

print(rsum)




Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>

int main(){
	int a[10], b, i, j, k, ans[11];
	i = 0;
	j = 0;
	for(k = 0; k < 11; k++) ans[k] = 0;
	while(scanf("%d", &b) != EOF){
		if(b == 0){
			i--;
			ans[j] = a[i];
			printf("%d\n", ans[j]);
			j++;
		}else{
			a[i] = b;
			i++;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    string s;
    cin >> s;
    int k;
    cin >> k;
    char c = 'z';
    string cd = "";
    set<string> v;
    rep(i, s.size())
    {
        cd = "";
        cd += s[i];
        v.insert(cd);
    }
    queue<string> u;
    int cnt = 1;
    while(cnt <= 5){
        for(auto e:v){
            if(e.size() >= cnt){
                u.push(e);
            }
        }
        while(!u.empty()){
            auto e = u.front();
            u.pop();
            rep(i,s.size()-e.size()){
                bool flag = true;
                rep(j,e.size()){
                    if(s[i+j] != e[j]){
                        flag = false;
                    }                                        
                }
                if(flag){
                    v.insert(e + s[i + e.size()]);
                }
            }
        }
        cnt++;
    }
    cnt = 1;
    for(auto e : v){
        if(cnt == k){
            cout << e << endl;
            return 0;
        }
        cnt++;
    }
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define RREP(i, n) for(int i=0; i>(int)(n); i--)
#define ALL(v) v.begin(), v.end()
#define INF 2e9
typedef long long ll;
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(a>b){a=b; return 1;}return 0;}

using namespace std;

vector<vector<int>> G;
int dp[101010];

int res(int v)
{
	if(dp[v] != -1)
	{
		return dp[v];
	}
	int r=0;
	for(auto nv:G[v]){
		chmax(r, res(nv)+1);
	}
	return dp[v] = r;
}
int main(void){
	int N;
	int M;
	cin >> N >> M;
	G.assign(N, vector<int>());
	REP(i, M){
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		G[x].push_back(y);
	}
	REP(i, N){
		dp[i] = -1;
	}
	int ans = 0;
	REP(i, N){
		chmax(ans, res(i));
	}
	cout << ans << "\n";
}


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


int main(){
    string S;
    cin >> S;
    bool judge=true;
    if(S.size()%2 ==1) judge=false;
    for(int i=0;i<S.size();i++){
        if(i%2==0){
            if(S.at(i)!='h'){
                judge = false;
            }
        }else{
            if(S.at(i)!='i'){
                judge = false;
            }
        }
    }
    if(judge){
        cout << "Yes";
    }else{
        cout << "No";
    }
    }
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long ceil(long long a)
{
	if(a%2==0)
		return a/2;
	else
		return a/2+1;
}

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long a[n], sum=0, m=0, ans=1;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+n);
	sum-=a[n-1];
	for (int i=n-1;i>0;i--)
	{
		if(2*sum>=a[i])
			ans++;
		else
			break;
		sum-=a[i-1];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second   
#define mit mii::iterator
#define vit vi::iterator
#define all(a) a.begin(),a.end()
#define min3(a, b, c) min(a, min(b, c))
#define mod 1000000007
#define inf 1000000000
#define limit 200001
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 

void input()
{
    int n;
    cin >> n;
    vlli div(n+1, 1);

    loop(p,2,n+1,1)
    {
        if(div[p] != 1)
            continue;
        loop(j,p,n+1,p)
        {
            int x = j, e = 0;
            while(x%p == 0)
                e++, x=x/p;
            div[j] = div[j] * (1 + e);
        }
    }

    lli ans = 0;
    rep(i,n+1)
        ans += i * div[i];
    cout << ans << '\n';

}
 
int main()
{
    

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b;
  cin>>a>>b;
  
  int ans = a -2*b;
  
  if(ans>=0) {
    cout<<ans;
  } else {
    cout<<0;
  }
}

Measured memory_bytes: 256