akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

//System.out.println();
public class Main implements Runnable { //クラス名はMain

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	//2 ≤ N ≤10^5
	//1 ≤ hi ≤ 10^4
	public void run() {
		FastScannerFrog12 sc = new FastScannerFrog12(System.in);

		//Refer to https://qiita.com/drken/items/dc53c683d6de8aeacf5a
		int N = sc.nextInt();
		int h[] = new int[N];
		int dp[] = new int[N];

		for (int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
		}

		dp[0] = 0;

		for (int i = 1; i < N; i++) {
			if (i == 1) {
				dp[i] = Math.abs(h[i] - h[i - 1]);
			} else {
				int jump1 = Math.abs(h[i] - h[i - 1]) + dp[i - 1];
				int jump2 = Math.abs(h[i] - h[i - 2]) + dp[i - 2];

				dp[i] = Math.min(jump1, jump2);

			}
		}
		System.out.println(dp[N - 1]);
	}
}

//高速なScanner
class FastScannerFrog12 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerFrog12(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

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

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


Measured memory_bytes: 34780
object Main {

  def main(args: Array[String]): Unit = {
    // 一番遅い所に左右される
    // 一番人を運べない地点に最初に人が到達するまでの時間 +
    // そのあと、全ての人間をその地点が通すことができる時間 +
    // 最後に通過したグループが都市6まで到達することができる時間
    // 実際、一番人を運べない地点に最初に人が到達するまでの時間 + 最後に通過したグループが都市6まで到達することができる時間 = 5分 なので
    // 全ての人間が一番少ない場所を全て通過するまでにかかる時間 + 5分が回答
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextLong()
    val min = Array.fill(5)(sc.nextLong()).min
    println(Math.ceil(N / min.toDouble).toLong + 4)
  }

}


Measured memory_bytes: 27432
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
int a[100010];
int main()
{
#ifdef DEBUG
	freopen("b.in","r",stdin);
	freopen("b.out","w",stdout);
#endif
	int n;
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1,greater<int>());
	int ans;
	a[0]=a[1];
	for(i=0;i<=n;i++)
		if(a[i+1]<=i)
		{
			ans=(a[i]-i)&1;
			int j=i+1;
			while(j<=n&&a[j]==i)
				j++;
			if((j-i+1)&1)
				ans=1;
			break;
		}
	if(ans)
		printf("First\n");
	else
		printf("Second\n");
	return 0;
}

Measured memory_bytes: 512
tmp = list(map(int, input().split()))
N = tmp[0]
Y = tmp[1]

ans = []
for x in range(0 ,N+1):
    for y in range(0, (N+1) - x):
        z = N - (x + y)
        if 10000*x + 5000*y + 1000*z == Y:
            ans.append([x,y,z])
        else:
            continue

if len(ans) != 0:
    print(ans[0][0],ans[0][1],ans[0][2])
else:
    print('-1 -1 -1')    

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

