akhauriyash/Code-Regression huggingface dataset:
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie();
	//cout.tie();		

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	
	int x, y;
	cin >> x >> y;
	if (x > 0)
	{
		if (y > 0)
		{
			if (x <= y)
				cout << y - x << endl;
			else
				cout << 2 + x - y << endl;
		}
		else if (y < 0)
		{
			if (x <= -y)
				cout << (-y) - x + 1 << endl;
			else
				cout << x + y + 1 << endl;
		}
		else
		{	
			cout << 1 + x << endl;
		}
	}
	else if (x < 0)
	{		
		if (y > 0)
		{
			if (-x <= y)
				cout << 1 + y - (-x) << endl;
			else
				cout << 1 + -x - y << endl;
		}
		else if (y < 0)
		{	
			if (x <= y)
				cout << y - x << endl;
			else
				cout << x - y + 2 << endl;
		}
		else
		{
			cout << -x << endl;
		}
	}
	else
	{
		if (y >= 0)
			cout << y << endl;
		else
			cout << -y + 1 << endl;
	}	

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>

using namespace std;
#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 300010;
const int INF = 1000000000;

int N,K; char str[MAXN+1];
deque<int> que;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(),K=read(); scanf("%s",str+1);
	for(int i=1,l=1;i<=N;i=l+1){
		l=i; while(l<N&&str[l+1]==str[i]) ++l;
		que.push_back(l); }
	int hd=(str[1]=='A'?1:0),bas=0;
	while(K--){
		if(que.size()==N) break;
		if(hd==1){
			int x=que.front()+bas;
			if(x==1) que.pop_front();
			else que.push_front(1-bas);
			hd^=1;
		}
		else {
			if(que.size()&1) que.pop_back();
			if(que.front()+bas!=1) hd^=1;
			--bas;
		}
		while(que.size()&&que.front()+bas<1) que.pop_front();
		if(!que.size()||que.back()+bas!=N) que.push_back(N-bas);
	} ++K;
	if(N&1) {
		if(K&1) que.pop_front(),hd^=1;
	}
	int now=0;
	while(!que.empty()){
		int k=que.front()+bas; que.pop_front();
		for(int i=now+1;i<=k;i++){
			if(hd) printf("A");
			else printf("B");
		} hd^=1; now=k;
	}
	return 0;
}


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



int main() {
  priority_queue<int> q;
char tag[20];
int value;

while(1){ //{}を閉じてない
  scanf("%s",tag);

  if(tag[0] == 'i')
  {
    scanf("%d",&value);
    q.push(value);
  } else if(tag[1] == 'x')
  {
    printf("%d\n",q.top());
    q.pop();
  } else if(tag[0] == 'e')
  {
    break;
  }
}



  return 0;
}



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

using ll = long long;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    queue<pair<int, int>> q;
    vector<vector<int>> B(H, vector<int>(W, -1));
    rep(i, H) {
        cin >> A[i];
        rep(j, W) {
            if (A[i][j] == '#') {
                q.push(make_pair(i, j));
                B[i][j] = 0;
            }
        }
    }
    int di[4] = {1, 0, -1, 0}, dj[4] = {0, 1, 0, -1}, ans = 0;
    while (!q.empty()) {
        auto p = q.front();
        q.pop();
        int i0 = p.first, j0 = p.second, d = B[i0][j0] + 1;
        //cout << "i0=" << i0 << " j0=" << j0 << " d=" << d << "\n";
        rep(k, 4) {
            int i = i0 + di[k], j = j0 + dj[k];
            if (i < 0 || i >= H || j < 0 || j >= W) continue;
            if (B[i][j] > -1) continue;
            q.push(make_pair(i, j));
            B[i][j] = d;
            //cout << "B[" << i << "][" << j << "]=" << B[i][j] << "\n";
            ans = max(ans, d);
        }
    }
    cout << ans << "\n";
    /*
    rep(i, H) {
        rep(j, W) cout << B[i][j];
        cout << "\n";
    }
    */
}

Measured memory_bytes: 13456
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String key = sc.next();
            if (map.containsKey(key)) {
                map.put(key, map.get(key) + 1);
            } else {
                map.put(key, 1);
            }
        }

        int m = Integer.parseInt(sc.next());
        for (int i = 0; i < m; i++) {
            String key = sc.next();
            if (map.containsKey(key)) {
                map.put(key, map.get(key) - 1);
            } else {
                map.put(key, -1);
            }
        }

        sc.close();

        int max = 0;
        for (String key : map.keySet()) {
            int num = map.get(key);
            max = Math.max(max, num);
        }
        int result = max;

        // 出力
        System.out.println(result);
    }
}


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

