akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=list(map(int,input().split()))
b=0
ans=1
for i in range(n-1):
  if b==0 and a[i]!=a[i+1]:
    if a[i]<a[i+1]:b=1
    else:b=-1
  elif(a[i]<a[i+1] and b==-1)or(a[i]>a[i+1] and b==1):
    ans+=1
    b=0
print(ans)

Measured memory_bytes: 14228
a,b,k = map(int,input().split())
ans = []

if (b-a)//2 >= k:
	for i in range(a,a+k):
		ans.append(i)
	for i in range(b-k+1,b+1):
		ans.append(i)
	ans.sort()
	for i in range(len(ans)):
		print(ans[i])
else:
	for i in range(a,b+1):
		print(i)

Measured memory_bytes: 3060
x,y = gets.chomp.split.map(&:to_i)
mod = 1000000007
ans = 0
MAX = 1000010
@fac = Array.new(MAX,0)
@finv = Array.new(MAX,0)
@inv = Array.new(MAX,0)

def com_init(mod)
  @fac[0] = @fac[1] = 1
  @finv[0] = @finv[1] = 1
  @inv[1] = 1
  (2..MAX-1).each do |i|
    @fac[i] = @fac[i-1]*i % mod
    @inv[i] = mod - @inv[mod % i] * (mod / i) % mod
    @finv[i] = @finv[i - 1] * @inv[i] % mod 
  end
end

def com(n,k,mod)
  if n < k
    return 0
  end
  if n < 0 || k < 0
    return 0
  end
  return @fac[n] * (@finv[k] * @finv[n-k] % mod) % mod
end

com_init(mod)

if (-x + 2*y) % 3 == 0 && (2*x - y) % 3 == 0
  r_n = (-x + 2*y)/3
  u_n = (2*x - y)/3
  sum = r_n + u_n
  if r_n > u_n
    ans = com(sum,u_n,mod)
  else
    ans = com(sum,r_n,mod)
  end
end

puts ans

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

using namespace std;

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