int main() {
    int W, a, b; cin >> W >> a >> b;
    if (a + W < b || b + W < a) {
        cout << min(abs(b - a - W), abs(a - b - W)) << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3644
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 2000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
vector<int> vertexs[200000];
string ans[2] = { "Alice","Bob" };
int dfs(int now, int back) {
	int ans = 0;
	for (int i = 0;i < vertexs[now].size();++i) {
		if (vertexs[now][i] != back) {
			ans ^= 1+dfs(vertexs[now][i], now);
		}
	}
	return ans;
}
int main() {
	int n;
	cin >> n;
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		vertexs[a].push_back(b);
		vertexs[b].push_back(a);
	}
	if (dfs(1, -1) != 0) {
		cout << "Alice" << endl;
	}
	else cout << "Bob" << endl;
	return 0;
}

Measured memory_bytes: 14336
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

import copy
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

PPP = 1000000007

# 整数の入力
#n = int(input())

# スペース区切りの整数の入力
#w = [x for x in map(int, input().split())]
n, k = map(int, input().split())
print("sp", n, k, file=sys.stderr)
#p, q, r = map(int, input().split())

# 改行区切りの整数の入力
a = []
#for x in range(m):
#  a.append(int(input()))
#  a.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]
#print(a, file=sys.stderr)

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()

import re

def doit():
  if k == 1:
    return 0
  return n - k

#print(doit([0] * 4))
#doit(s)
try:
  print(doit())
except Exception as e:
  print("e", e, file=sys.stderr)


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

double dist(int x1, int x2, int y1, int y2) {
    return sqrt((double)pow(x2-x1, 2) + (double)pow(y2-y1, 2));
}

int main() {
    int n;
    cin >> n;
    vint x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    vint id(n);
    rep(i, n) id[i] = i;
    double ans = 0;
    double count = 0;
    do {
        rep(i, n-1) {
            ans += dist(x[id[i]], x[id[i+1]], y[id[i]], y[id[i+1]]);
        } 
        count++;
    } while( next_permutation(all(id)));

    ans /= count;

    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <size_t N>
using Bits = std::bitset<N>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    Int n;
    std::cin >> n;

    Real mot = 0;
    for (Int i = 0; i < n; ++i) {
        Real a;
        std::cin >> a;
        mot += 1. / a;
    }
    std::cout << Fout(10) << 1. / mot << std::endl;
    return 0;
}


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

int main(void) {
    vector<int> pqr(3); 

    for(int i=0;i<3;i++){
        cin >> pqr[i];
    }

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

    cout << pqr[0]+pqr[1] << endl;

    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
count = 0

for i in range(len(L)):
#  print(i)
  for j in range(i + 1, len(L)):
#    print('	:' + str(j))
    for k in range(j + 1, len(L)):
#      print('		:' + str(k))
      tmp = [L[i] ,L[j], L[k]]
      tmp.sort()
#      print(tmp)
      if L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
        if tmp[0] + tmp[1] > tmp[2]:
          count += 1
print(count)

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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a + b + c >= 22){
		cout << "bust" << endl;
	}else{
		cout << "win" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
(declaim (optimize (speed 0) (debug 3) (safety 3)))

(defun make-union-find (n)
  (let ((x (make-array n)))
    (loop for i from 0 below n
       do (setf (aref x i) i))
    x))

(defun lookup (uf n)
  (if (= (aref uf n) n)
      n
      (setf (aref uf n)
	    (lookup uf (aref uf n)))))

(defun unite (uf n m)
  (setf (aref uf (lookup uf n))
	(lookup uf m)))

(defun force (uf)
  (loop for x from 0 below (length uf)
     do (lookup uf x)))

(defun main ()
  (let* ((n (read))
	 (k (read))
	 (l (read))
	 (road (make-union-find n))
	 (rail (make-union-find n)))
    (loop repeat k
       do (let ((p (1- (read)))
		(q (1- (read))))
	    (unite road p q)))
    (loop repeat l
       do (let ((r (1- (read)))
		(s (1- (read))))
	    (unite rail r s)))
    (force road)
    (force rail)

    (let ((table (make-hash-table)))
      (labels ((idx (i) (+ (* (lookup road i) n)
			   (lookup rail i))))
	(loop for i from 0 below n
	   do (if (gethash (idx i) table)
		  (incf (gethash (idx i) table))
		  (setf (gethash (idx i) table) 1)))
	(loop for i from 0 below n
	   do (format t "~a " (gethash (idx i) table)))
	(terpri)))))

(main)


Measured memory_bytes: 71168
import sys
sys.setrecursionlimit(10**6)
N, M, Q = map(int, input().split())
l=[]
p=[]
for i in range(M):
    t=input().split()
    l.append((int(t[0]),int(t[1])))
for i in range(Q):
    t=input().split()
    p.append((int(t[0]),int(t[1])))

ans = int(0)
count = int(0)
sumTrain = [[0 for i in range(N+1)] for j in range(N+1)]
ansTrain = [[-1 for i in range(N+1)] for j in range(N+1)]

for i in range(M):
    sumTrain[l[i][0]][l[i][1]] += 1

def dfs(l, r):
    if not l <= r:
        return 0
    if l == r:
        return sumTrain[l][r]
    if ansTrain[l][r] != -1:
        return ansTrain[l][r]
    ansTrain[l][r] = res = sumTrain[l][r] + dfs(l+1, r) + dfs(l, r-1) - dfs(l+1, r-1)
    return res

for i in range(Q):
    ans = dfs(p[i][0],p[i][1])
    print(ans)


Measured memory_bytes: 42920
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    string S;
    cin >> N >> S >> K;
    rep(i, N) {
        if (S[K - 1] != S[i]) cout << "*";
        else cout << S[i];
    }
    cout << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n,m;
    cin >>n >>m;
    vector<int> x(m);
    rep(i,m) cin >>x[i];

    sort(all(x));

    if(n>=m){
        cout << 0 << endl;
        return 0;
    }

    vector<int> d;
    rep(i,m-1) d.pb(x[i+1]-x[i]);
    sort(all(d), greater<int>());

    int s = 0;
    for(int i:d) s += i;
    rep(i,n-1) s -= d[i];

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 1276
#include<cstdio>

int main(){
    char op;
    int a,b,c;
    for(;;){
        scanf("%d %c %d",&a,&op,&b);
            if(op == '+'){
                c = a + b;
            }
            else if(op == '-'){
                c = a - b;
            }
            else if(op == '*'){
                c = a * b;
            }
            else if(op == '/'){
                c = a / b;
            }
            else if(op == '?'){
                break;
            }
        printf("%d\n",c);
    }
    
    return 0;
}


Measured memory_bytes: 2740
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
#include <cmath>
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*
小数の扱い。全部doubleにしないと10^-9以上の誤差が出る
*/
int main()
{
    double A,B,H,M;
    cin >> A >> B >> H >> M;
    //角度を考える
    double Hangle,Mangle,angle;
    const double pi = acos(-1.0);
    cout << fixed << setprecision(30);
    //fin(pi);
    
    angle = fabs(pi/180*(30*H-11*M/2));
    double cosan = cos(angle);
    //fin(cosan);
    double ans = sqrt(A*A+B*B-2*A*B*cosan);
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // 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 all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

signed main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  rep(i, tx - sx) { cout << "R"; }
  rep(i, ty - sy) { cout << "U"; }
  rep(i, tx - sx) { cout << "L"; }
  rep(i, ty - sy) { cout << "D"; }
  cout << "D";
  rep(i, tx - sx + 1) { cout << "R"; }
  rep(i, ty - sy + 1) { cout << "U"; }
  cout << "L";
  cout << "U";
  rep(i, tx - sx + 1) { cout << "L"; }
  rep(i, ty - sy + 1) { cout << "D"; }
  cout << "R";
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<time.h>

using namespace std;

#define ll long long
#define MOD 1000000007

int n;
int a[500001];
int b[500002];
int zerob[500003];

vector<int> xat[1<<20];
map<int,ll> dp[2];

int getNextX(int at, int tarX){
	vector<int> target = xat[tarX];
	vector<int>::iterator position = lower_bound(target.begin(), target.end(), at);
	if(position == target.end())return n;
	return *position;
}

int getXnum(int l, int r, int tarX){
	vector<int> target = xat[tarX];
	vector<int>::iterator posA = lower_bound(target.begin(), target.end(), l);
	vector<int>::iterator posB = lower_bound(target.begin(), target.end(), r);
	return posB-posA;
}

int get0num(int l, int r){
	return zerob[r]-zerob[l];
}

int main(){
	cin >> n;
	// srand((unsigned)time(NULL));
	// n = 500000;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		// a[i] = i%40;
		// a[i] = (1<<20)-1;
	}
	b[0] = 0;
	for(int i = 0;i < n;i++){
		b[i+1] = b[i]^a[i];
	}
	n++;
	zerob[0] = 0;
	for(int i = 0;i < n;i++){
		xat[b[i]].push_back(i);
		zerob[i+1] = zerob[i]+(b[i]==0?1:0);
	}
	// for(int i = 0;i < n;i++){
	// 	cout << b[i] << " ";
	// }
	// cout << endl;
	// for(int i = 0;i < n;i++){
	// 	cout << zerob[i] << " ";
	// }
	// cout << endl;
	ll ans = 0;
	map<int,int> fin;
	for(int i = 0;i < n;i++){
		int X = b[i];
		if(X == 0)continue;
		if(fin[X] == 1)continue;
		if(b[n-1] != 0 && b[n-1] != X)continue;
		// cout << X << endl;
		fin[X] = 1;

		vector<pair<int,int> > target;
		int index_last = 0;
		int count = 1;
		if(b[n-1] == 0)xat[X].push_back(n);//番兵
		target.push_back(make_pair(0,1));
		// cout << xat[X].size() <<endl;
		for(int j = 1;j < xat[X].size();j++){//座標圧縮
			int at = xat[X][j];
			// cout << at << " ";
			int num0 = get0num(xat[X][index_last], at);
			if(num0==0){
				count++;
				continue;
			}
			target.push_back(make_pair(X,count));
			target.push_back(make_pair(0,num0));
			index_last = j;
			count = 1;
		}
		if(b[n-1] != 0)target.push_back(make_pair(X,count));
		// cout << endl;
		// cout << X << endl;
		// for(int j = 0;j < target.size();j++){
		// 	cout << target[j].first << " " << target[j].second << endl;
		// }

		dp[0].clear();
		dp[1].clear();
		int n2 = target.size();
		dp[0][n2-1] = b[n-1]==0?0:1;
		dp[1][n2-1] = (dp[0][n2-1]+1)%2;
		for(int at = n2-2;at!=-1;at--){
			for(int before = 0;before<2;before++){
				// cout << at << endl;
				dp[before][at] = 0;
				dp[before][at] += dp[before][at+1];
				int y = target[at].first;
				int len = target[at].second;
				if(y==0 && before==1){
					dp[before][at] += dp[0][at+1]*len%MOD;//選ぶ
				}else if(y!=0 && before==0){
					dp[before][at] += dp[1][at+1]*len%MOD;//選ぶ
				}
				dp[before][at]%=MOD;
			}
		}
		ans+=dp[0][0];
		ans%=MOD;
	}
	if(b[n-1]!=0){
		cout << ans << endl;
		return 0;
	}
	int num0 = getXnum(0,n,0);
	ll ans0 = 1;
	for(int i = 0;i < num0-2;i++){
		ans0*=2;
		ans0%=MOD;
	}
	cout << (ans0+ans)%MOD << endl;
}

Measured memory_bytes: 63152
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
static const int MAX = 1e4;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
//first: 目的点,second: 距離
vector<pair<int,int> > adj[MAX];

void dijkstra(){
  //first: ある点へのマイナス距離, second: ある点
  priority_queue<pair<int,int> > pq;
  //d[i]: 始点からのiへの距離
  int d[MAX],color[MAX];
  for(int i=0;i<n;i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }
  d[0] = 0;
  pq.push(make_pair(0,0));
  while(!pq.empty()){
    pair<int,int> key = pq.top();
    pq.pop();
    int u = key.second;
    color[u] = BLACK;
    if(d[u] < key.first*(-1)) continue;
    for(int j=0;j<adj[u].size();j++){
      int v = adj[u][j].first;
      if(color[v]==BLACK) continue;
      if(d[v] > d[u] + adj[u][j].second){
        //ここで最初に更新されているから、pqからtopを取り出すだけでOK
        d[v] = d[u] + adj[u][j].second;
        pq.push(make_pair((-1)*d[v],v));
        color[v] = GRAY;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout << i << " " << (d[i]==INFTY ? -1 : d[i]) << endl;
  }
}

int main(){
  int k,u,v,c;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int j=0;j<k;j++){
      cin >> v >> c;
      adj[u].push_back(make_pair(v,c));
    }
  }
  dijkstra();
}



Measured memory_bytes: 8024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    
    cin >> n;
    
    if(n/10==9){
        
        cout << "Yes" << endl;
        
    } else if(n%10==9){
        
        cout << "Yes" << endl;
        
    } else {
        
        cout << "No" << endl;
        
    }
    
    return 0;
    
}

Measured memory_bytes: 256
#include<stdio.h>

int n, q, a, b, z;
int X[1000];
int comp(int n, int a, int b);
int main(void) {
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%d", &X[i]);
        
    }
    scanf("%d", &q);
    while(q--){
        scanf("%d%d%d", &n, &a, &b);
        printf("%d\n", comp(n, a, b));
        //if (q != 0)printf("\n");
    }
    return 0;
}