int main() {
    int k; string s;
    cin >> k >> s;
    if (s.size() <= k) {
        for (int i = 0; i < s.size(); i++) {
            cout << s[i];
        }
    } else {
        for (int i = 0; i < k; i++) cout << s[i];
        cout << "...";
    }
    cout << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X;
  cin >>A>>B>>C>>X;
  
  int count = 0;
   for(int i = 0;i <= A;i++){
    for(int j = 0;j <= B;j++){
      for(int k = 0;k <= C;k++){
        int total = 500*i+100*j+50*k;
        if(total == X) count++;
         }
       }
    }
  
  cout << count << endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define BOOST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ll long long
#define test(t) int t ; cin>>t ; while(t--)
ll mulmod(ll a, ll b, ll mod){ll res = 0;a = a % mod;while (b > 0){if (b % 2 == 1)res = (res + a) % mod;a = (a * 2) % mod;b /= 2;}return res % mod;}
int n;
int main(){
	BOOST;
	// cin >> n;
	string s , t;
	cin >> s >> t;
	s += s;
	if(s.find(t) == string::npos){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>

struct Coordinate {
	int x, y;
	Coordinate operator+(const Coordinate that) const {
		return Coordinate{ x + that.x, y + that.y };
	}
};
struct State {
	Coordinate position;
	int direction;
	long long int step;
};
int main() {
	std::array<Coordinate, 4> dir{ Coordinate{1, 0}, Coordinate{-1, 0}, Coordinate{0, 1}, Coordinate{0, -1} };
	int height, width, kick; std::cin >> height >> width >> kick;
	Coordinate start, goal; std::cin >> start.x >> start.y >> goal.x >> goal.y; --start.x; --start.y; --goal.x; --goal.y;
	std::vector<std::string> state(height); for (auto& line : state) std::cin >> line;
	std::vector<std::vector<std::vector<long long int>>> min_step(height, std::vector<std::vector<long long int>>(width, std::vector<long long int>(4, LLONG_MAX)));
	std::queue<State> normal, turned;
	for (auto i = 0; i < 4; ++i) {
		min_step[start.x][start.y][i] = 0;
		normal.push(State{ start, i, 0 });
	}
	const auto pop = [&normal, &turned]() {
		if (normal.empty() || (!turned.empty() && normal.front().step == turned.front().step)) {
			const auto result = turned.front();
			turned.pop();
			return result;
		}
		else {
			const auto result = normal.front();
			normal.pop();
			return result;
		}
	};
	while (!normal.empty() || !turned.empty()) {
		const auto top = pop();
		if (min_step[top.position.x][top.position.y][top.direction] != top.step) continue;
		const auto turned_step = (top.step + kick - 1) / kick * kick;
		for (auto d = 0; d < 4; ++d) if (d != top.direction && min_step[top.position.x][top.position.y][d] > turned_step) {
			min_step[top.position.x][top.position.y][d] = turned_step;
			turned.push(State{ top.position, d, turned_step });
		}
		const auto next_state = State{ top.position + dir[top.direction], top.direction, top.step + 1 };
		if (0 <= next_state.position.x && next_state.position.x < height &&
			0 <= next_state.position.y && next_state.position.y < width &&
			state[next_state.position.x][next_state.position.y] != '@' &&
			min_step[next_state.position.x][next_state.position.y][next_state.direction] > next_state.step
			) {
			min_step[next_state.position.x][next_state.position.y][next_state.direction] = next_state.step;
			normal.push(next_state);
		}
	}
	const auto min = *std::min_element(min_step[goal.x][goal.y].begin(), min_step[goal.x][goal.y].end());
	std::cout << (min != LLONG_MAX ? (min + kick - 1) / kick : -1) << '\n';
}


Measured memory_bytes: 144888
#include <stdio.h>

int main(void) {
	int N, X;
	int L[100] = {};
	int sum = 0;
	int count = 2;
	scanf("%d%d", &N, &X);
	for (int i = 0; i <= N-1; i++) {
		scanf("%d", &L[i]);
	}
	for (int i = 0; i < N; i++) {

		sum += L[i];

		if (sum > X) {
			sum -= L[i];
			break;
		}
	}

	for (int i = 0; i < N; i++) {
		L[i + 1] += L[i];
	}



	for (int i = 0; i < N; i++) {
		if (sum != L[i]) {
			count++;
		}
		else break;
	}

	printf("%d", count);

	return 0;

}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
a = int(input())
from collections import deque
stack_deque = deque([])


if a <= 9:
    print(a)
    from sys import exit
    exit()
else:
    base = [1,2,3,4,5,6,7,8,9]
    cnt = 9
    while cnt<a:
        nb = deque([])
        for i in base:
            first_v = i%10
            v = i*10
            if first_v==0:
                nb.append(v)
                cnt+=1
                if cnt==a:
                    break
                else:
                    nb.append(v+1)
                    cnt+=1
            elif first_v==9:
                nb.append(v+8)
                cnt+=1
                if cnt==a:
                    break
                else:
                    nb.append(v+9)
                    cnt+=1
            else:
                for j in [first_v-1,first_v,first_v+1]:
                    nb.append(v+j)
                    cnt+=1
                    if cnt==a:
                        break
                if cnt==a:
                    break
        base = nb
print(nb[-1])

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

struct Node
{
    int Parent;
    int Depth;
    std::vector<int> Child;
};

int main(void){
    int Num;
    std::cin >> Num;
    
    std::vector<Node> List;
    List.resize(Num);
    
    for(int i = 0; i < Num; i++){
        List[i].Parent = -1;
    }
    
    int Id, Jisu, Temp;
    
    //?????¨????????????
    for(int i = 0; i < Num; i++){
        std::cin >> Id;
        std::cin >> Jisu;
        
        List[Id].Depth = 0;

        List[Id].Child.clear();
        for(int j = 0; j < Jisu; j++){
            std::cin >> Temp;
            List[Id].Child.push_back(Temp);
            List[Temp].Parent = Id;
        }
    }
    
    //Depth
    for(int i = 0; i < Num; i++){
        int depth = 0;
        int ParentNumber = List[i].Parent;
        while(ParentNumber != -1){
            ParentNumber = List[ParentNumber].Parent;
            depth++;
        }
        List[i].Depth = depth;
    }
    
    
    //??????
    for(int i = 0; i < Num; i++){
        std::cout << "node ";
        std::cout << i;
        std::cout << ": parent = ";
        std::cout << List[i].Parent;
        std::cout << ", depth = ";
        std::cout <<  List[i].Depth;
        std::cout << ", ";
        if(List[i].Child.size() > 0){
            if(List[i].Parent == -1){
                std::cout << "root, [";
            } else{
                std::cout << "internal node, [";
            }
            for(int j = 0; j < List[i].Child.size(); j++){
                if(j > 0)   std::cout << ", ";
                std::cout << List[i].Child[j];
            }
            std::cout << "]";
        } else{
            if(Num > 1){
                std::cout << "leaf, []";
            } else{
                std::cout << "root, []";
            }
        }
        std::cout << std::endl;
    }
}

Measured memory_bytes: 6732
package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"math"
	"os"
	"strconv"
	"strings"
)

var (
	// ErrLineNotFound -
	ErrLineNotFound = errors.New("lines: line not found")
)

type onError int

const (
	onErrorPanic onError = iota
	onErrorError
)

// Lines represents multi line.
type Lines struct {
	r       io.Reader
	w       io.Writer
	onError onError

	store []string
}

// NewLines create lines from provided input reader.
func New(r io.Reader) *Lines {
	lines, err := newLines(r, ioutil.Discard, onErrorPanic)
	if err != nil {
		panic(err)
	}
	return lines
}

// Line represents single line.
type Line struct {
	store string
	field int
}

// Line return given n line.
func (ls *Lines) Line(n int) *Line {
	line, err := ls.line(n)
	if err != nil {
		panic(err)
	}
	return line
}

func (ls *Lines) line(n int) (*Line, error) {
	if n >= len(ls.store) {
		return nil, ErrLineNotFound
	}
	return &Line{store: ls.store[n]}, nil
}

func (l *Line) Ints() []int {
	ints, err := l.ints()
	if err != nil {
		panic(err)
	}
	return ints
}

func (l *Line) ints() ([]int, error) {
	var ints []int
	fields := strings.Fields(l.store)
	for _, s := range fields {
		i, err := strconv.Atoi(s)
		if err != nil {
			return nil, err
		}
		ints = append(ints, i)
	}
	return ints, nil
}

// Field specify current field scope.
func (l *Line) Field(n int) *Line {
	clone := l.clone()
	clone.field = n
	return clone
}

func (l *Line) Int() int {
	ints, err := l.ints()
	if err != nil {
		panic(err)
	}
	return ints[l.field]
}

func newLines(r io.Reader, w io.Writer, onError onError) (*Lines, error) {
	lines := &Lines{
		r:       r,
		w:       w,
		onError: onErrorError,
	}
	return lines, lines.init()
}

func (ls *Lines) init() error {
	s := bufio.NewScanner(ls.r)
	s.Buffer([]byte{}, math.MaxInt64)
	for s.Scan() {
		ls.store = append(ls.store, s.Text())
	}
	return s.Err()
}

func (l *Line) clone() *Line {
	clone := *l
	return &clone
}

func main() {
	lines := New(os.Stdin)
	n := lines.Line(0).Int()

	switch n {
	case 1:
		handle1()
	case 2:
		handle2(lines)
	default:
		panic("no way")
	}
}

func handle1() {
	fmt.Println("Hello World")
}

func handle2(lines *Lines) {
	a := lines.Line(1).Int()
	b := lines.Line(2).Int()
	fmt.Println(a + b)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
string S,T;
int main(){
	cin>>S;T=S;
	sort(T.begin(),T.end());
	T.erase(unique(T.begin(),T.end()),T.end());
	if(S.size()==T.size())cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>

int main (){
  int N;
  scanf("%d", &N);
	int A[N], B[N];
  for (int i=0; i<N-1; i++){
    scanf("%d", &B[i]);
  }
	int ans = 0;
	A[0] = B[0];
	ans += A[0];
	A[N-1] = B[N-2];
	ans += A[N-1];

	for (int i=1; i<N-1; i++){
		A[i] = std::min(B[i], B[i-1]);
		ans += A[i];
	}

  printf("%d\n", ans);
  return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const int Nmax=2e5+1;
const int Nd=61;
const int INF=1e5;


int main(){
  int k,x;
  cin>>k>>x;
  if( k*500>=x){
    cout<<"Yes";
  }else{
    cout<<"No";
  }

}


Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n;
  string s;
  cin >> n >> s;
  for(int i=0; i<s.size(); i++) {
    if(s[i] + n <= 'Z') {
      s[i] += n;
    }
    else {
      s[i] += n-26;
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3624
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = []


co = 0

c = 0

for i in range(n):
    a,b = m()

    co += a*b

    c += b

c += (co-1)//9

print(c-1)







Measured memory_bytes: 45784
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  sort(a.begin(), a.end());
  int ans=0;
  for(int i=0;i<k;i++){
    ans=ans+a.at(i);
  }
  cout<<ans;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define IT iterator 
#define vi vector<int>
#define TP template<class o>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20,mod=998244353,inf=2e9;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
    char c=gc; x=0; int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
    while(isdigit(c)) x=x*10+c-'0',c=gc;
    x*=f;
}
template<class o> void qw(o x) {
    if(x/10) qw(x/10);
    putchar(x%10+'0');
}
template<class o> void pr1(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar('\n');
}

ll x,k,d;

int main() {
    qr(x); qr(k); qr(d); x=abs(x);
    ll t=min(k,x/d); 
    x -= t*d;
    k-=t;
    k&=1;
    if(k) x-=d;
    pr2(abs(x)); return 0;
}


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

int main() {

  int D; cin >> D;
  if (D == 25) cout << "Christmas" << endl;
  if (D == 24) cout << "Christmas Eve" << endl;
  if (D == 23) cout << "Christmas Eve Eve" << endl;
  if (D == 22) cout << "Christmas Eve Eve Eve" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const ll INF = +10010010000;

typedef pair<ll,ll> P;
const ll MO = 1000000007;

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

Measured memory_bytes: 3636
using System;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Numerics;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            var h = Int32.Parse(s[0]);
            var w = Int32.Parse(s[1]);
            var a = Int32.Parse(s[2]);
            var b = Int32.Parse(s[3]);
            Console.WriteLine(Solve(h, w, a, b));
        }

        const Int64 mod = 1000000007;
        static Int64 Solve(int h, int w, int a, int b)
        {
            Precal_FactAndInv(mod);

            Int64 ret = 0;
            for (int i = 0; i < h - a; i++)
            {
                var c = Nck(b + i - 1, i, mod);
                c *= Nck(w - b - 1 + h - 1 - i, h - 1 - i, mod);
                ret += c;
                ret %= mod;
            }
            return ret;
        }

        static Int64[] fact = new Int64[200005];
        static Int64[] inv = new Int64[200005];

        static void Precal_FactAndInv(Int64 mod)
        {
            fact[0] = 1;
            inv[0] = ModInv(1, mod);

            for (Int64 i = 1; i < 200005; i++)
            {
                fact[i] = (fact[i - 1] * i) % mod;
                inv[i] = ModInv(fact[i], mod);
            }
        }

        static public Int64 ExtGcd(Int64 a, Int64 b, ref Int64 x, ref Int64 y)
        {
            Int64 d = a;
            if (b != 0)
            {
                d = ExtGcd(b, a % b, ref y, ref x);
                y -= (a / b) * x;
            }
            else
            {
                x = 1;
                y = 0;
            }
            return d;
        }

        static Int64 ModInv(Int64 a, Int64 m)
        {
            Int64 x = 0, y = 0;
            ExtGcd(a, m, ref x, ref y);
            if (x < 0) x += m; //modInv is never negative
            return x;
        }

        static Int64 Nck(int n, int k, Int64 mod)
        {
            return fact[n] * inv[n - k] % mod * inv[k] % mod;
        }
    }
}

Measured memory_bytes: 5848
#include <iostream>

int main() {
	int d_max, cnt;
	std::cin >> d_max >> cnt;
  
	for(int i = 0; i < cnt; ++i) {
		int n;
      	std::cin >> n;
		d_max -= n;
    }
  
  	std::cout << (d_max >= 0 ? d_max : -1) << std::endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}
 

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    int mn = INF;
    int mx = 0;
    REP(i, n) {
        cin >> a[i];
        chmin(mn, a[i]);
        chmax(mx, a[i]);
    }
    if (mx - mn > 1) {
        cout << "No" << EOL;
        return;
    }
    if (mx - mn == 0) {
        if (a[0] == n - 1) {
            cout << "Yes" << EOL;
            return;
        }
        if (a[0] * 2 <= n) {
            cout << "Yes" << EOL;
            return;
        }
        cout << "No" << EOL;
        return;
    }
    if (mx - mn == 1) {
        int c = 0;
        REP(i, n) if (a[i] == mx) c++;
        if (n - c < mx && (mx - (n - c)) * 2 <= c) {
            cout << "Yes" << EOL;
        } else {
            cout << "No" << EOL;
        }
    }
}


Measured memory_bytes: 640
nums = [int(e) for e in input().split()]
H = [int(e) for e in input().split()]

list0 = []
for i in range(0, nums[1]):
  val = [int(e) for e in input().split()]
  if H[val[0]-1] >= H[val[1]-1]:
      list0.append(val[1])
  if H[val[0]-1] <= H[val[1]-1]:
      list0.append(val[0])

print(nums[0]-len(list(set(list0))))

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

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int A,B;cin >> A >> B;
    int ans = 0;
    ans += max(A,B);
    if(max(A,B)==A)A--;
    else B--;
    ans += max(A,B);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
while True:
    n, k = map(int, input().split())
    if n == 0 and k == 0:
        break
    
    x = 0
    a = []
    for i in range(n):
        y = int(input())
        a.append(y)
    
    s = 0
    for j in range(k):
        s += a[j]
    S = []
    S.append(s)
    
    for i in range(1, n-k+1):
        s = S[i-1] + a[i+k-1] -a[i-1]
        S.append(s)
    
    x = max(S)
    print(x)


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

int main() {
	int N, M; cin >> N >> M;
	for(int i=0; i<N; i++) {
		string s; cin >> s;
		cout << s << endl << s << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>

#include <bits/stdc++.h>
using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define TRUE (0)
#define FALSE (1)

// This value shold be close to used maximum value.  
// #define NUM_MAX 2003001

// void sort(uint32_t *num, uint32_t size);

int main()
{   
    uint32_t num[3];
    uint32_t dist;
    uint32_t time_delta;
    int32_t i;
    string str;

    cin >> num[0] >> num[1] >> num[2];

    if (num[0] == num[1]) {
        if (num[1] == num[2]){
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    } else {
        if (num[1] == num[2]){
            cout << "Yes" << endl;
        } else {
            if (num[0] == num[2]) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        }
    }

    return 0;
}

// void sort(uint32_t *num, uint32_t size) {
//     uint32_t i, j, k;
//     uint32_t sorted_num;
//     uint32_t array[NUM_MAX] = {0};

//     for (i = 1; i < size + 1; i++) {
//         array[num[i - 1]]++;
//     }

//     sorted_num = 0;

//     for (i = 0; i < NUM_MAX; i++) {
//         for (j = 0; j < array[i]; j++) {
//             num[j + sorted_num] = i;
//         }
//         sorted_num += j;
//         j = 0;
//     }

//     return;
// }


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int x,y,z,j,h;
    cin>>x>>y>>z;
    
    
    j=x*z;
    if(j<=y){cout<<z;}
    else if(j>=y)
    {

        h=y/x;
        cout<<h<<endl; }



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int m, f, r;
  while (cin >> m >> f >> r, m != -1 || f != -1 || r != -1)
  {
    if (m == -1 || f == -1 || m + f < 30)
      cout << 'F' << endl;
    else if (m + f >= 80)
      cout << 'A' << endl;
    else if (m + f >= 65)
      cout << 'B' << endl;
    else if (m + f >= 50)
      cout << 'C' << endl;
    else
    {
      if (r >= 50)
        cout << 'C' << endl;
      else
        cout << 'D' << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3100
@A=glob<>;@l=<>;printf sort{$a-$b}map{$x=@v=0;$T=$_;$v[$T&3]+=$T&3&&($x+=10,$_),$T/=4for@l;$x+=abs$A[$_]-($v[$_]||1e9)for 1..3;$x-31}1..1e5

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

int d, c[26];
int s[365][26];

int main() {
	cin >> d;
	rep(i, 26) cin >> c[i];
	rep(i, d) rep(j, 26) cin >> s[i][j];
	rep(i, d) {
		int mx = -1;
		int jmx;
		rep(j, 26) if (s[i][j] > mx) {
			mx = s[i][j];
			jmx = j;
		}
		cout << jmx+1 << endl;
	}
}


Measured memory_bytes: 3668
#include<iostream>
#include<ctime>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<climits>
#include<cstring>
#include<iomanip>
#include<string>
#include<bitset>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<algorithm>
#include<functional>
#include<chrono>
#include<random>

#define y0 asdahsdlkahsdad
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define taskname "B"
#define BeztDonkey

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

const int max4K = 1000 << 2;

static int s[max4K + 1][max4K + 1], n, k, k2, k4, x, y;
char c;

inline int Sum(int x, int y, int u, int v) { return s[u][v] - s[x - 1][v] - s[u][y - 1] + s[x - 1][y - 1]; }

int main()
{
    #ifdef BeztDonkey
    auto start = chrono::steady_clock::now();
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen(taskname".inp", "r", stdin);
    //freopen(taskname".out", "w", stdout);

    cin >> n >> k;
    k2 = k << 1; k4 = k << 2;
    while (n--)
    {
        cin >> x >> y >> c;
        if (c == 'W') y += k;
        ++s[x = x % k2 + 1][y = y % k2 + 1];
        ++s[x + k2][y];
        ++s[x][y + k2];
        ++s[x + k2][y + k2];
    }
    int ans = 0;
    for (int i = 1; i <= k4; ++i)
        for (int j = 1; j <= k4; ++j) s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
    for (int i = 1; i <= k2; ++i)
        for (int j = 1; j <= k2; ++j)
            ans = max(ans, Sum(i, j, i + k - 1, j + k - 1)
                         + Sum(i + k, j + k, i + k2 - 1, j + k2 - 1));
    cout << ans;

    #ifdef BeztDonkey
    auto end = chrono::steady_clock::now();
    cerr << "In milliseconds : "
         << chrono::duration_cast<chrono::milliseconds>(end - start).count();
    cerr << '\n' << "In seconds : "
         << chrono::duration_cast<chrono::seconds>(end - start).count() << '\n';
    #endif
    return 0;

}


Measured memory_bytes: 62848
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <stdio.h>
//end of libraries ;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , h[N] , dp[N] , k;
int main(){
fcin;
	cin >> n >> k ;
	for(int i = 1 ; i <= n ; i++){
		 cin >> h[i];
		 dp[i] = INF;
	}
	dp[1] = 0;
	// dp[2] = abs(h[2] - h[1]);
	// dp[3] = abs(h[3] - h[1]);
	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ; j <= k ; j++){
		// if(i-j>) continue;
		dp[i+j]= min (dp[i+j] , dp[i] + abs(h[i+j] - h[i]));
		// dp[i] = min(dp[i], dp[i-2] +  abs(h[i-2] - h[i]));
		}
	}
	cout << dp[n] << "\n";

}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,ans=0,h,w,a,b;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>h>>w;
	for(int i=1;i<=n;i++){
		cin>>a>>b;
		if(a>=h&&b>=w) ans++;
	} 
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
    int n, i;
    cin >> n;
    int a[n];
     
    for(i = 0; i <= n-1; i++){
        cin >> a[i];
    }
     
    for(i = 0; i <= n-2; i++){
        cout << a[n-(i+1)] << ' ';
    }
    cout << a[0] << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string.h>
#include <cmath>
#include <vector>
#include <algorithm>

#define pb push_back
#define mp make_pair

using namespace std;

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

int main(void)
{
	char f[10][10];
	int i1,i2,i3;
	int cnt;
	int xx,yy;
	int c;
	int witch,mami;
	int mamix,mamiy;
	int witchx,witchy;
	int sizee;
	int check1,check2;
	vector<int> mamiv;
	vector<int> witchv;

	for(i1=0;i1<10;i1++){
		for(i2=0;i2<10;i2++){
			if(i1==0 || i2==0 || i1==9 || i2==9) f[i1][i2]='n';
			else cin>>f[i1][i2];
		}
	}

	check1=0;
	check2=0;
	while(1){

		mami=0;
		sizee=0;
		for(i1=1;i1<=8;i1++){
			for(i2=1;i2<=8;i2++){

				if(f[i1][i2]=='.'){
					cnt=0;
					vector<int> v;
					for(i3=0;i3<8;i3++){
						xx=i2+dx[i3];
						yy=i1+dy[i3];
						c=0;
						
						while(f[yy][xx]=='x') {
							c++;
							yy+=dy[i3];
							xx+=dx[i3];
						}
						if(f[yy][xx]=='o'){
							cnt+=c;
							v.pb(i3);
						}
					}

					if(mami<cnt){
						mami=cnt;
						mamix=i2;
						mamiy=i1;
						sizee=v.size();
						mamiv.clear();
						mamiv.reserve(v.size());//先にメモリ領域を確保する。
						copy(v.begin(), v.end(), back_inserter(mamiv));
					}
				}
			}
		}
		if(mami!=0){ 



			for(i1=0;i1<sizee;i1++){
				yy=mamiy;
				xx=mamix;
				f[yy][xx]='x';
				while(f[yy][xx]=='x'){
					f[yy][xx]='o';
					yy+=dy[mamiv[i1]];
					xx+=dx[mamiv[i1]];

				}
			}
			check1=0;
		}
		else check1=1;

		if((check1+check2)==2) break;



		witch=0;
		sizee=0;
		for(i1=8;i1>=1;i1--){
			for(i2=8;i2>=1;i2--){

				if(f[i1][i2]=='.'){
					cnt=0;
					vector<int> v;
					for(i3=0;i3<8;i3++){
						xx=i2+dx[i3];
						yy=i1+dy[i3];
						c=0;
						
						while(f[yy][xx]=='o') {
							c++;
							yy+=dy[i3];
							xx+=dx[i3];
						}
						if(f[yy][xx]=='x'){
							cnt+=c;
							v.pb(i3);
						}
						//cout<<i1<<" "<<i2<<" "<<c<<" "<<witchy<<endl;
					}

					if(witch<cnt){
						witch=cnt;
						witchx=i2;
						witchy=i1;
						sizee=v.size();
						witchv.clear();
						witchv.reserve(v.size());//先にメモリ領域を確保する。
						copy(v.begin(), v.end(), back_inserter(witchv));
					}
				}
			}
		}

		if(witch!=0){
			for(i1=0;i1<sizee;i1++){
				yy=witchy;
				xx=witchx;
				f[yy][xx]='o';
				while(f[yy][xx]=='o'){
					f[yy][xx]='x';
					yy+=dy[witchv[i1]];
					xx+=dx[witchv[i1]];
				}
			}
			check2=0;
		}
		else check2=1;

		if((check1+check2)==2) break;	
	}
		
	for(i1=1;i1<9;i1++){
		for(i2=1;i2<9;i2++){
			cout<<f[i1][i2];
		}
		cout<<endl;
	}

	

	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, t;
  cin >> n >> t;
  
  vector<vector<int>> a(n, vector<int>(2));
  for(int i = 0; i < n; i++) cin >> a.at(i).at(0) >> a.at(i).at(1);
  
  sort(a.begin(), a.end());
  
  vector<vector<int>> dp(n + 1, vector<int>(6005));
  
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= 6004; j++){
      if(j >= t){
        dp.at(i + 1).at(j) = max(dp.at(i).at(j), dp.at(i + 1).at(j));
      //  cout << 1 << endl;
      }
      else{
        dp.at(i + 1).at(j) = max(dp.at(i).at(j), dp.at(i + 1).at(j));
        dp.at(i + 1).at(j + a.at(i).at(0)) = max(dp.at(i + 1).at(j + a.at(i).at(0)), dp.at(i).at(j) + a.at(i).at(1));
       // cout << 2 << endl;
      }
    }
  }
  
  int ans = 0;
  for(int i = 6004; i >= 0; i--) ans = max(ans, dp.at(n).at(i));
  
  cout << ans << "\n";
}

Measured memory_bytes: 71040
import sys
import math
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        a,b=map(int, input().split())
        for i in range(13,1250):
            if math.floor(i*0.08)==a and math.floor(i*0.1)==b:
                return i
        return -1
    print(main())
resolve()

Measured memory_bytes: 3060
def main():
    N, M, Q = list(map(int, input().split(' ')))
    x = [[0 for _ in range(N)] for _ in range(N)]
    for _ in range(M):
        left, right = list(map(int, input().split(' ')))
        x[left - 1][right - 1] += 1
    for i in range(N):
        for j in range(1, N):
            x[i][j] += x[i][j - 1]
    for j in range(N):
        for i in range(N - 2, -1, -1):
            x[i][j] += x[i + 1][j]
    queries = [list(map(int, input().split(' '))) for _ in range(Q)]
    for q in queries:
        print(x[q[0] - 1][q[1] - 1])


if __name__ == '__main__':
    main()

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

int main()
{
    int N;
    int c = 0;
    int min;
    cin >> N;
    vector<int> P(N + 1);
    for (int i = 1; i <= N; i++)
        cin >> P[i];
    //bool flg = false;
    min = P[1];
    for (int i = 1; i <= N; i++)
    {
        if (P[i] <= min)
        {
            min = P[i];
            c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
     String[] nyu=sc.nextLine().split(" ");

   //  String nyu=sc.nextLine();
int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]+nyu[2]);
//int C=Integer.parseInt(nyu[2]);
//int D=Integer.parseInt(nyu[3]);


//StringBuffer sb = new StringBuffer(nyu);
//		String dst = sb.reverse().toString();

//     String nyu2=sc.nextLine();
//int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(nyu){
case "H H":
System.out.println("H") ;
break;

case "D D":
System.out.println("H") ;
break;

case "H D":
System.out.println("D") ;
break;

case "D H":
System.out.println("D") ;
break;


default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:nyu){
//if(tem.equals("1"))res++;
//}
//int res=0;
//for(int i=0;i<300;i++){
//if(num[i]==1)res=i;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);



//if(D<1200){
//double res=Math.ceil((AB)/2);

//System.out.println("ABC");
//}else if(B<A){
//System.out.println("Alice");

//}else{
System.out.println(A+B);

//}




	}
}

Measured memory_bytes: 22868
//itp1_2_c

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
 vector<int> A(3,0);
 for(int i=0;i<3;i++){
  cin>>A[i];
 }
 sort(A.begin(),A.end());
 cout<<A[0]<<" "<<A[1]<<" "<<A[2]<<endl;
 return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int to_i(string s){
  int k=1,res=0;
  for(int i=s.size()-1;i>=0;i--){
    res+=(s[i]-'0')*k;
    k*=10;
  }
}
int main(){
  int n,k;
  while(cin>>n>>k&&n&&k){
    string a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    set<string> f;
    int ans=0;
    for(int i=0;i<1<<n;i++){
      int c=0;
      vector<string> t;
      for(int j=0;j<n;j++)if((i>>j)&1){
          c++;t.PB(a[j]);
      }
      if(c!=k)continue;
      sort(t.begin(),t.end());
      do{
        string res="";
        for(int j=0;j<t.size();j++)res+=t[j];
        if(f.count(res)==0){
          ans++;
          f.insert(res);
        }
      }while(next_permutation(t.begin(),t.end()));
    }
    cout<<f.size()<<endl;
  }
}

Measured memory_bytes: 1460
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

ll dp[55][2];
void solve()
{
    int n,P;
    scanf("%d%d", &n, &P);

    dp[0][0]=1;
    int i;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        if(tmp%2) {
            dp[i+1][0]+=dp[i][1]+dp[i][0];
            dp[i+1][1]+=dp[i][0]+dp[i][1];
        }
        else {
            dp[i+1][0]+=dp[i][0]*2;
            dp[i+1][1]+=dp[i][1]*2;
        }
    }
    printf("%lld\n", dp[n][P]);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= i;
    }
    sort(a.begin(), a.end());
    auto median = a[n / 2];
    auto median2 = a[n / 2 - 1];
    ll sum1 = 0;
    for (auto v : a)
        sum1 += abs(v - median);
    cerr << sum1 << median << endl;
    
    ll sum2 = 0;
    for (auto v : a)
        sum2 += abs(v - median2);
    cerr << sum2 << median2 << endl;
    
    cout << min(sum1, sum2) << endl;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<(n);++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define per(i,a,b) for(lli i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b))) 