int main() {
	int N;	
	while(cin >> N) {
		if(N == 0) break;
		vector<int> x(N, 0);			
		vector<int> y(N, 0);			
			
		int n, d;	
		for(int i = 1; i < N; ++i) {
			cin >> n >> d;	
			x[i] = x[n] + dx[d];		
			y[i] = y[n] + dy[d];		
		}
			
		cout << *max_element(begin(x), end(x)) - *min_element(begin(x), end(x)) + 1 << " ";
		cout << *max_element(begin(y), end(y)) - *min_element(begin(y), end(y)) + 1 << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  
  sort(A.rbegin(), A.rend());
  
  ll cnt = 0, l = 0, s = 0;
  for (int i = 0; i < N - 1; ++i) {
    if (A[i] == A[i + 1]) {
      if (cnt == 0) {
        l = A[i];
        ++cnt;
        ++i;
      } else if (cnt == 1) {
        s = A[i];
        break;
      }
    }
  }
  cout << l * s << endl;  
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

struct P{
    ll x, y;
    P(ll x, ll y): x(x), y(y) {};
};

vector<ll> dx = {-1, 0, 1, 0};
vector<ll> dy = {0, -1, 0, 1};

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

    ll H, W, K;
    cin >> H >> W >> K;
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--, y1--, x2--, y2--;

    vector<string> c(H);
    REP(i, H) cin >> c[i];

    const ll INF = (1ll<<60);
    vector<vector<ll>> dist(H, vector<ll>(W, INF));
    
    queue<P> qu;

    qu.emplace(x1, y1);
    dist[x1][y1] = 0;

    while(!qu.empty()){
        P p = qu.front();qu.pop();
        REP(dir, 4){
            for(int k=1;k<=K;k++){
                ll nx = p.x + k * dx[dir];
                ll ny = p.y + k * dy[dir];

                if(nx<0 or nx>H-1 or ny<0 or ny>W-1) break;
                if(c[nx][ny] == '@') break;
                if(dist[nx][ny] <= dist[p.x][p.y]) break;
                if(dist[nx][ny] != INF) continue;

                dist[nx][ny] = dist[p.x][p.y] + 1;
                qu.emplace(nx, ny);
            }
        }
    } 

    //debug(dist, H, W);

    cout << (dist[x2][y2] == INF ? -1 : dist[x2][y2])  << endl;

    return 0;
}

Measured memory_bytes: 19804
class Node:
	def __init__(self, id):
		self.id = id
		self.parent_id = -1
		self.depth = -1
		self.children = None
	def get_type(self):
		if self.parent_id == -1:
			return 'root'
		elif self.children == None or len(self.children) == 0:
			return 'leaf'
		return 'internal node'
	def __str__(self):
		strNode = 'node ' + str(self.id) + ': '
		strNode += 'parent = ' + str(self.parent_id) + ', '
		strNode += 'depth = ' + str(self.depth) + ', '
		strNode += self.get_type() + ', ['
		if len(self.children) > 0:
			strNode += str(self.children[0])
			for i in range(1, len(self.children)):
				strNode +=  ', ' + str(self.children[i])
		strNode += ']'
		return strNode

def calc_depth(nodes):
	stack = []
	for i in range(len(nodes)):
		if nodes[i].parent_id == -1:
			nodes[i].depth = 0
			stack.append(nodes[i].id)
			break
	while len(stack) != 0:
		node = nodes[stack.pop()]
		for i in range(len(node.children)):
			child_id = node.children[i]
			nodes[child_id].depth = node.depth + 1
			stack.append(child_id)

n = int(input())
nodes = [Node(i) for i in range(n)]
for i in range(n):
	a = list(map(int, input().split()))
	id = a[0]
	m = a[1]
	children = [0] * m
	for j in range(m):
		child_id = a[2 + j]
		child = nodes[child_id]
		child.parent_id = id
		children[j] = child_id
	nodes[id].children = children

calc_depth(nodes)

for i in range(n):
	print(nodes[i])



Measured memory_bytes: 38252
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

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

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	i64 n, m;
	cin >> n >> m;
	vector<i64> x(n + 1, 0);
	FOR(i, 1, n + 1) { cin >> x[i]; }
	vector<i64> y(m + 1, 0);
	FOR(i, 1, m + 1) { cin >> y[i]; }

	i64 num_x = 0;
	FOR(i, 1, n + 1)
	{
		num_x += (i - 1) * x[i] - (n - i) * x[i];
		num_x %= MOD;
	}
	i64 num_y = 0;
	FOR(i, 1, m + 1)
	{
		num_y += (i - 1) * y[i] - (m - i) * y[i];
		num_y %= MOD;
	}
	i64 ans = (num_x * num_y) % MOD;
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
string s;
int len, last[26], a[26];
int main()
{
    cin >> s;
    len = s.length();
    for (int i = 0; i < 26; ++i) {
        for (int j = 0; j < len; ++j) {
            if ('a' + i == s[j]) {
                a[i] = max(a[i], j - last[i]);
                last[i] = j + 1;
            }
        }
        a[i] = max(a[i], len - last[i]);
    }
    for (int i = 0; i < 26; ++i) {
        len = min(len, a[i]);
    }
    cout << len << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>
#include<cassert>

using namespace std;

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

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;



int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(NULL);

 int l,r,d;cin>>l>>r>>d;
 cout << r/d - (l-1)/d <<endl;


 return 0;
}


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

int main() {
  int F, M =  0;
  int N;
  cin >> N;
  int Q = N;

  for(int i = 0; i < 9; i++){
    M = Q % 10;
    F += M;
    Q /= 10;
  }
  
  if(N % F == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

int main()
{
    string arr,frr;
    int n;cin>>n;
    cin>>arr>>frr;
    int m=max(arr.size(),frr.size());

    for(int i=0;i<m;i++)
    {
        if(arr.size()>i)cout<<arr[i];
         if(frr.size()>i)cout<<frr[i];
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	int M;

	class Shop {
		long A;
		long B;

		public Shop(long a, long b) {
			super();
			A = a;
			B = b;
		}
	}

	ArrayList<Shop> Shops = new ArrayList<Shop>();

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		M = Integer.parseInt(strArr[1]);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		String[] strArr = str.split(" ");
		long a = Long.parseLong(strArr[0]);
		long b = Long.parseLong(strArr[1]);
		Shops.add(new Shop(a, b));
		cnt++;
	}

	public void solve() {
		Collections.sort(Shops, new Comparator<Shop>() {
			@Override
			public int compare(Shop a, Shop b) {
				long d = a.A - b.A;
				if (d == 0)
					return 0;
				else if (d > 0)
					return 1;
				else
					return -1;
			}
		});
		long m = M;
		long ans = 0;
		for (Shop s : Shops) {
			// System.out.println(s.A + " " + s.B);
			int d;
			if (m > s.B) {
				ans += s.A * s.B;
				m -= s.B;
			} else {
				ans += s.A * m;
				m = 0;
			}
			if (m <= 0)
				break;
		}
		System.out.println(ans);
	}
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


template<typename T>
class Perm {
public:
    ll n;
    vector<T> p;
    vector<vector<T>> p_v;
    Perm(ll n):n(n){}

    void build() {
        vector<T> v(n);
        iota(v.begin(), v.end(), 1);
        do {
            ll num = 0;
            for(ll i=0; i<v.size(); i++) num += pow(10, v.size()-(i+1)) * v[i];
            p.push_back(num);
        }while(next_permutation(v.begin(), v.end()));
    }

    void build_v(){
        ll size = 1;
        for(ll i=0; i<=n; i++) size *= i;
        p_v.assign(size, vector<T>(size));
        vector<T> v(n);
        iota(v.begin(), v.end(), 1);
        ll ind = 0;
        do {
            for(auto const e : v) p_v[ind].push_back(e);
            ind++;
        }while(next_permutation(v.begin(), v.end()));
    }
};


class CLowElements {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        vector<ll> p(n);
        rep(i, n){
            in >> p[i];
        }

        int res = 0;
        ll mi = p[0];
        rep(i, n){
            if(mi >= p[i])res++;
            chmin(mi, p[i]);
        }

        out << res << endl;
	}
};


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


Measured memory_bytes: 1792
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

vll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    rep(ni,N){
        cin >> ltmp;
        A.push_back(ltmp);
    }

    ll cnt = 0;
    rep(ni,N){
        if((ni+1)%2==1 && A[ni]%2==1) cnt++;
    }
    cout << cnt << endl;
    

}

Measured memory_bytes: 3616
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#define M 1000000007
typedef long long int ll;
#define INF 1000000000000000
int main()
{
    ll n,i;
    cin>>n;
    ll a[n],b[n],c[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    ll dp[n+1][3];
    memset(dp,0,sizeof(dp));
    dp[1][0]=a[0];
    dp[1][1]=b[0];
    dp[1][2]=c[0];
    for(i=2;i<=n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i-1];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i-1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i-1];
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));

}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define FOR(i,n) for(size_t i=0;i<(n);i++)
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)