int comp(int n, int a, int b){
    if (n == 0){
        if (a == 0 && b == 1){z = X[a]; return z;}
        //if (a == 0) a = 1;
        z = X[a];
        for (int i = a; i < b; i++){
            if (i == b - 1) break;//printf("%d %d \n",i , z);
            if (z <= X[i+1]);
            else z = X[i+1];
        }
    }
    else if (n == 1){
        if (a == 0 && b == 1){z = X[a]; return z;}
        //if (a == 0) a = 1;
        z = X[a];
        for (int i = a; i < b; i++){
            if (i == b - 1) break;
            if (z > X[i+1]);
            else z = X[i+1];
        }
    }
    return z;
}


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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> x(n);
    x[0] = 0;
    for (int i=1;i<n;i++) {
        cin >> a[i];
        x[i] = 0;
    }
    for (int i=1;i<n;i++) {
        x[a[i]-1]++;
    }
    rep(i,n) {
        cout << x[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    double N, M, A, B, C;
    string s1, s2;
    cin >> s1 >> s2;
    int ans = 10000;
    for(int i = 0; i + s2.size() - 1 < s1.size(); i++){
        int tmp = 0;
        for(int j = 0; j < s2.size(); j++){
            if(s1[i + j] != s2[j]) tmp++;
        }
        // cout << tmp << endl;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  // ifstream cin("../test.txt");
  int n;
  int a[10] = {1,2,4,8,16,32,64,128,256,512};
  while (cin >> n) {
    stack<int> s;
    for (int i = 9; i >= 0; i--) {
      if (n >= a[i]) {
        n -= a[i];
        s.push(a[i]);
      }
    }
    int m = s.size() - 1;
    while (m--) {
      cout << s.top() << " ";
      s.pop();
    }
    cout << s.top() << endl;
  }
}

Measured memory_bytes: 1200
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

void solve()
{
    int N;
    cin >> N;
    vector<int> s(N);
    int ans = 0;

    REP0(i, N)
    {
        cin >> s[i];
        ans += s[i];
    }

    if (ans % 10 != 0)
    {
        cout << ans << endl;
        return;
    }

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

    REP0(i, N)
    { // 小さい順に問題を見て、10の倍数でない最も小さい問題を外す
        if (s[i] % 10 == 0)
            continue;
        else
        {
            ans -= s[i];
            cout << ans << endl;
            return;
        }
    }
    // 全部みても10の倍数でないものがなかったら0点
    cout << 0 << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    ll x;cin>>x;
    ll ans=(ll)(x/(ll)11)*(ll)2;
    int y=x%11;
    if(y>0 && y<=6)ans++;
    if(y>=7)ans+=2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    sum_A = sum(A)
    border = (1 / (4 * M)) * sum_A
    count = 0
    for a in A:
        if a >= border:
            count += 1
    if count >= M:
        print("Yes")
    else:print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;
#define PI 3.14159265358979323846264338327950L
const int mod =  998244353;



#define SIZE 200005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

struct BIT{
	int bit[SIZE];
	
	void init(){memset(bit,0,sizeof(bit));}
    
	void add(int k,int x) {
		k++;
		while(k<SIZE){
			bit[k]+=x;
			k+=k&-k;
		}
	}
	int get(int k){
		k++;
		int ret=0;
		while(k>0){
			ret+=bit[k];
			k-=k&-k;
		}
		return ret;
	}
    
	int get(int s,int t){
		return get(t)-get(s-1);
	}
    
	int pos(int k){ //k番目
		int l=0,r=SIZE;
		while(r-l>1)
		{
			int m=(l+r)/2;
			if(get(m)<k) l=m;
			else r=m;
		}
		return r;
	}
};


BIT bit;




void solve(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    rep(j,k){
        bit.init();
        rep(i,n){
            int l = max(0,i - a[i]);
            int r = min(n,i + a[i]+1);
            bit.add(l,1);
            bit.add(r,-1);
        }
        int minV = 1001001001;
        rep(i,n){
            a[i] = bit.get(0,i);
            minV = min(a[i],minV);
        }
        if (minV == n){
            break;
        }
    }
    rep(i,n) cout << a[i] << " ";

}


int main(){
    int T;
    T = 1;
    while(T--){
        solve();
        cout << endl;
    }
}


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

using namespace std;

int gcd(int n, int m) {
	if (n < m) {
		swap(n,m);
	}
	if (m == 0) {
		return n;
	}
	return gcd(m,n%m);
}

int main(void) {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}

	int res = -1;
	if (N > 2) {
		vector<int> ltr(N),rtl(N);
		ltr[0] = A[0];
		rtl[N-1] = A[N-1];
		for (int i = 1; i < N; ++i) {
			ltr[i] = gcd(A[i],ltr[i-1]);
			rtl[N-i-1] = gcd(A[N-i-1],rtl[N-i]);
		}

		for (int i = 0; i < N; ++i) {
			int now;
			if (i == 0) {
				now = rtl[1];
			}
			else if (i == N-1) {
				now = ltr[N-2];
			}
			else {
				now = gcd(ltr[i-1],rtl[i+1]);
			}
			res = max(now,res);
		}
	}
	else {
		res = max(A[0],A[1]);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std ;
template< class T > inl T read() {
	T x = 0 ; int f = 1 ; char k = getchar() ;
	for( ; k > '9' || k < '0'; k = getchar() ) if( k == '-' ) f = -1 ;
	for( ; k >= '0' && k <= '9'; k = getchar() ) x = x * 10 + k - '0' ;
	return x * f ;
}
template< class T > inl T read( T &x ) { return x = read<T>() ; }
int _num, _buf[20];
template< class T > il print( T x ) {
   	if( x == 0 ) return putchar( '0' ) ,void() ;
	if( x < 0 ) putchar( '-' ), x = -x ;
	while( x ) _buf[++_num] = x % 10, x /= 10 ;
	while( _num ) putchar( _buf[_num--] + '0' ) ;
}
ll mul( ll a, ll b, ll mod ) { long double c = 1. ; return ( a * b - (ll)( c * a * b / mod ) * mod ) % mod ; }
it qpow( int x, int m, int mod ) {
	int res = 1, bas = x ;
	while(m) {
		if( m & 1 ) res = ( 1ll * res * bas ) % mod ;
		bas = ( 1ll * bas * bas ) % mod, m >>= 1 ;
	}
	return res ;
}
const int N = 1e3 + 5 ;
int n, k, val[N];
int main() {
//	freopen( ".in", "r", stdin ) ;
//	freopen( ".out", "w", stdout ) ;
	n = read<int>(), k = read<int>() ;
	for( ri i = 1; i <= n; ++i )
		val[i] = read<int>() ;
	std::sort( val + 1, val + 1 + n ) ;
	int ans = 0 ;
	for( ri i = 1; i <= k; ++i )
		ans += val[i] ;
	print( ans ), puts( "" ) ;
	return 0;
}

Measured memory_bytes: 3640
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    S = in_n()
    M = 10**9
    x1, y1 = 0, 0
    x2, y2 = M, 1
    q, r = divmod(S, M)
    if r == 0:
        x3, y3 = r, q
    else:
        x3, y3 = M - r, q + 1

    #print(x2 * y3 - y2 * x3)
    print(x1, y1, x2, y2, x3, y3)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9404
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#define STR 4
int main(){
    char S[STR];
    scanf("%s",S);
    if(S[1]!='B'){
        printf("ABC\n");
    }
    else{
        printf("ARC\n");
    }
    return 0;
}

Measured memory_bytes: 1644
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
	   {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}

  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
	{
	  if(i>1&&i<a&&j<b&&j>1)printf(".");
	  else printf("#");
	}
      printf("\n");
    }
  printf("\n");
    
	   }
  return 0;
}



Measured memory_bytes: 2108
using System;
using System.Collections.Generic;

namespace abc121_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            string[] array2 = Console.ReadLine().Split(' ');

            int AllHorizon = int.Parse(array[0]);
            int AllVertical = int.Parse(array[1]);
            int SelectHorizon = int.Parse(array2[0]);
            int SelectVertical = int.Parse(array2[1]);

            int RemainingHorizon = AllHorizon - SelectHorizon;
            int RemainingVertical = AllVertical - SelectVertical;
            int Answer = RemainingHorizon * RemainingVertical;

            Console.WriteLine(Answer);


        }
    }
}