#define sz(x) (lli)(x).size()
#define endl '\n'
typedef long long lli;        typedef long double ld;
typedef pair<lli,lli> ii;     typedef vector<lli> vi;
typedef vector<ii> vii;       typedef vector<vi> graph;
long long MOD=1000000007;     long double EPS=1e-9;
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
lli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}

void pre(){

}

void solve(){
    lli a,b;cin>>a>>b;
    cout<<(a^b)<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //cout<<fixed<<setprecision(15);
    //clock_t begin = clock();
    pre();lli _t=1;//cin>>_t;
    for(lli i=1;i<=_t;i++){
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    // clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}

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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define loop while(true)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

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

int main(){
  int h, w, k;
  char cake[310][310] = {};
  int find = -1;
  scanf("%d %d %d", &h, &w, &k);
  rep(i, h){
    scanf("%s", cake[i]);
    if(find == -1){
      char* p = strrchr(cake[i], (int)'#');
      if(p != NULL) find = i;
    }
  }
  
  int ans[310][310] = {}, num = 1;
  rep2(i, find, h){
    char* p = strrchr(cake[i], (int)'#');
    if(p == NULL){
      memcpy(ans[i], ans[i - 1], sizeof(ans[i - 1]));
    }
    else{
      bool b = false;
      rep(j, w){
        if(j != 0){
          if(cake[i][j] == '#'){
            if(b) num++;
            else b = true;
          }
        }
        else{
          if(cake[i][j] == '#'){
            b = true;
          }
        }
        ans[i][j] = num;
      }
      num++;
    }
  }
  
  for(int i = find; i > 0; i--){
    memcpy(ans[i - 1], ans[i], sizeof(ans[i]));
  }
  
  rep(i, h){
    rep(j, w){
      if(j == 0) printf("%d", ans[i][j]);
      else printf(" %d", ans[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int N = in.nextInt();
			int[] a = in.nextIntArray(N);

			int[] dp = new int[N];
			Arrays.fill(dp, INF);

			for (int i = 0; i < N; i++) {
				dp[lowerBound(dp, a[i])] = a[i];
			}
			out.println(lowerBound(dp, INF));


		}

		/**
		 * 指定された要素以上の値が現れる最初の位置のイテレータを取得する
		 * */
		public static int lowerBound(int[] a, int obj) {
			int l = 0,r = a.length - 1;
			while (r - l >= 0) {
				int c = (l + r) / 2;
				if (obj <= a[c]) {
					r = c - 1;
				} else {
					l = c + 1;
				}
			}
			return l;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}



Measured memory_bytes: 43352