#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))

#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

#define order_sl(neq_sl) [](const &auto s, const &auto l){return neq_sl}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}



int main() {
  int n,k;
  cin>>n>>k;
  nvec(int,v,n);
  long mx=0;
  for (size_t i = 0; i <= k && i <= n; i++) {
    for (size_t j = 0; j <= i; j++) {
      vector<long> w;
      w.insert(w.end(), v.begin(), v.begin()+j);
      w.insert(w.end(), v.end()-i+j, v.end());
      sort(all(w));
      mx=max(mx,accumulate(min(w.begin()+k-i,upper_bound(all(w),0)),w.end(),0l));
    }
  }
  cout<<mx;
}

Measured memory_bytes: 256
many, A, B, C = map(int, input().split())
bamboos = [int(input()) for i in range(many)]

# point: 訳が分からなくなるものは自分でルールづけをする
# 合成魔法を全て最初に行う、というルールづけ

# 解法: DFS or 4進数(4patternsで2の累乗だからできる)
# PS: DFS(深さ優先探索), BFS(幅優先探索)

infinity = 1e10

def dfs(depth, a, b, c):
    if depth == many:
        # 謎の場合分け
        if min(a, b, c) > 0:
            # 竹が何もない状態でも各竹に+10がかかっていることから-30する必要がある。
            # また、+10が一個はないとベースとなる竹がないことになるので
            # a,b,c = 0はコストを無限にすることで避ける。
            return abs(a-A) + abs(b-B) + abs(c-C) - 30
        else:
            return infinity
    else:
        ret0 = dfs(depth+1, a, b, c)
        ret1 = dfs(depth+1, a+bamboos[depth], b, c) + 10
        ret2 = dfs(depth+1, a, b+bamboos[depth], c) + 10
        ret3 = dfs(depth+1, a, b, c+bamboos[depth]) + 10
        return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
open System
open System.Collections.Generic