Measured memory_bytes: 11092
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID

#include<bits/stdc++.h>

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define print(v) for(auto it=(v).begin();it!=(v).end();it++) {cout<<*it<<" ";}
#define ll long long
#define w(t) ll t;cin>>t;while(t--)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
using namespace std;


int main()
{
    int x,n,m=1000,M=-1;
    cin>>x>>n;
    if(n==0)
    {
        cout<<x<<"\n";
        return 0;
    }
    bool a[102]={false};
    forn(i,n){
        int y;
        cin>>y;
        a[y]=true;
    }
    ll ans=-1;
    for(int i=0;i<=101;++i)
    {
        if(!a[i])
            if(abs(x-i)<abs(x-ans))
        {
            ans=i;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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

struct Data{
     long num1; 
     long num2;
     bool operator<( const Data& another ) const {
       return  num1 < another.num1;
    }
};
 
int main() {
  long N;
  cin >> N;
  
  vector<int> a(N);
  vector<int> b(N);
  vector<Data> d(N);///???
  for (long i = 0; i < N; i++) {
    cin >> a.at(i) >> b.at(i);
    d[i].num1 = a.at(i) + b.at(i);
    d[i].num2 = i;
  }
    
    sort(d.begin(),  d.end());
    reverse(d.begin(), d.end());
  long value = 0;
  for (long i = 0; i < N; i++) {
    if (i % 2 == 0) {
      value = value + a.at(d[i].num2);
    } else {
      value = value - b.at(d[i].num2);
    }
  }
  cout << value << endl;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<string.h>
#define N 100000

typedef struct pp{
  char name[100];
  int t;
}P;

int head, tail, n, c=0, q;
P Q[N];
void enqueue(){
  Q[head].t = Q[head].t -q;
  Q[tail] = Q[head];
  if(tail > n+1) tail = 0;
  else tail++;
}

void dequeue(){
  printf("%s %d\n",Q[head].name, Q[head].t+c);
}

int main(){
  int i;
  
  scanf("%d %d", &n, &q);
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n+1;
  i = 1;
  while(head != tail){
    if(Q[head].t > q){
    enqueue();
    c = c + q;
    }
    else{
      dequeue();
      c = c + Q[head].t;
	}
  if(head > n+1) head = 0;
  else head++;
  }
  return 0;
}

Measured memory_bytes: 6744
main(){
 long int k,i,n;
  scanf("%ld",&n);
  long long int a[n],b[n],l=0,s=0,m=1000000000+7;
  for(i=0;i<n;i++){scanf("%lld",&a[i]);l=(l+a[i])%m;b[i]=l;}
 for(k=0;k<n;k++){s+=a[k]*(b[n-1]-b[k]);s=s%m;}
  if(s>=0)printf("%lld",s);
 else printf("%lld",s+m);
}


Measured memory_bytes: 4804
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(), (a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(), (a).end())
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    bool ans = false;
    int i=0,t=0;
    while(i<n){
        t = a[t];
        //cout<<"button"<<t+1<<endl;
        i++;
        if(t==1){
            ans = true;
            break;
        }
    }
    if(ans){
        cout<<i<<endl;
    }
    else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 640
def cal_comb_num(n, x):
    sum = 0
    pairs = 0
    for i in range(1, n-1):
        for j in range(i+1, n):
            sum = x - i - j
            if j < sum <= n:
                pairs += 1
    print(pairs)

for i in range(10000):
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    else:
        cal_comb_num(n, x)


Measured memory_bytes: 5592
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MAX 100

int n, a[MAX], b[MAX];
char c[MAX][3], d[MAX][3];
char *s;
char t[256];

 

void swap_str(char *sx, char *sy)
{
	char tmp[MAX];
	
	strcpy(tmp,sx);
	strcpy(sx,sy);
	strcpy(sy,tmp);
}
void swap_int(int *x, int *y)
{
	int tmp = *x;
	*x =*y ;
	*y = tmp;
}

void print1()
{
	int i;
	
	for (i = 0; i < n; i++) {
		if (i > 0) {
			printf(" ");
		}
		printf("%s",c[i]);
	}
	printf("\n");
}

void print2()
{
	int i;
	
	for (i = 0; i < n; i++) {
		if (i > 0) {
			printf(" ");
		}
		printf("%s",d[i]);
	}
	printf("\n");
}

void bubbleSort()
{
	int i, tmp, flag;

	flag = 1;
	while (flag) 
	{
		flag = 0;
		for (i = n - 1; i > 0; i--) 
		{
			if (a[i] < a[i - 1]) 
			{
				swap_str(c[i], c[i-1]);
				swap_int(&a[i], &a[i-1]);
				flag = 1;
			}
		}
	}
}
void selectionSort()
{
	int i, j, tmp, minj;
	
	for (i = 0; i < n; i++) {
		minj = i;
		
		for (j = i; j < n; j++) {
			if (b[j] < b[minj]) {
				minj = j;
			}
		}
		if(i != minj)
		{
			swap_str(d[i], d[minj]);
			swap_int(&b[i], &b[minj]);
		}
		
	}
	
}

int main()
{
	int i;
	
	scanf("%d",&n);
	
	for(i = 0; i < n; i++)
	{
		scanf("%s", &c[i]);
		b[i] = a[i] = (int)(c[i][1] - '0');
		strcpy(d[i], c[i]);
	}
	
	bubbleSort();
	print1();
	printf("Stable\n");
	selectionSort();
	print2();
	
	for (i = 0; i < n; i++)
	{
		if (c[i][0] != d[i][0])
		{
			printf("Not stable\n");
			return 0;
		}
	}
	printf("Stable\n");
	

return 0;
}


Measured memory_bytes: 2076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=101;
const ll maxw=1e5+1;
ll wt[maxn],v[maxn],dp[maxn][maxw];
ll n,w;
int main()
{
	cin>>n>>w;
	for(int i=1;i<=n;i++)cin>>wt[i]>>v[i];
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=w;j++)
		{
			if(i==0||j==0)dp[i][j]=0;
			else if(wt[i]>j)dp[i][j]=dp[i-1][j];
			else dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-wt[i]]);
		}
	}
	cout<<dp[n][w]<<endl;
	return 0;
}

