akhauriyash/Code-Regression huggingface dataset:
(defun read-alist(N &optional (i 1) (l nil))
  (if (< N i) l
    (let ((str (format nil "~A~13D" (read) (- 100 (read)))))
      (read-alist N (1+ i) (cons (cons str i) l)))))


(format t "~{~A~^~%~}"
	(mapcar #'cdr
		(sort (read-alist (read)) #'string< :key #'car)))

Measured memory_bytes: 26344
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;



struct UnionFind {

    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {
            par[i] = i;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける

        return;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

};

int main(){

int N;
cin>>N;
int size;
if(N%2==1){
    size=(N-1)/2+1;
}
else {
    size=N/2;
}

UnionFind uf(N+1);
if(N%2==1){
    for(int i=1;i<N;i++){
        uf.unite(i,N-i);
    }
}
else{
    for(int i=1;i<=N;i++){
        uf.unite(i,N+1-i);
    }
}
long long m=(N*(N-1))/2-N/2;

cout<<m<<endl;


for(int i=1;i<N;i++){
    for(int k=i+1;k<=N;k++){
        if(!uf.same(i,k)){
        cout<<i<<" "<<k<<endl;
        }
    }
}


return 0;
}
/*
3

2
1 3
2 3

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int d;
    cin >> d;
    switch (d) {
        case 25:
            cout << "Christmas" << endl;
            break;
        case 24:
            cout << "Christmas Eve" << endl;
            break;
        case 23:
            cout << "Christmas Eve Eve" << endl;
            break;
        case 22:
            cout << "Christmas Eve Eve Eve" << endl;
            break;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define MAX 500005
using namespace std;
int H;
void maxHeapify(int A[], int i)
{
  int l = 2*i; int r = 2*i + 1;
  int largest;
  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;
  if(largest != i)
  {
    swap(A[largest], A[i]);
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int A[])
{
  for(int i=H/2; i>=1; i--) maxHeapify(A, i);
}

int main()
{
  scanf("%d", &H);
  int A[MAX];
  for(int i=1; i<=H; i++)
  {
    scanf("%d", &A[i]);
  }
  buildMaxHeap(A);
  for(int i=1; i<=H; i++)
  {
    //if(i != 1)  printf(" ");
    printf(" %d", A[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 5112
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

max_A = max(A)
j = 0
while max_A >> j > 0:
    j += 1
max_j = j

ans = 0
MOD = 10 ** 9 + 7
for j in range(max_j):
    c = [0] * 2
    for i in range(N):
        c[A[i] >> j & 1] += 1
    ans += c[0] * c[1] * (1 << j)
    ans %= MOD
print(ans)


Measured memory_bytes: 122808
def main():
    S = list(input())

    array = ['A', 'C', 'G', 'T']
    count = 0
    ans = 0
    for i in range(len(S)):
        if S[i]!=array[0] and S[i]!=array[1] and S[i]!=array[2] and S[i]!=array[3]:
            ans = max(ans, count)
            count = 0
        else:
            count += 1

    ans = max(ans, count)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct Node{
    Node *parent,*left,*right;
    int key;
};
Node *root=NULL,*NIL=NULL;
void insert(int k){
    Node* x_parent=NIL;//xの親
    Node* x=root;//挿入する場所
    Node* node=NIL;//新しく挿入するノード
    node=(Node*)malloc(sizeof(Node));
    node->key=k;
    node->right=NIL;
    node->left=NIL;
    while(x!=NIL){
        x_parent=x;
        if(node->key<x->key) x=x->left;
        else x=x->right;
    }
    node->parent=x_parent;
    if(x_parent==NIL) root=node;//木が空の場合
    else{
        if(node->key<x_parent->key) x_parent->left=node;
        else x_parent->right=node;
    }
}
void pre(Node* u){
    if(u==NIL) return;
    printf(" %d",u->key);
    pre(u->left);
    pre(u->right);
}
void in(Node* u){
    if(u==NIL) return;
    in(u->left);
    printf(" %d",u->key);
    in(u->right);
}
Node* find(Node* u,int k){
    while(u!=NIL&&u->key!=k){
        if(k<u->key) u=u->left;
        else u=u->right;
    }
    return u;
}
Node* treeMinimum(Node* x){
    while(x->left!=NIL) x=x->left;
    return x;
}
Node* treeSuccessor(Node* x){
    if(x->right!=NIL) return treeMinimum(x->right);
    Node *y=x->parent;
    while(y!=NIL&&x==y->right){
        x=y;
        y=y->parent;
    }
    return y;
}
void treeDelete(Node* z){
    Node* y;//削除対象がおきかえられるノード
    Node* x;//yの子
    //削除する節点を決める
    if(z->left==NIL||z->right==NIL) y=z;
    else y=treeSuccessor(z);
    //yの子を決める
    if(y->left!=NIL) x=y->left;
    else x=y->right;

    if(x!=NIL) x->parent=y->parent;

    if(y->parent==NIL) root=x;
    else{
        if(y==y->parent->left) y->parent->left=x;
        else y->parent->right=x;
    }

    if(y!=z) z->key=y->key;

    free(y);
}
int main(){
    int m,k;
    scanf("%d",&m);
    string com;
    for(int i=0;i<m;++i){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&k);
            insert(k);
        }else if(com=="print"){
            in(root);
            putchar('\n');
            pre(root);
            putchar('\n');
        }else if(com=="find"){
            scanf("%d",&k);
            printf("%s\n",find(root,k)!=NIL?"yes":"no");
        }else if(com=="delete"){
            scanf("%d",&k);
            treeDelete(find(root,k));
        }
    }
    return 0;
}

Measured memory_bytes: 22020
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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

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

  bool is_ok[100010], is_prime[100010];
  int sum[100010];

  is_prime[1] = false;

  for (int i = 2; i <= 100004; i++)
  {
    is_prime[i] = true;
    for (int j = 2; j * j <= i; j++)
    {
      if (i % j == 0)
        is_prime[i] = false;
    }
  }

  is_ok[1] = false;
  for (int i = 2; i <= 100004; i++)
  {
    if (i % 2 == 0)
      is_ok[i] = false;
    else if (is_prime[i] && is_prime[(i + 1) / 2])
    {
      is_ok[i] = true;
    }
    else
    {
      is_ok[i] = false;
    }
  }

  sum[1] = 0;
  int tmp = 0;
  for (int i = 2; i <= 100002; i++)
  {
    if (is_ok[i])
    {
      sum[i] = ++tmp;
    }
    else
      sum[i] = tmp;
  }

  int ls[100005], rs[100005];

  rep(i, q)
  {
    cin >> ls[i] >> rs[i];
  }

  rep(i, q)
  {
    cout << sum[rs[i]] - sum[max(ls[i] - 2, 1)] << endl;
  }

  // repi(i, 1, 10)
  // {
  //   cout << is_prime[i] << " ";
  // }
  // cout << endl;

  // repi(i, 1, 10)
  // {
  //   cout << is_ok[i] << " ";
  // }
  // cout << endl;
  return 0;
}


Measured memory_bytes: 4920
#include <iostream>
using namespace std;
int A, B, C;
long long K;
int main()
{
    cin >> A >> B >> C;
    cin >> K;
    if(K % 2 == 0)
    {
        cout << A - B << "\n";
    }
    else
        cout << B - A << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

struct UnionFind {
  vi par, count;

  UnionFind(int N) : par(N), count(N, 1){
    for(int i = 0; i < N; i++) par.at(i) = i;
  }

  int root(int x){
    if(par.at(x) == x) return x;
    return par.at(x) = root(par.at(x));
  }

  int unite(int x, int y){
    if(root(x) == root(y)) return 0;
    if(size(x) < size(y)){
      count.at(root(y)) += count.at(root(x));
      par.at(root(x)) = root(y);
    }
    else{
      count.at(root(x)) += count.at(root(y));
      par.at(root(y)) = root(x);
    }
    return 1;
  }

  bool same(int x, int y){
    return root(x) == root(y);
  }

  int size(int x){
    return count.at(root(x));
  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M, K;
  cin >> N >> M >> K;
  UnionFind uf(N);

  vll ans(N, 0LL);

  for(int i = 0; i < M; i++){
    ll A, B;
    cin >> A >> B;
    A--; B--;
    uf.unite(A, B);
    ans.at(A)--; ans.at(B)--;
  }

  for(int i = 0; i < N; i++){
    ans.at(i) += uf.size(i) - 1;
  }

  for(int i = 0; i < K; i++){
    ll C, D;
    cin >> C >> D;
    C--; D--;
    if(uf.same(C, D)){
      ans.at(C)--; ans.at(D)--;
    }
  }
  for(int i = 0; i < N; i++){
    cout << ans.at(i);
    if(i == N-1) cout << endl;
    else cout << ' ';
  }
}

Measured memory_bytes: 2432
if __name__ == '__main__':
    N,K=list(map(int,input().split()))
    AB=[tuple(map(int,input().split())) for i in range(N)]
    AB.sort(key=lambda x:x[0])
    for a,b in AB:
        K-=b
        if K<=0:
            print(a)
            break


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

int main(){
  int H,W;
  cin>>H>>W;
  for(int l=0;l<W+1;l++){
    cout<<'#';
  }
  cout<<'#'<<endl;//1行目
  
  for(int m=0;m<H;m++){
    cout<<'#';
    for(int i=0;i<W;i++){
      char c;
      cin>>c;
      cout<<c;
    }
    cout<<'#'<<endl;
  }
  
  for(int n=0;n<W+1;n++){
    cout<<'#';
  }
  cout<<'#'<<endl;
}

Measured memory_bytes: 256
n,*a=map(int,open(0).read().split())
a.sort()
l=[]
if a[-1]>=0>a[0]:
  a,b=[t for t in a if t>=0],[t for t in a if t<0]
  c,y=a.pop(),b.pop()
  while b:
    t=b.pop()
    l.append((c,t))
    c-=t
  while a:
    t=a.pop()
    l.append((y,t))
    y-=t
  l.append((c,y))
  c-=y
elif a[0]>=0:
  s,*a,c=a
  while a:
    t=a.pop()
    l.append((s,t))
    s-=t
  l.append((c,s))
  c-=s
else:
  *a,c=a
  while a:
    t=a.pop()
    l.append((c,t))
    c-=t
print(c)
for t in l:print(*t)

Measured memory_bytes: 64196
#include<bits/stdc++.h>
#define int  long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define maxx ((ll)1e6+5)
#define pb push_back
#define ins insert
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expo(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*int sv[1000000]={0};
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
void sve() {sv[0]=1;sv[1]=1;for(int i=2;i*i<=maxx;i++){if(!sv[i]){for(int j=2*i;j<=maxx;j+=i)sv[j]=1;}}}//0 hai to prime
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expo(fact[r],mod-2)))%mod; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}*/
using namespace std;
signed main()
{
    //test
    {
    	int n,k,i,j;
    	cin >> n >> k;
    	int a[n+1];
    	for(i=1 ; i<=n ; i++)
    		cin >> a[i];
    	int s[n+1][k+1],f[k+1]={0};
    	for(i=0 ; i<=n ; i++)
    		for(j=0 ; j<=k ; j++)
    			s[i][j] = 0;
    	for(j=1 ; j<=k ; j++)
    	{
    		for(i=1 ; i<=n; i++)
    		{
    			if(a[i] >  j)
    				s[i][j] = 0;
    			else
    			{
    				s[i][j] = 1-f[j-a[i]];
    			}
    			f[j] = max(f[j] , s[i][j]);
    		}
    	}
    	if(f[k]) cout << "First\n";
    	else cout << "Second\n";
    }
    return 0;
}

Measured memory_bytes: 79872
while 1:
	n=input()
	if n==0:break
	a,b,c=[0]*n,0,raw_input()
	for i in range(100):
		if c[i]=="M":
			a[i%n]+=1
		elif c[i]=="S":
			b+=1+a[i%n]
			a[i%n]=0
		else:
			a[i%n]+=1+b
			b=0
	print " ".join(map(str,sorted(a))),b

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

int main(void) {

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		a[num - 1]++;
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < n - k; i++) {
			ans += a[i];
		}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
use std::io;

const MOD: usize = 1_000_000_007;

fn main() {
    let (n, m) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let mut an = vec![false; n];
    for _ in 0..m { an[read_one::<usize>() - 1] = true; }

    if n == 1 {
        let ans = if an[0] { 0 } else { 1 };
        println!("{}", ans);
        return;
    }

    let mut dp = vec![0; n];
    dp[0] = if an[0] { 0 } else { 1 };
    dp[1] = if an[1] { 0 } else { 1 + dp[0] };
    for i in 2..n {
        if an[i] { continue; }
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
    }
    println!("{}", dp[n - 1]);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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


int main() {
  vector<vector<int>> c(3, vector<int>(3));
  rep(i, 3){
    rep(j, 3) cin >> c[i][j];
  }
  bool can = false;
  rep(i, c[0][0]+1){
    int a1, a2, a3, b1, b2, b3;
    a1 = i;
    b1 = c[0][0] - a1;
    b2 = c[0][1] - a1;
    b3 = c[0][2] - a1;
    a2 = c[1][0] - b1;
    a3 = c[2][0] - b1;
    if(a2 + b2 == c[1][1] && a2 + b3 == c[1][2]
       && a3 + b2 == c[2][1] && a3 + b3 == c[2][2]){
      can = true;
      break;
    }
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;

int h,w;
char field[105][105];
int main(){
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;++i) scanf("%s",field[i]);
	for(int i=0;i<h;++i){
		int lastPos=-1;
		for(int j=0;j<w;++j){
			if(field[i][j]=='c') lastPos=j;
			
			int res=-1;
			if(lastPos!=-1) res=j-lastPos;
			printf("%d%c",res,j==w-1?'\n':' ');
		}
	}

	return 0;
}

Measured memory_bytes: 2724
function main(input) {
  const b = input.trim();
  let result = "";
  if (b === "A") {
    result = "T";
  } else if (b === "T") {
    result = "A";
  } else if (b === "G") {
    result = "C";
  } else if (b === "C") {
    result = "G";
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main(void){
int n;
cin>>n;
priority_queue<int> q;
for(int i=0;i<n;i++){
	int b;
	cin>>b;
	q.push(b);
}
int s=q.top();
vector<bool> a(s+1,false);
while(!q.empty()){
	int now=q.top();
	q.pop();
	if(a[now]){
		a[now]=false;
	}else{
		a[now]=true;
	}
}
int ans=0;
for(int i=0;i<s+1;i++){
	if(a[i]){
		ans++;
	}
}
cout<<ans<<endl;
	return 0;
}

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

int main(){
  int n, k; cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i, k) ans += p[i];
  
  cout << ans << endl;
  
  return 0;
}


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

const int MAXSIZE = 2000005;
int htop = 0;	// same as hsize
int Heap[MAXSIZE];

void insert(int x);
int extract(void);

void interact(char command[])
{
	switch (command[0])
	{
	case 'I':
	case 'i':
		int k;
		cin >> k;
		insert(k);
		break;
	case 'E':
	case 'e':
		cout << extract() << endl;
		break;
	default:
		break;
	}
}

int main()
{
	char command[32];
	cin >> command;
	while (!(command[0] == 'e' && command[1] == 'n'))
	{
		interact(command);
		cin >> command;
	}
}

void max_heapify(int arr[], int ia)
{
	int left = ia * 2, right = ia * 2 + 1;
	int largest = ia;

	if (left <= htop && arr[left] > arr[ia])
		largest = left;
	if (right <= htop && arr[right] > arr[largest])
		largest = right;

	if (largest != ia)
	{
		swap(arr[ia], arr[largest]);
		max_heapify(arr, largest);
	}
}

void insert(int x)
{
	Heap[++htop] = x;
	int cur = htop;
	int pa = cur / 2;
	while (pa > 0 && Heap[pa] < Heap[cur])
	{
		swap(Heap[pa], Heap[cur]);
		cur = pa;
		pa = pa / 2;
	}
}

inline bool is_h_empty(void)
{
	return htop <= 0;
}

int extract()
{
	if (is_h_empty())
		return (-2147483647 - 1);
	int ret = Heap[1];
	Heap[1] = Heap[htop--];
	max_heapify(Heap, 1);
	return ret;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            List<int> result = new List<int>();

            while (true)
            {

                string inputtext = Console.ReadLine();

                //??\??????????????????"0"????????°????????????????????????
                if (inputtext == "0") break;

                char[] calcdata = inputtext.ToCharArray();

                int sum = 0;

                for (int i = 0; i < calcdata.Length; i++)
                {
                    sum += int.Parse(calcdata[i].ToString());
                }

                result.Add(sum);
            
            }


            foreach(var output in result)
            {
                Console.WriteLine(output);
            }
        }
    
    }

}

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

#define rep(a, b) for(int a  = 0; a < b; a++)
#define repr(a, b) for(int a = b; a >= 0; a++)

using namespace std;

int main(){
    int A, B;
    char op;
    cin >> A >> op >> B;
    if (op == '+') {
        cout << A + B << endl;
    } else {
        cout << A - B << endl;
    }
    return 0;
}

Measured memory_bytes: 764
import sys
import collections

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	dd=[]
	for _ in range(n):
		b , c = tin()
		dd.append([b,c])
	#s = input()
	dist_dict=collections.defaultdict(lambda :0)
	for i,(xa, ya) in enumerate(dd):
		for xb, yb in dd:#[i+1:]:
			if xa==xb and ya == yb:
				continue
			dist_dict[str(xa-xb)+'_'+str(ya-yb)]+=1
			dist_dict[str(xb-xa)+'_'+str(yb-ya)]+=1
	rr=0
	for k in dist_dict:
		rr=max(rr,dist_dict[k])
		#print(k,dist_dict[k])
	return n-int(rr//2)
		
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 41072
import itertools
n=int(input())
p=tuple(input().split())
q=tuple(input().split())
h=[]
for i in range(n):
    h+=str(i+1)
k=list(itertools.permutations(h))
p2=-1
q2=-1
for i in range(len(k)):
    if p==k[i]:
        p2=i
    if q==k[i]:
        q2=i
    if p2 != -1 and q2 !=-1:
        break
print(abs(p2-q2))

Measured memory_bytes: 8052
package main

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

var (
	n       int
	a, b, c int
	ls      []int
)

func rec(i uint, bit, la, lb, lc, ca, cb, cc int) int {
	if int(i) == n {
		if ca == 0 || cb == 0 || cc == 0 {
			return inf
		}
		return 10*(ca+cb+cc-3) + abs(a-la) + abs(b-lb) + abs(c-lc)
	}

	ret := inf
	if bit&(1<<i) == 0 {
		ret = min(ret, rec(i+1, bit, la, lb, lc, ca, cb, cc))
	} else {
		ret = min(ret, rec(i+1, bit, la+ls[i], lb, lc, ca+1, cb, cc))
		ret = min(ret, rec(i+1, bit, la, lb+ls[i], lc, ca, cb+1, cc))
		ret = min(ret, rec(i+1, bit, la, lb, lc+ls[i], ca, cb, cc+1))
	}

	return ret
}

func solve() {
	n = getInt()
	a, b, c = getInt(), getInt(), getInt()
	ls = getIntSlice(n)

	ans := inf
	for bit := 0; bit < (1 << uint(n)); bit++ {
		ans = min(ans, rec(0, bit, 0, 0, 0, 0, 0, 0))
	}

	fmt.Fprintln(wr, ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 640
temp = input().split(" ")
A = int(temp[0])#Aくんの所持枚数
B = int(temp[1])#Bくんの所持枚数
K = int(temp[2])#処理回数K回

def judge(number):
    if number % 2 != 0:
        return number - 1
    else:
        return number
for k in range(K):
    if k % 2 == 0:
        #print("Aのターン")
        A = judge(A)
        A = A / 2
        B = B + A
    else:
        #print("Bのターン")
        B = judge(B)
        B = B / 2
        A = A + B
print(str(int(A))+" "+str(int(B)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define P pair<int, int>

using namespace std;
const int INF=1e5;

int main(){
  int n, r, l, r_s, l_s;
  string s;
  cin >> n;
  cout << 0 << endl;
  cin >> s;
  if(s=="Vacant")return 0;
  r = 0;
  r_s = (s=="Male"?0:1);
  cout << n-1 << endl;
  cin >> s;
  if(s=="Vacant")return 0;
  l = n-1;
  l_s = (s=="Male"?0:1);
  for(int i=0;i<18;i++){
    int mid = (l+r)/2, mid_s;
    cout << mid << endl;
    cin >> s;
    if(s=="Vacant")return 0;
    mid_s = (s=="Male"?0:1);
    if(mid_s^r_s^((mid-r)%2)){
      l=mid;
      l_s=mid_s;
    }
    else{
      r=mid;
      r_s=mid_s;
    }
  }
  return 0;
}



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

int H, W;
int wall;
int M[102][102];
bool visited[102][102];

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

bool isInField(int x, int y) {
  return 0<=x&&x<=W+1 && 0<=y&&y<=H+1;
}

void dfs(int x, int y){

  visited[y][x] = true;

  for(int i=0; i<6; i++) {
    int nx = x+dx[y%2][i], ny = y+dy[y%2][i];
    if(isInField(nx, ny)) {
      if(visited[ny][nx]) continue;
      if(M[ny][nx]) wall ++;
      else dfs(nx, ny);
    }
  }
}

int main(){

  fill(M[0], M[102], 0);
  fill(visited[0], visited[102], false);

  cin >> W >> H;

  for(int i=1; i<=H; i++) {
    for(int j=1; j<=W; j++) {
      cin >> M[i][j];
    }
  }
  
  wall = 0; dfs(0, 0);
  cout << wall << endl;
  
  return 0;
}

Measured memory_bytes: 1452
n, k = gets.chomp.split(' ').map(&:to_i)
h = []

(1..n).each do
  h.push(gets.chomp.to_i)
end

h.sort!

ans = h[k-1] - h[0]
(1..h.size-k).each do |i|
  diff = h[i+k-1] - h[i]
  ans = diff if ans > diff
  break if ans == 0
end

puts ans


Measured memory_bytes: 3704
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <climits>
#include <algorithm>

using namespace std;

const int len = 100010;
char s[len];
int n,a[30];

int main() {
    //freopen("test.in","r",stdin);
    scanf("%s",s);
    n = strlen(s);
    bool flag = true;
    memset(a,0,sizeof(a));
     for (int i=0;i<len;i++) a[s[i]-'a']++;
     for (int i=0;i<26;i++) {
         if (a[i]>1) flag = false;
     }
     if (flag) cout << "yes" << endl;
       else cout << "no" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const LL INF=1<<17;

vector<LL> fact;
vector<LL> inver(200001);

LL combi(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}

LL hcombi(int n,int r){
    return combi(n+r-1,r); 
}

LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}

void set_combi(){
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<=200000;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[200000]=fpow(fact[200000],mod-2);
    for(int i=199999;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
}




int main(){
    int N,K;
    cin >> K >> N;
    set_combi();
    for(int k=2;k<=2*K;k++){
        int p=min(k,2*K+2-k)/2;
        LL ret=0;
        if(k%2){
            for(int q=0;q<=p;q++){
                ret+=combi(p,q)*fpow(2,q)%mod*hcombi(K+q-2*p,N-q);
                ret%=mod;
            }
        }
        else{
            for(int q=0;q<=p-1;q++){
                ret+=combi(p-1,q)*fpow(2,q)%mod*(hcombi(K+q-2*p+1,N-q-1)+hcombi(K+q-2*p+1,N-q));
                ret%=mod;
            }
        }
        cout << ret << endl;
    }
    return 0;
}



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

int main() {
  int L,R,d;
  cin >> L;
  cin >> R;
  cin >> d;
  
  
  int X = 0;
  for(int i =1; i <= L; i++){
    if(L >= d){
    if(i%d == 0){
    X++;
    }
  }
  }
  
  int Y = 0;
  for(int i= 1 ; i <= R; i++){
    if(R >= d){
    if(i%d == 0){
    Y++;
    }
  }
  }

  if(L%d == 0){
  Y = Y + 1; 
  }

  cout << Y - X << endl;
  
}


Measured memory_bytes: 3672
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
int n;
int main() {
    scanf("%d",&n);
    int ans=2e9;
    LL sum=0;
    for (int i=1;i<=n;i++) {
	int x,y;
	scanf("%d%d",&x,&y);
	if (x>y) ans=min(ans,y);
	sum+=x+y;
    }
    if (ans==2e9) {
	printf("0\n");
	return 0;
    }
    sum=sum/2-ans;
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
 
#define F(i, a) for (int i = 0; i < (a); i++)
#define Fd(i, a) for (ll i = (a)-1; i >= 0; i--)
#define Fs(i, a, j) for (ll i = (j); i < (a); i++)
#define deb(x) cout << #x << " " << x << endl;
#define debs(x) cout << #x << " " << x << " ";
#define deba(x) for (auto _i:x) cout << _i << " "; cout << endl;
#define ms(a) memset(a,0,sizeof(a));
#define ll long long
#define mp make_pair
#define eb emplace_back
#define FastOpen freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define int long long
//int power(int x,int p){if(p==0)return 1;if(p==1)return x;if(p%2)return x*power(x,p-1);int y=power(x,p/2);return y*y;}
/*
*/

//const int INF = 1e9+7;

void solve() {
    int n,x,t; cin >> n >> x >> t;
    cout << ((n+x-1)/x)*(t) << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    FastOpen
    int t; t=1;
    while (t--) solve();
}





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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int gcd(int a, int b) {
    return b==0?a:gcd(b, a%b);
}

int main() {
	cin.tie(0);
	
	int a, b;
	
	cin>>a>>b;
	
	cout<<gcd(a, b)<<endl;

	return 0;
}



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

using namespace std;

const int MOD = 1e9 + 7;

inline int add (int a, int b) { return (1LL * a + b) % MOD; }

struct BIT {
  vector <int> ft;
  int n;
  BIT (int n): n(n + 10) {
    ft.resize(n + 10, 0);
  }
  void update (int pos, int var) {
    pos++;
    while (pos < n) {
      ft[pos] = add(ft[pos], var);
      pos += pos & -pos;
    }
  }
  int get (int pos) {
    pos++;
    int ret = 0;
    while (pos) {
      ret = add(ret, ft[pos]);
      pos -= pos & -pos;
    }
    return ret;
  }
};

int main () {
  int n, k;
  cin >> n >> k;
  vector <int> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  BIT dp(k);
  dp.update(0, 1);
  dp.update(1, MOD - 1);
  for (int i = 1; i <= n; i++) {
    for (int c = k - 1; c >= 0; c--) {
      int from = c + 1, to = c + min(a[i], k - c);
      int val = dp.get(c);
      dp.update(from, val);
      dp.update(to + 1, MOD - val);
    }
  }
  cout << dp.get(k) << endl;
  return (0);
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

void solve(std::string S) {
    int N = S.size();
    vector<int> mi(S.size() + 1);

    int c = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '<') {
            c++;
            mi[i + 1] = max(c, mi[i + 1]);
        } else {
            c = 0;
        }
    }

    c = 0;
    for (int i = S.size() - 1; i >= 0; i--) {
        if (S[i] == '>') {
            c++;
            mi[i] = max(c, mi[i]);
        } else {
            c = 0;
        }
    }
    long long ans = 0;
    for(int i = 0 ; i < S.size()+1 ; i++)
        ans += mi[i];
    cout << ans << endl;
}

int main() {
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3332
#include <iostream>

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;


int main(){
  int n, d, x;
  cin >> n;
  cin >> d >> x;
  int ans = 0;
  rep(i, n){
    int a;
    cin >> a;
    int tmp = 1;
    while(tmp <= d){
      tmp += a;
      ans++;
    }
  }
  cout << ans+x << endl;
  return 0;
}


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

using namespace std;

string s;

int main() {
    int n,k;

    cin>>n>>k;

    cin>>s;
    k--;
    for(int i=0;i<s.size();i++){
        if(i==k){
            //cout<<s[i]+32;
            printf("%c",s[i]+32);
        }else{
            cout<<s[i];
        }
    }
    cout<<endl;

    return 0;
}




Measured memory_bytes: 256
import math
import collections
N = int(input())
# N!の約数の個数を10**9+7で割ったあまりを出す
nums = [i for i in range(2, N + 1)]


def prime_factorization(num):
    sqrt_num = math.sqrt(num)
    prime_numbers = []
    for i in range(2, int(sqrt_num) + 1):
        # print(num)
        while num % i == 0:
            # print(num)
            num = num / i
            prime_numbers.append(i)
    if num != 1:
        prime_numbers.append(int(num))

    return prime_numbers


# print(nums)
nums_counter = {}
for num in nums:
    prime_numbers = prime_factorization(num)
    # print(prime_numbers)
    for prime_num in prime_numbers:
        # print(nums_counter)
        # print(prime_num in nums_counter)
        if prime_num in nums_counter:
            nums_counter[prime_num] += 1
        else:
            nums_counter[prime_num] = 1

ans = 1
for key, value in nums_counter.items():
    ans *= (value + 1)
    ans %= 10**9 + 7

print(ans)


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    int n,a,b;
    cin >> n >> a >> b;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int num = i;
        int sum  = 0;
        while (num) {
            sum += num % 10;
            num /= 10;

        }
        if (sum >= a && sum <= b) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/// 11:57 AM 02/05/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

template<typename T>
void ContainerError(T &v);

ll powmod(ll base, ll exp, ll MOD);

ll mpow(ll base, ll exp);

ll gcd(ll a, ll b);
ll sol(ll a,ll b,ll n) {
    ll ans = (a*(b-1))/b;
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll a,b,n;
    cin >> a >> b >> n;
    if(n<b) {
        ll ans = (a*n)/b;
        cout<<ans;
        return 0;
    }
    else if(n==b) {
        ll ans = (a*(b-1))/b;
        cout << ans;
        return 0;
    }
    
    cout << sol(a,b,n) << endl;
    return 0;
}

template<typename T>
void ContainerError(T &v) {
    cout << "{";
    for (auto &x:v) { cout << x << ','; }
    cout << "}" << endl;
    return;
}

ll powmod(ll base, ll exp, ll MOD) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return (res % MOD);
}

ll mpow(ll base, ll exp) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base);
        base = (base * base);
        exp /= 2;
    }
    return (res);
}

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }



Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[30], b[30], c[30];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int j = 0; j < n; j++) {
		cin >> b[j];
	}
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (i > 0) if (a[i - 1] == a[i] - 1) ans += c[a[i - 1] - 1];
		ans += b[a[i] - 1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int m_min(char *num);
int m_max(char *num);

int main(void)
{
    int n;
    char str[8];
    int i;
    int min,max;

    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%s", str);
        min = m_min(str);
        //printf("<%d>", min);
        max = m_max(str);
        //printf("<%d>", max);
        printf("%d\n", max - min);
    }

    return (0);
}
int m_min(char *num)
{
    int i,j;
    int temp;

    for (i = 0; i < 8; i++){
        for (j = 7; j >= 0; j--){
        
            if (num[j] < num[j - 1]){
                temp = num[j];
                num[j] = num[j - 1];
                num[j - 1] = temp;
            }
        }
    }
    return (atoi(num));
    
}
int m_max(char *num)
{
    int i,j;
    int temp;

    for (i = 0; i < 8; i++){
        for (j = 0; j < 8; j++){
            if (num[j + 1] > num[j]){
                temp = num[j];
                num[j] = num[j + 1];
                num[j + 1] = temp;
            }
        }
    }
    return (atoi(num));
}


Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  string s;
  cin >> n >> s;
  string ans="";
  for(int i=0;i<s.size();i++){
    ans+=char((s.at(i)+n-65)%26+65);
//    cout << (s.at(i)+n-65)%26+65 << '/';
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
//#define sort(x) sort(x.begin(), x.end())
using namespace std;
ll power(ll a, ll b, ll m)
{
    if(b == 0)
        return 1;
    ll x = power(a,b/2,m);
    x = (x*x)%m;
    if(b%2 == 1)
        x = (x*a)%m;
    return x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,ans = 0, cnt = 0, x = 0,y;
    cin>>n;
    ll c[n];
    for(i=0;i<n;i++)
        cin>>c[i];
    sort(c,c+n);
    reverse(c,c+n);
    cnt = 1;
    ll M = 1e9+7;
    for(i=0;i<n;i++)
    {
        y = x;
        x = (x + cnt)%M;
        cnt = (cnt*2)%M;
        ans = (ans + ((x*c[i])%M)*power(2,n-i-1,M))%M;
        x = (x + y)%M;
    }
    ans = (ans*power(2,n,M))%M;
    cout<<ans;
    return 0;
}


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

bool isprime[1299710];

void eratos(int n){
  
  for(int i=0 ; i <= n ; i++){
    isprime[i]=true;    
  }
  isprime[0]=isprime[1]=false;
  for(int i=2 ; i <= sqrt(n) ; i++){
    if(isprime[i]){
      int  j=i+i;
      while(j <= n){
	isprime[j]=false;
	j=j+i;
      }
    }
  }
}

int main(){
  
  int k;
  int prime1,prime2;

  eratos(1299709);

  while(1){
    
    cin >>k;
    if(k==0)break;
    
    if(isprime[k]){
      cout <<"0"<<endl;
    }else{
      for(prime1=k+1 ; !isprime[prime1] ; prime1++);
      for(prime2=k-1 ; !isprime[prime2] ; prime2--);
      cout <<prime1-prime2<<endl;;
    }
 
  }
 
  return 0;
}

Measured memory_bytes: 2428
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
const int INF = 1001001001;

int main()
{
    int n;
    in n;
    vector<string> s(n);
    rep(i,n)in s[i];
    int m;
    in m;
    vector<string> t(m);
    rep(i,m)in t[i];

    vector<int> a(n);
    rep(i,n)
    {
        rep(j,n)
        {
            if(s[i]==s[j])a[i]++;
        }

        rep(j,m)
        {
            if(s[i]==t[j])a[i]--;
        }
    }
    sort(a.begin(),a.end());
    if(a[n-1]>0)cout<<a[n-1]<<endl;
    else cout<<0<<endl;
}


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

using namespace std;

int main(void)
{
	string s;
	int zcnt=0,ocnt=0;
	int cnt;

	cin>>s;

	for(int i=0;i<s.size();i++){
			if(s[i]=='0') zcnt++;
			if(s[i]=='1') ocnt++;
	}

	cnt=min(zcnt,ocnt)*2;

	cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <regex>
#include <cstdio>
#include <string>

using namespace std;

int main(void) {
  regex re("^(dream|dreamer|erase|eraser)+$");
  string s;
  getline(cin, s);

  if (regex_match(s, re)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return EXIT_SUCCESS;
}



Measured memory_bytes: 39808
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    aa=a*(a-1)/2
    bb=b*(b-1)/2
    print(int(aa+bb))
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ;
    map<string, ll> cnt;
    vector<string> idx;
    
    cin >> N ;
    rep(i, N){
        string inp;
        cin >> inp;
        sort(all(inp));
        idx.pb(inp);
        cnt[inp] ++;
    }
    
    rmsame(idx);
    
    ll ans = 0 ;
    rep(i, idx.size()){
        ll num = cnt[idx[i]] ;
        ans += num * (num-1) ;
    }
    
    cout << ans / 2 << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	cin >> n;
	map < int, int > val;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		val[a[i]];
	}
	for (auto &it : val) {
		it.S = ++cur;	
	}
	int ans = 0;
	for (int i = 1; i <= n; i ++) {
		ans += abs(i - val[a[i]]) % 2;
	}

	assert(ans % 2 == 0);
	cout << ans / 2 << '\n';

   	return Accepted;
}

// B...a

Measured memory_bytes: 23424
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n, k, q;
    cin >> n >> k >> q;
    int a[n + 1];
    memset(a, 0, sizeof a);
    for (int i = 0; i < q; i++) {
        int e;
        cin >> e;
        a[e]++;
    }

    for (int i = 1; i < n + 1; i++) {
        cout << (q - a[i] >= k ? "No" : "Yes") << '\n';
    }


}

Measured memory_bytes: 1024