[<AutoOpen>]
module FastIO =
    let reader = new IO.StreamReader(new IO.BufferedStream(Console.OpenStandardInput()))
    let inline read f = reader.ReadLine() |> f
    let inline reada f = reader.ReadLine().Split() |> Array.map f
    let inline readChars() = read string |> Seq.toArray
    let inline readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let inline write (s: string) = writer.Write s
    let inline writeln (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> writeln

    let inline ioDispose() =
        reader.Dispose()
        writer.Dispose()

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

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

let main() =
    let k = read int
    let k = k - 1
    let ls = [| 1; 1; 1; 2; 1; 2; 1; 5; 2; 2; 1; 5; 1; 2; 1; 14; 1; 5; 1; 5; 2; 2; 1; 15; 2; 2; 5; 4; 1; 4; 1; 51 |]
    puts ls.[k]
    ()

// -----------------------------------------------------------------------------------------------------
main()
ioDispose()


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

string s;
bool flag[100000];
pair<int,int> dist[100000];
int ans[100000+10];

pair<int,int> goal(int cur){
	//cout<<cur<<endl;
	if(flag[cur]) return dist[cur];
	
	if(s[cur]=='R'){
		if(cur+1 == s.length()){
			flag[cur]=true;
			dist[cur].first=s.length()+2;
			dist[cur].second=s.length()+2;
		}
		else if(s[cur+1]=='L'){
			flag[cur]=true;
			dist[cur].first=cur;
			dist[cur].second=cur+1;
		}
		else{
			pair<int,int> tmp=goal(cur+1);
			flag[cur]=true;
			dist[cur].second=tmp.first;
			dist[cur].first=tmp.second;
		}
	}

	if(s[cur]=='L'){
		if(cur-1 == -1){
			flag[cur]=true;
			dist[cur].first=s.length()+2;
			dist[cur].second=s.length()+2;
		}
		else if(s[cur-1]=='R'){
			flag[cur]=true;
			dist[cur].first=cur;
			dist[cur].second=cur-1;
		}
		else{
			pair<int,int> tmp=goal(cur-1);
			flag[cur]=true;
			dist[cur].second=tmp.first;
			dist[cur].first=tmp.second;
		}
	}
	return dist[cur];
}

int main(void){
	cin>>s;

	rep(i,s.length()){
		flag[i]=false;
		dist[i].first=-1;
		dist[i].second=-1;
		ans[i]=0;
	}


	rep(i,s.length()){
		pair<int,int> tmp;
		tmp=goal(i);
		ans[tmp.first]++;
	}

	rep(i,s.length())cout<<ans[i]<<" ";
	cout<<endl;
	return 0;
}


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

int main(){
    string s;
    int n1=0,n2=0;
    cin>>s;
    
    for(int i=0;i<s.length();i++){
        if(s[i]=='0')   n1++;
        else    n2++;
    }
    cout<<(min(n1,n2))*2<<endl;
    
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	map<string, int> m;
	for (int ii = 0; ii < N; ++ii){
		string tmp;
		cin >> tmp;
		m[tmp]++;
	}

	int ans = m.size();

	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 19180
N = int(input())
a = [int(input()) for _ in range(N)]
nxt = a[0]-1
cnt = 1
if a[0]-1 == 1:
  print(cnt)
  exit()

for i in range(1, N+1):
  if a[nxt] == 2:
    cnt += 1
    print(cnt)
    exit()
  else:
    nxt = a[nxt] - 1
    cnt += 1
else:    
  print(-1)

Measured memory_bytes: 7084
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;






int main() {

    int n, m, x;
    cin >> n >> m >> x;
    int a[m];
    rep(i,m) cin >> a[i];

    int cost[n+1];
    rep(i,n+1) cost[i] = 0;
    rep(i,m) cost[a[i]] = 1;

    int to_l = 0;
    for (int i = x; 0 <= i; --i) {
        to_l += cost[i];
    }
    int to_r = 0;
    for (int i = x; i <= n; ++i) {
        to_r += cost[i];
    }


    out(min(to_l, to_r));



    return 0;
}




//              g++ -std=c++1z






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

using namespace std;
using LL = long long;
using P = pair<int,int>;
const int kind=26;
const int INF=1e9;

int main(){
	int D;
	cin >> D;
	vector<int> c(kind);
	rep(i,kind) cin >> c[i];
	int c_sum=0;
	rep(i,kind) c_sum+=c[i];
	vector<vector<int>> s(D,vector<int>(kind));
	rep(i,D){
		rep(j,kind) cin >> s[i][j];
	}
	vector<int> t(D), max_score(D,-INF);
	vector<int> last(kind);
	int ans=0, dec=0;
	for(int day=1; day<=D; day++){
		int k=-1;
		dec+=c_sum;
		rep(i,kind){
			int res=s[day-1][i];
			res-=dec;
			res+=c[i]*(day-last[i]);
			if(res>max_score[day-1]){
				max_score[day-1]=res;
				k=i;
			}
		}
		dec-=c[k]*last[k];
		last[k]=day;
		t[day-1]=k+1;
	}
	rep(i,D) cout << t[i] << endl;

	return 0;
}

Measured memory_bytes: 3684
N, M, Q = [int(_) for _ in input().split()]
LR = [[int(_) for _ in input().split()] for i in range(M)]
PQ = [[int(_) for _ in input().split()] for i in range(Q)]

from collections import defaultdict
from itertools import accumulate

C = [[0]*(N+1) for i in range(N+2)]

for l, r in LR:
    C[1][r] += 1
    C[l + 1][r] -= 1

#print(C)

T = [list(accumulate(row)) for row in C]
T = [list(accumulate(row)) for row in zip(*T)]

#print(T)

for p, q in PQ:
    print(T[q][p])


Measured memory_bytes: 62412
#include<iostream>

using namespace std;


int main(){
    long long n,d;
    cin>>n>>d;
    long long x,y;
    int cnt=0;
    for (int i=0;i<n;i++){
        cin>>x>>y;
        if(x*x+y*y<=d*d) cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <unordered_map>

using namespace std;

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

    unordered_map<int, int> m;
    while (n--) {
        int a;
        cin >> a;
        ++m[a];
    }
    int ans = 0;
    for (auto& p : m) {
        if (p.second % 2 != 0) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }

    void solve(){  
        int n;
        cin>>n;
        vector<ll>a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        vector<ll>pref(n+1);
        for(int i=n-1;i>=0;i--){
            pref[i]=pref[i+1]+a[i];
        }
        ll ans=0;
        for(int i=0;i<n;i++){
            ans=add(ans,mul(a[i],pref[i+1]));
        }
        cout<<ans;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }


Measured memory_bytes: 6364
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
inline int getint(){
    char c=getchar();int x=0;bool p=0;
    while((c>'9'||c<'0')&&c!='-')c=getchar();
    if(c=='-')p=1,c=getchar();
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    if(p)x=-x;return x;
}
int main(){
	int n=getint(),k=getint();
	if(n*(n-1)/2-k<n-1){puts("-1");return 0;}
	cout<<n*(n-1)/2-k<<endl;
	int x=0;
	for(int i=1;i<n;++i)
	for(int j=i+1;j<=n;++j){
		printf("%d %d\n",i,j);
		++x;
		if(x==n*(n-1)/2-k)return 0;
	}
	return 0;
}

Measured memory_bytes: 256
//ITNOA
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
typedef long long ll;
const ll INF=1e9+10,MAX=3e5+1e4,MOD=1e9+7,MAXL=25;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii;
void OUT(long double o,int x){
	 cout<<fixed<<setprecision(x)<<o;
	 return;
}
ll a[MAX];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,x,y;
	cin>>n>>x>>y;
	if(x+y>n+1)
		return cout<<-1,0;
	if(x*y<n)
		return cout<<-1,0;
	ll p=0,cnt=0;
	while(p<n){
		ll sz=min(x,n-p);
		if(n-sz-p<y-cnt-1){
			//n-sz=y-cnt-1
			sz=cnt+1-y+n-p;
		}
		for(int i=1;i<=sz;i++)
			a[n-sz-p+i]=p+i;
		p+=sz;
		cnt++;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<" ";
	return 0;
}


Measured memory_bytes: 4608
X,N=map(int, input().split())
A = list(map(int, input().split()))

def p(i):
    return i+1
def m(i):
    return i-1

if not X in A:
    print(X)
else:
    pl=p(X)
    mi=m(X)
    for _ in range(100):
        if not mi in A:
            print(mi)
            break
        else:
            mi = m(mi)
        if not pl in A:
            print(pl)
            break
        else:
            pl = p(pl)

Measured memory_bytes: 9148
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"
#define pi              acos(-1)
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MAX             100005
#define MOD             1000000007

typedef long long ll;


int main()
{
    FastRead

    ll n,a,b;

    cin>>a>>b;

    cout<<(a-b)+1;
}


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

using namespace std;


void solve() {
    int n; cin >> n;
    string s; cin >> s;
    vector<int> pre(n+1), suf(n+1);
    pre[0] = 0;
    for (int i = 1; i <= n; i++) {
        pre[i] += pre[i-1] + (s[i-1]=='W');
    }
    suf[n] = 0;
    for (int i = n-1; i >= 0; i--) {
        suf[i] += suf[i+1] + (s[i]=='E');
    }
    int res = n;
    for (int i = 0; i < n; i++) {
        int tmp = pre[i] + suf[i+1];
        res = min(res, tmp);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 2964
import 'dart:io';

void main() {
  List abc = stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();

  bool yes = false;
  int n = 0;
  for (int i = 1; i <= 10000; i++) {
    n = n + abc[0];
    if (n % abc[1] == abc[2]) {
      yes = true;

      break;
    }
  }
  (yes == true) ? print("YES") : print("NO");
}

Measured memory_bytes: 13160
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#define INF (2000000000)
#define MOD (1000000007)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;
typedef vector<long>::iterator VL;
typedef vector<long>::iterator VLI;
typedef pair<int, int> P;


int dp[11][156];

int main()
{
	int n, k, s;
	while (scanf("%d %d %d", &n, &k, &s), n + k + s){
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1;
		
		for (int i = 1; i <= n; i++){
			for (int j = k; j > 0; j--){
				for (int l = i; l <= s; l++){
					dp[j][l] += dp[j - 1][l - i];
				}
			}
		}
		
		printf("%d\n", dp[k][s]);
	}
	
	return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>

int main(void)
{ int circumference,num;
 scanf("%d%d", &circumference, &num);
int number[num];
for(size_t i=0;i<num;++i){
scanf("%d",&number[i]);
}
int last = circumference-number[num-1]+number[0];

int b[num-1];
for (size_t i=0; i<num-1; ++i){

 b[i]=number[i+1]-number[i];
 }

 int largest=0;
 for (size_t i=0; i<num-1; ++i){
  if (b[i]>largest)
     largest=b[i];}
  if (last>largest)
   printf("%d", circumference-last);
  else
   printf("%d", circumference-largest);

return 0;
}


Measured memory_bytes: 1664
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[8]={ 1,0,-1,0,1,1,-1,-1 };
int dy[8]={ 0,1,0,-1,1,-1,1,-1 };

int N, T;
int A[100000];

signed main(){
	cin >> N >> T;
	rep(i, N) cin >> A[i];

	int m = INT_MAX;
	int M = 0;
	rep(i, N){
		m = min(m, A[i]);
		M = max(M, A[i]-m);
	}

	m = INT_MAX;
	int ans1 = 0;
	rep(i, N){
		m = min(m, A[i]);
		if(M == A[i]-m) ans1++;
	}

	m = INT_MIN;
	int ans2 = 0;
	rep(i, N){
		m = max(m, A[N-1-i]);
		if(M == m-A[N-1-i]) ans2++;
	}

	cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 640
S = input()
N = len(S)

ans1 = "".join(["1" if i%2 == 0 else "0" for i in range(N)])
ans2 = "".join(["0" if i%2 == 0 else "1" for i in range(N)])

print(min(bin(int(S, 2)^int(ans1, 2)).count("1"), bin(int(S, 2)^int(ans2, 2)).count("1")))

Measured memory_bytes: 10132
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include<map>
#include <utility>
#include <math.h>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[100010] = {}, f[100010];
double syo = 0, su = 0;
long long   mur = 0, kmr = 0, yju = 0, counto[5003], counto1[5003];
char fir, sec = 'z', mado[52][52], homu[52][52];
string rik, mrsm[55], tok[25003];
bool mazi[110], gi[110], zi, manji;
pair<int, int>n[110];
vector<int> aa[50] = {}, cc;
vector<char> bb, dd;
map<char, int>zis, uuu;
int gcd(int a, int b) {
	int d;
	if (a > b) {
		int t = b;
		b = a;
		a = t;
	}
	while ((d = b % a) != 0) {
		b = a;
		a = d;
	}
	return a;
}
int main()
{
	cin >> rik;
	long long ans = 0;
	for (int bit = 0; bit < (1 << ((int)rik.size() -
		1)); bit++) {
		long long num = rik[0] - '0';
		long long sum = 0;
		for (int i = 0; i < (int)rik.size() - 1; i++) {
			if (bit&(1 << i)) {
				sum += num;
				num = 0;
			}
			num = num * 10 + rik[i + 1] - '0';
		}
		sum += num;
		ans += sum;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// Nの入力
		int N = sc.nextInt();
		
		// 九九の結果を格納したSetを作成
		Set<Integer> kuku = new TreeSet<>();
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				kuku.add(i * j);
			}
		}
		
		// 結果の出力
		System.out.println(kuku.contains(N)? "Yes" : "No");
		
		sc.close();
	}

}


Measured memory_bytes: 23892
import numpy as np
H, W = map(int, input().split())
L = []
for i in range(H):
  L.append(list(map(int, input().split())))
C = np.array(L) % 2
A = []
for i in range(H):
  for j2 in range(W):
    if i % 2 == 1:
      j = W-1-j2
    else:
      j = j2
    if C[i][j] == 1:
      C[i][j] = 0
      if i % 2 == 0:
        if j == W-1:
          if i == H-1:break
          C[i+1][j] = not C[i+1][j]
          A.append([i, j, i+1, j])
        else:
          C[i][j+1] = not C[i][j+1]
          A.append([i, j, i, j+1])
      else:
        if j == 0:
          if i == H-1:break
          C[i+1][j] = not C[i+1][j]
          A.append([i, j, i+1, j])
        else:
          C[i][j-1] = not C[i][j-1]
          A.append([i, j, i, j-1])
print (len(A))
for i in range(len(A)):
  print (A[i][0]+1, A[i][1]+1, A[i][2]+1, A[i][3]+1)

Measured memory_bytes: 37696
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
const int N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n;
cin>>n;
vector<int> v;
vector<int>::iterator it;
rep(i,0,n)
{
	int x;
	cin>>x;
	 it=upper_bound(v.begin(),v.end(),x,greater<>());
	if(it==v.end()) v.push_back(x);
	else *it = x;
}
cout<<v.size();
}







Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  int N,D;
  cin>>N>>D;
  int X[10][10];
  for (int i=1; i<=N; i++){
    for (int j=1; j<=D; j++){
      cin>>X[i][j];}}
  int counter=0;
  for (int i=1; i<N; i++){
    for (int j=i+1; j<=N; j++){
      int distance=0;
     
      for(int k=1; k<=D; k++) distance+=pow((X[i][k]-X[j][k]),2);
       bool t=false;
        for (int l=1; l<=1000; l++){
          if (distance==pow(l,2)) t=true;
        }
      if (t) counter++;}}
  cout<<counter<<endl;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
#define X real()
#define Y imag()
void pin(pt& p){
	ld x,y; 
	cin>>x>>y; 
	p={x,y};
}
ostream& operator<<(ostream& os, pt p){
	return os<<p.X<<" "<<p.Y<<endl;
} 
ld dot(pt p,pt q){
	return (p.X*q.X + p.Y*q.Y);
}
pt solve(pt p,pt q,pt x){
	ld l = dot((q-p),(x-p))/abs(q-p);
	pt on = l*(q-p)/abs(q-p);
	return p+on;
}
int main (){
	cout<<fixed<<setprecision(12);
	pt p,q,x;
	pin(p);
	pin(q);
	int t; 
	cin>>t;
	while(t--){
		pin(x);
		cout<<solve(p,q,x); 
	}
	return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    vector<int> A(N);
    Graph x(N), y(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        for(int j = 0; j < A[i]; j++) {
            int X, Y; cin >> X >> Y;
            X--;
            x[i].push_back(X);
            y[i].push_back(Y);
        }
    }
    int ans = 0;
    for(int b = 0; b < (1 << 15); b++) {
        if(b == (1 << N)) break;
        bitset<15> bit(b);
        bool judge = true;
        for(int u = 0; u < N; u++) {
            for(int v = 0; v < A[u]; v++) {
                if(bit.test(u)) {
                    if(bit.test(x[u][v])) {
                        if(!y[u][v]) judge = false;
                    }
                    else {
                        if(y[u][v]) judge = false;
                    }
                }                
            }
        }
        if(judge) ans = max(ans, (int)bit.count());
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  long long N;
  cin >> N;
  int ans = 11;
  for (long long i = 1; i * i <= N; ++i)
    if (N % i == 0)
      ans = min(ans, (int)max(to_string(i).size(), to_string(N / i).size()));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int n, a, numCnt[100000] = {0};
	scanf("%d", &n);
	int eat = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		numCnt[a - 1]++;
	}
	for (int i = 0; i < 100000; i++) {
		if (numCnt[i] >= 2) {
			eat += numCnt[i] - 1;
		}
	}
	printf("%d\n", n - ((eat + 1) / 2 * 2));
	return 0;
}

Measured memory_bytes: 512
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(D)]

ans = 10 ** 9
for msk in range(1 << D):
    tmp = 0
    cnt = 0
    for i in range(D):
        if msk >> i & 1:
            p, c = pc[i]
            tmp += p * (i + 1) * 100 + c
            cnt += p

    for i in range(D - 1, -1, -1):
        if tmp >= G:
            break
        if (msk >> i & 1) ^ 1:
            p, c = pc[i]
            k = min(p, -(-(G - tmp) // ((i + 1) * 100)))
            cnt += k
            tmp += (i + 1) * 100 * k

    ans = min(ans, cnt)

print(ans)

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define SWAP(x, y) do { char z = y; y = x; x = z; } while (0)
int main(void)
{
    int h,m,H,M,k;
    cin >> h >> m >> H >> M >> k;
    int dis = (H * 60 + M) - (h * 60 + m) - k;
    cout << dis << endl;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define pr(n) cout << fixed << setprecision(n)
#define ci(n) cin >> n
#define ci2(n, o) cin >> n >> o
#define ci3(n, o, p) cin >> n >> o >> p
#define co(n) cout << n << endl

int main() {
  int K, N, a = 0;
  ci2(K, N);
  ve(int) A(N);
  rep(i, N) {
    ci(A.at(i));
  }
  ve(int) B(N);
  rep(i, N - 1) {
    B.at(i) = A.at(i + 1) - A.at(i);
  }
  B.at(N - 1) = K - A.at(N - 1) + A.at(0);
  sort(B.begin(), B.end());
  rep(i, N) {
    a += B.at(i);
  }
  a -= B.at(N - 1);
  co(a);
}  

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

D, G = MAP()
G //= 100
DC = []
MAX = 0
for i in range(D):
    d, c = MAP()
    c //= 100
    MAX += d
    DC.append((d, c))

# dp[i][j] := i点問題まで見て、合計j問解いた状態でのスコア最大値
dp = list2d(D+1, MAX+1, 0)
for i in range(D):
    d, c = DC[i]
    for j in range(MAX+1):
        for k in range(d+1):
            if j+k > MAX:
                break
            if k == d:
                # 全完ボーナス付
                dp[i+1][j+k] = max(dp[i+1][j+k], dp[i][j] + (i+1) * k + c)
            else:
                # 通常
                dp[i+1][j+k] = max(dp[i+1][j+k], dp[i][j] + (i+1) * k)

# スコアがG以上となる最小の解いた問題数を出力
for j in range(MAX+1):
    if dp[D][j] >= G:
        print(j)
        break


Measured memory_bytes: 40688
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  string left="qwertasdfgzxcvb",right="yuiophjklnm";
  string in;

  while(1){
    cin >>in;
    if(in == "#")break;
    int cnt=0;
    int hand=-1;//left 1 right 2
    
    for(int i=0 ; i < (int)in.size() ; i++){
      
      char key=in[i];
      
      if(left.find(key) != -1 && hand != 1){
	cnt++;
	hand=1;
      }else if(right.find(key) != -1 && hand !=2){
	cnt++;
	hand=2;
      }
    }
    
    cout <<cnt-1<<endl;
  }
  
  

  return 0;
}

Measured memory_bytes: 1188
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
  int i;
  int n, m;
  cin >> n >> m;
  int mx = m;
  for(i = 0; i < n && m >= 0; ++i) {
    int p, q;
    cin >> p >> q;
    m += p - q;
    mx = max(mx, m);
  }
  cout << (m < 0 ? 0 : mx) << endl;
  return 0;
}

Measured memory_bytes: 1160
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

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


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         <vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define MN                           INT_MIN
#define MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}
int32_t main()
{
	int n;
	cin >> n;
	int a[n];
	for(int i = 0;i<n;i++)
		cin >> a[i];
	int mn = MX,cnt = 0;
	for(int i = 0;i<n;i++)
	{
		mn = min(mn,a[i]);
		if(a[i] <= mn)
		{
			cnt++;
		}
	}
	cout <<cnt<<endl;
}

Measured memory_bytes: 4424
#include <stdio.h>
#include <string.h>

int main()
{
	int n;
	int i;
	int money = 100000;
	scanf("%d",&n);
	for (i = 0; i < n; i += 1)
	{
		money = money * 105 / 100;
		if(money % 1000)
		{
			money = money - (money % 1000) + 1000;
		}
	}
	printf("%d\n",money);
	return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

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

struct Prime {
    vector<int> p_list;
    set<int> p_set;

    Prime (int N) {
        set<int> no_prime;
        if(2 <= N) {
            p_list.push_back(2);
            p_set.insert(2);
        }

        int idx = 3;
        while(idx <= N) {
            if(no_prime.count(idx) == 0) {
                p_list.push_back(idx);
                p_set.insert(idx);
                LL x = 2;
                while(idx * x <= N) {
                    no_prime.insert((int)(idx * x));
                    x++;
                }
            }

            idx += 2;
        }
    }

    bool isPrime(int i) {
        return p_set.count(i) == 1;
    }
};

void solve(long long N){
    VI ans;

    Prime x(55555);
    int target = 11;
    REP(i, x.p_list.size()) {
        if(x.p_list[i] % 10 == 1) {
            ans.PB(x.p_list[i]);
        }

        if(ans.size() == N) break;
    }

    cout << ans[0];
    REP1(i, N) cout << " " << ans[i];
    cout << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 2816