Measured memory_bytes: 79104
import java.util.*;

public class Main {


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

        int n = sc.nextInt();

        int[] p = new int[100002];

        for(int i = 0 ; i < p.length; i++){
            p[i] = 0;
        }

        for(int i = 0; i < n; i++){
            int d = sc.nextInt();
            p[d + 1]++;
        }

        int ans = 0;
        int sum = 0;
        for(int i = 0; i < p.length; i++){
            if(sum + p[i] == n / 2){
                ans++;
            }
            sum += p[i];
        }


        System.out.println(ans);

        return;
    }
}


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

int main() {
  long N,a,b,c,d,e;
  cin >> N >> a >> b >> c >> d >> e ;
  long m=min(a,min(b,min(c,min(d,e))));
  long flag=0;
  if(N%m==0){
    flag ++;
  }
  cout<<N/m+5-flag<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const double pai=3.14159;
inline int read() {
	int x=0;char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x;
}
int main() {
	int r=read();
	printf("%.4lf\n",2*pai*r);
}

Measured memory_bytes: 3720
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-variable"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;
// }}}

int main() {
    string s;
    cin >> s;
    int ans=0;
    for ( char c:s ) {
        if ( c=='2' ) ans++;
    }
    cout << ans << '\n';
    return 0;
}






Measured memory_bytes: 3596
A,B,C=map(int,input().split())

a=0
D=set()
while True:
    if A%2!=0 or B%2!=0 or C%2!=0:
        break
    if (A,B,C) in D:
        a=-1
        break
    else:
        D.add((A,B,C))
    p=(B+C)/2
    q=(A+C)/2
    r=(A+B)/2
    A=p;B=q;C=r
    a+=1
print(a)

Measured memory_bytes: 9180
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;


int p,q;
 
int main(){

  for(int N, Q;cin>>N>>Q&&(N|Q);) {
    vector<string> M(N);
    vector<string> T(Q);
    vector<int> ans(Q);
    rep(i, Q) ans[i] = inf;
    rep(i, N) cin >> M[i];
    rep(i, Q) cin >> T[i];
    REP(R, 1, 21) REP(C, 1, 21) REP(S, 1, 21) {
      bool ok = 1;
      int r = 0, c = 0, s = 0;
      rep(i, N) {
        const int MiLen = M[i].size();
        int indent = 0;
        rep(j, MiLen) {
          if(M[i][j] == '.') {
            indent ++;
          }
          else {
            if(R * r + C * c + S * s != indent) {
              ok = 0;
            }
            break;
          }
        }
        rep(j, MiLen) {
          r += (M[i][j] == '(') - (M[i][j] == ')');
          c += (M[i][j] == '{') - (M[i][j] == '}');
          s += (M[i][j] == '[') - (M[i][j] == ']');
        }
      }

      if(!ok) { continue; }

      r = 0, c = 0, s = 0;

      rep(i, Q) {
        if(ans[i] == inf) {
          ans[i] = R * r + C * c + S * s;
        }
        else if(ans[i] != R * r + C * c + S * s) {
          ans[i] = -1;
        }
        
        int n = T[i].size();
        rep(j, n) {
          r += (T[i][j] == '(') - (T[i][j] == ')');
          c += (T[i][j] == '{') - (T[i][j] == '}');
          s += (T[i][j] == '[') - (T[i][j] == ']');
        }
      }
    }

    rep(i, Q) {
      if(i) cout << " ";
      cout << ans[i];
    }
    cout << endl;

  }

  return 0;
}

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

const int MAX = 770000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1; finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int x, y;
  cin>>x>>y;
  if (2 * y - x < 0 || (2 * y - x) % 3 != 0) {
    cout<<0<<endl;
    return 0;
  }
  if (2 * x - y < 0 || (2 * x - y) % 3 != 0) {
    cout<<0<<endl;
    return 0;
  }
  int a = (2 * y - x) / 3;
  int b = (2 * x - y) / 3;
  COMinit();
  cout<<COM(a + b, a)<<endl;
}

Measured memory_bytes: 18304
#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool PN(T x)
{
  if (x <= 1)
    return false;
  if (x == 2)
    return true;
  for (int i = 2; i < sqrt(x) + 1; i++)
    if (x % i == 0)
      return false;
  return true;
}

const long long MOD = 1e9+7;

void solve()
{
  int n, m; cin >> n >> m;
  long long x[n], y[m];
  for(int i = 0; i < n; ++i) cin >> x[i];
  for(int i = 0; i < m; ++i) cin >> y[i];
  long long xx = 0;
  long long yy = 0;
  for(int i = 0; i < n; i++){
    xx += (i * x[i] - (n-i-1) * x[i]);
    xx %= MOD;
  }

  for(int i = 0; i < m; i++){
    yy += (i * y[i] - (m-i-1) * y[i]);
    yy %= MOD;
  }
  cout << xx * yy % MOD<< endl;

}

int main()
{
  solve();
  return 0;
}

Measured memory_bytes: 5132
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
     long long a,b,c=0;
     cin>>a>>b;
     long long  q[a];
     for(int i=0;i<a;i++){
	  cin>>q[i];
     }
     sort(q,q+a);
     for(int i=0;i<a-b;i++){
     	c+=q[i];
	}
          cout<<c;
}

Measured memory_bytes: 1792