akhauriyash/Code-Regression huggingface dataset:
def main():
	num = 0

	n = int(input())
	s_list = list(map(int, input().split()))

	_ = input()
	t_list = list(map(int, input().split()))
	for t in t_list:
		if b_search(s_list, t) != -1:
			num += 1
	
	print(num)

def b_search(li, key):
	left = 0
	right = len(li)
	while left < right:
		mid = int((left+right) / 2)
		if li[mid] == key:
			return mid
		elif key < li[mid]:
			right = mid
		else:
			left = mid + 1

	return -1

if __name__ == '__main__':
	main()

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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    ll ans = 0;
    if (a + b <= c * 2) {
        ans += a * x + b * y;
    } else {
        int minv = min(x, y);
        ans += c * minv * 2;
        x -= minv, y -= minv;

        if (x > 0) {
            if (a <= c * 2)
                ans += a * x;
            else
                ans += c * 2 * x;
        } else if (y > 0) {
            if (b <= c * 2)
                ans += b * y;
            else
                ans += c * 2 * y;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N_MAX 100000
void input(int *a, int l, int r) {
	for(int i = l; i <= r; ++i) {
		scanf("%i", &a[i]);
	}
	return;
}
void merge_sort(int *a, int l, int r) {
	int b[N_MAX + 1];
	for(int k = 1; k <= r - l; k *= 2) {
		int s = l, t = l + k;
		while(t <= r) {
			int so = t, to = t + k <= r + 1 ? t + k : r + 1;
			for(int i = s; i < to; ++i) {
				if(a[s] <= a[t]) {
					b[i] = a[s++];
					if(s == so) {
						for(int j = i + 1; j < to; ++j) {
							b[j] = a[t++];
						}
						break;
					}
				} else {
					b[i] = a[t++];
					if(t == to) {
						for(int j = i + 1; j < to; ++j) {
							b[j] = a[s++];
						}
						break;
					}
				}
			}
			s = t;
			t = s + k;
		}
		for(int i = l; i < s; ++i) {
			a[i] = b[i];
		}
	}
	return;
}
int greater_bound(int *a, int l, int r, int k) {
	int s = l, t = r;
	while(s <= t) {
		int m = (s + t) / 2;
		if(a[m] <= k) {
			s = m + 1;
		} else {
			t = m - 1;
		}
	}
	return s;
}
int less_bound(int *a, int l, int r, int k) {
	int s = l, t = r;
	while(s <= t) {
		int m = (s + t) / 2;
		if(a[m] < k) {
			s = m + 1;
		} else {
			t = m - 1;
		}
	}
	return t;
}
int main(int argc, char **argv) {
	int n;
	scanf("%i", &n);
	int a[N_MAX + 1];
	input(a, 1, n);
	int b[N_MAX + 1];
	input(b, 1, n);
	int c[N_MAX + 1];
	input(c, 1, n);
	merge_sort(a, 1, n);
	merge_sort(c, 1, n);
	long long ans = 0LL;
	for(int i = 1; i <= n; ++i) {
		ans += (long long)less_bound(a, 1, n, b[i]) * (long long)(n - greater_bound(c, 1, n, b[i]) + 1);
	}
	printf("%lli\n", ans);
	return 0;
}

Measured memory_bytes: 3264
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){
  // b - c < a < b + c
  llong n;
  cin >> n;

  vector<llong> v(n);
  REP(i,n){
    cin >> v[i];
  }

  SORTV(v);

  
  llong ans = 0;
  for(int i = n - 1; i > 0; --i){
    for(int j = i - 1; j > 0; --j){
      int a = v[i] - v[j];
      int pos = j - distance(v.begin(), upper_bound(ALL(v), a));
      //cout << j << " " << distance(v.begin(), upper_bound(ALL(v), a)) << endl;
      //cout << pos << endl;
      if(pos > 0 ){
        ans += pos;
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int p(int e, int x) {
	if (x == 1)return e;
	else return e*p(e, x - 1);
}

int main(void) {

	int X;
	cin >> X;

	int m = 1;
	for (int i = 2; i <= sqrt(X); i++) {
		for (int j = 2; p(i, j) <= X; j++) {
			m = max(m, p(i, j));
		}
	}

	cout << m;
	return 0;
}

Measured memory_bytes: 256
n=gets.to_i
v=gets.split.map &:to_i
kisu=Hash.new(0)
gusu=Hash.new(0)

v.each_with_index do |e,i|
    if i%2==0
        gusu[e]+=1
    else
        kisu[e]+=1
    end
end

kisu=kisu.sort{|a,b|b[1]<=>a[1]}
gusu=gusu.sort{|a,b|b[1]<=>a[1]}

if gusu.size==1 && kisu.size==1
    if gusu[0][0]==kisu[0][0]
        p n/2
    else
        p 0
    end
else
    if kisu[0][0]!=gusu[0][0]
        p n-kisu[0][1]-gusu[0][1]
    else
        p n-[kisu[1][1].to_i+gusu[0][1],kisu[0][1]+gusu[1][1].to_i].max
    end
end

Measured memory_bytes: 20292
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;

bool ok(int n){
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(n%i==0)cnt++;
	}
	if(cnt==8)return 1;
	return 0;
}


void solve(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	cout<<a+b+c+max(a,max(b,c))*(1<<k)-max(a,max(b,c));

}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
main() {
	int N;
	cin >> N;
	int answer;
	if (N <= 104) answer = 0;
	else if (N <= 134) answer = 1;
	else if (N <= 164) answer = 2;
	else if (N <= 188) answer = 3;
	else if (N <= 194) answer = 4;
	else answer = 5;
	cout << answer << '\n';
	return 0;
}


Measured memory_bytes: 256
fun main() {
    val N = readLine()!!.toInt()
    var ans = 0
    for (n in 1..N) {
        if (n % 2 == 1) {
            var cnt = 0
            for (i in 1..n) {
                if (n % i == 0) {
                    cnt++
                }
            }
            if (cnt == 8) {
                ans++
            }
        }
    }
    println(ans)
}

Measured memory_bytes: 34504
use proconio::input;

fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        hw: [String; h],
    }

    let mut ans = 0;

    for s in 0..1 << h {
        for sw in 0..1 << w {
            let mut black = 0;
            for i in 0..h {
                for j in 0..w {
                    let chars: Vec<char> = hw[i].chars().collect();
                    if s >> i & 1 == 0 && sw >> j & 1 == 0 && chars[j] == '#' {
                        black += 1;
                    }
                }
            }
            if black == k {
                ans += 1
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2196
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
using namespace std;

int main() {
    int N;
    int num;
    int max = 0;
    vector<int> ans;
    cin >> N;
    for(int i = 0; i < N; i++){
        ans.push_back(0);
    }
    for(int i = 0; i < N; i++){
        cin >> num;
        if(num == 1){
            ans[0] = 1;
        }else{
            ans[num-1] = ans[num-2] + 1;
        }
        if(max < ans[num-1]){
            max = ans[num-1];
        }
    }
    
    cout << N-max << endl;
}


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

using namespace std;

int cnt[4];
double p[303][303][303], ev[303][303][303];

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int N, x;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> x;
    ++cnt[x];
  }
  p[cnt[1]][cnt[2]][cnt[3]] = 1;
  for (int c = N; c >= 0; --c)
    for (int b = N; b >= 0; --b)
      for (int a = N; a >= 0; --a) {
        if (a == 0 && b == 0 && c == 0)
          continue;
        if (a + b + c > N)
          continue;
        double p_waste = (double) (N - (a + b + c)) / N;
        double ev_waste = p_waste / (1 - p_waste) + 1;
        ev[a][b][c] += ev_waste * p[a][b][c];
        if (a != 0) {
          double p_go = (double) a / (a + b + c);
          p[a - 1][b][c] += p[a][b][c] * p_go;
          ev[a - 1][b][c] += ev[a][b][c] * p_go;
        }
        if (b != 0) {
          double p_go = (double) b / (a + b + c);
          p[a + 1][b - 1][c] += p[a][b][c] * p_go;
          ev[a + 1][b - 1][c] += ev[a][b][c] * p_go;
        }
        if (c != 0) {
          double p_go = (double) c / (a + b + c);
          p[a][b + 1][c - 1] += p[a][b][c] * p_go;
          ev[a][b + 1][c - 1] += ev[a][b][c] * p_go;
        }
      }
  cout << fixed << setprecision(10) << ev[0][0][0];
}


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

int main() {
    vector<long long int> a5;
    a5.emplace_back(0);
    int i = 1;
    while (true) {
        long long int n = i;
        for (int k = 0; k < 4; k++)
            n *= i;
        i++;
        if (n <= 1000000000000000)
            a5.emplace_back(n);
        else
            break;
    }
    vector<long long int> b5 = a5;
    long long int x;
    cin >> x;
    for (int a = 0; a < a5.size(); a++)
        for (int b = 0; b < b5.size(); b++) {
            if (a5[a]-b5[b] == x) {
                cout << a << " "<< b << endl;
                return 0;
            } else if (-a5[a]-b5[b] == x) {
                cout << -a << " "<< b << endl;
                return 0;
            } else if (a5[a]+b5[b] == x) {
                cout << a << " "<< -b << endl;
                return 0;
            } else if (-a5[a]+b5[b] == x) {
                cout << -a << " "<< -b << endl;
                return 0;
            }
        }
};

Measured memory_bytes: 3188
/***********************************************
 *                   _ooOoo_                   *
 *                  o8888888o                  *
 *                  88" . "88                  *
 *                  (| -_- |)                  *
 *                  O\  =  /O                  *
 *               ____/`---'\____               *
 *             .'  \\|     |//  `.             *
 *            /  \\|||  :  |||//  \            *
 *           /  _||||| -:- |||||-  \           *
 *           |   | \\\  -   * |    |           *
 *           | \_|  ''\---/''  |   |           *
 *           \  .-\__  `-`  ___/-. /           *
 *         ___`. .'  /--.--\  `. . __          *
 *      ."" '<  `.___\_<|>_/___.'  >'"".       *
 *     | | :  `- \`.;`\ _ /`;.`/ - ` : | |     *
 *     \  \ `-.   \_ __\ /__ _/   .-` /  /     *
 *======`-.____`-.___\_____/___.-`____.-'======*
 *                   `=---='                   *
 *^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

             佛祖保佑       永无BUG

   本程序已经经过开光处理，绝无可能再产生bug
 **********************************************/
#include<algorithm>
#include <iostream>
#include  <cstdlib>
#include  <cstring>
#include   <string>
#include   <vector>
#include   <cstdio>
#include    <queue>
#include    <stack>
#include    <ctime>
#include    <cmath>
#include      <map>
#include      <set>
#define ll long long
#define INF 0x3f3f3f3f
#define db1(x) cout<<#x<<"="<<(x)<<endl
#define db2(x,y) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<endl
#define db3(x,y,z) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<", "<<#z<<"="<<(z)<<endl
using namespace std;

int num[200010];

int main(void)
{
    #ifdef test
    freopen("in.txt","r",stdin);
    //freopen("in.txt","w",stdout);
    clock_t start=clock();
    #endif //test

    int n,k;long long sum=0;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&num[i]);
        sum+=num[i];
    }
    if(k>=n)printf("0\n");
    else
    {
        int t=0;
        sort(num,num+n);
        for(int i=n-1;t<k;t++)
        {
            sum-=num[n-1-t];
        }
        printf("%lld\n",sum);
    }

    #ifdef test
    clockid_t end=clock();
    double endtime=(double)(end-start)/CLOCKS_PER_SEC;
    printf("\n\n\n\n\n");
    cout<<"Total time:"<<endtime<<"s"<<endl;        //s为单位
    cout<<"Total time:"<<endtime*1000<<"ms"<<endl;    //ms为单位
    #endif //test
    return 0;
}


// ━━━━━━神兽出没━━━━━━
//      ┏┓       ┏┓
//     ┏┛┻━━━━━━━┛┻┓
//     ┃           ┃
//     ┃     ━     ┃
//     ????━????   ┃
//     ┃           ┃
//     ┃    ┻      ┃
//     ┃           ┃
//     ┗━┓       ┏━┛
//       ┃       ┃
//       ┃       ┃
//       ┃       ┗━━━┓
//       ┃           ┣┓
//       ┃           ┏┛
//       ┗┓┓┏━━━━━┳┓┏┛
//        ┃┫┫     ┃┫┫
//        ┗┻┛     ┗┻┛
//
// ━━━━━━感觉萌萌哒━━━━━━


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll L[90];
int main() {
    //cout.precision(10);
  ll N;
  cin >> N;
  L[0] = 2;
  L[1] = 1;
  for(ll i = 2; i <= N; i++) {
    L[i] = L[i-2] + L[i-1];
  }
  cout << L[N] << endl;
    return 0;
}


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

int main(){

    int n;
    cin>>n;
    int a=0,w=0,t=0,r=0;
    string x;
    for(int i=0;i<n;i++){
        cin>>x;
        if(x[0]=='A'){a++;}
        else if(x[0]=='W'){w++;}
        else if(x[0]=='T'){t++;}
        else {r++;}
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;
    cout<<"TLE x "<<t<<endl;
    cout<<"RE x "<<r;

return 0;
}


Measured memory_bytes: 3628
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = if n <= m then  List.range n `To m else []
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 1_000_000_007
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'
let itoa n = Char.chr (n + Char.code '0')

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (l,r,d) = scan "%d %d %d" Tuple3.make

let () =
  0::(ListL.map (0++100) ~f:(fun i ->
      if l <= i * d && i*d <= r then 1 else 0
    ))
  |> List.sum
  |> Printf.printf "%d\n"


Measured memory_bytes: 5508
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

vector<int> v(3,0);

/* add your algorithm here */

int main() {
  rep(i,3) cin >> v[i];
  sort(v.begin(), v.end());

  int ans = v[2] * 10 + v[1] + v[0];

  cout << ans << endl;
}


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

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

    std::vector<int> R(n);
    for (int i = 0; i < n; i += 1) {
        std::cin >> R[i];
    }

    int max_value = R[1] - R[0];
    int min_value = R[0];
    for (int i = 1; i < n; i += 1) {
        max_value = std::max(max_value, R[i] - min_value);
        min_value = std::min(min_value, R[i]);
    }

    std::cout << max_value << std::endl;

    return 0;
}



Measured memory_bytes: 3560
#include <stdio.h>

int main(void){
    int x, a, b, c, d;
    while(1){
        scanf("%d%d",&a, &b);
        if((c = a+b)==0) break;
        d = 0;
        for(x = 1; x < 5; x++){
            scanf("%d%d", &a, &b);
            if(a + b > c){
                c = a + b;
                d = x;
            }
        }
        printf("%c %d\n", d + 'A', c);
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int n;
    cin >> n;
    set<ll> st;
    rep (i, n) {
        ll x;
        cin >> x;
        if (st.count(x)) st.erase(x);
        else st.insert(x);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 4992
/*左上から文字を置いていくとして, 未確定の場所に置く文字リテラルをA,B,…とおいてみると、各リテラル（変数）が対称な位置に現れるので、同じリテラルに同じ文字(a～z)を割り当てられるか判定する。*/
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int h, w;
string s[100];
int cnt[26];

int main() {
	int i, j;
	
	cin >> h >> w;
	for (i = 0; i < h; i++) cin >> s[i];
	
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			cnt[s[i][j] - 'a']++;
		}
	}
	
	int rCnt4 = ((h / 2) * 2) * ((w / 2) * 2) / 4;
	int rCnt2 = (h % 2) * (w / 2) + (w % 2) * (h / 2);
	int rCnt1 = (h % 2 == 1 && w % 2 == 1);
	
	for (i = 0; i < 26; i++) {
		int x = cnt[i];
		int useNum;
		
		useNum = min(rCnt4, x / 4);
		rCnt4 -= useNum;
		x -= useNum * 4;
		
		useNum = min(rCnt2, x / 2);
		rCnt2 -= useNum;
		x -= useNum * 2;
		
		useNum = min(rCnt1, x);
		rCnt1 -= useNum;
		x -= useNum;
		
		if (x > 0) { cout << "No" << endl; return 0; }
	}
	
	if (rCnt4 > 0 || rCnt2 > 0 || rCnt1 > 0) { cout << "No" << endl; }
	else { cout << "Yes" << endl; }
	return 0;
}

Measured memory_bytes: 256
var dp=[];
for(var i=0;i<=10;i++){
   dp[i]=[];
   for(var j=0;j<=330;j++){
      dp[i][j]=0;
   }
}

var used=[];
for(var i=0;i<=9;i++)used[i]=false;

function bomb(sum,cnt){
   dp[cnt][sum]++;
   cnt++;
   if(cnt==11)return;
   for(var i=0;i<=9;i++){
      if(used[i])continue;
      used[i]=true;
      bomb(sum+i*cnt,cnt);
      used[i]=false;
   }
}

bomb(0,0);

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
arr.forEach(function(v){
   var ns=v.split(" ").map(Number);
   var n=ns[0];
   var s=ns[1];
   var ans=(dp[n][s]==undefined)?0:dp[n][s]
   console.log(ans);
});

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

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

    int ans = INT_MAX;
    int sz = pow(4, N);
    for (int i = 0; i < sz; ++i) {
        vector<int> a,b,c;
        int t = i;
        for (int k = 0; k < N; ++k) {
            int idx = t % 4;
            t /= 4;
            if (idx == 0) { a.push_back(L[k]); }
            if (idx == 1) { b.push_back(L[k]); }
            if (idx == 2) { c.push_back(L[k]); }
        }

        int tmp = 0;
        if (a.empty() || b.empty() || c.empty()) {
            continue;
        }

        tmp += (10 * (a.size() - 1));
        tmp += (10 * (b.size() - 1));
        tmp += (10 * (c.size() - 1));

        int suma = accumulate(all(a),0);
        int sumb = accumulate(all(b),0);
        int sumc = accumulate(all(c),0);

        tmp += (abs(suma - A) + abs(sumb - B) + abs(sumc - C));
        ans = min(ans, tmp);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
N = int(input())
dic = {}
maxi = 0
res = []
for _ in range(N):
    s = input()
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1
    if dic[s] > maxi:
        maxi = dic[s]
for key in dic.keys():
    if dic[key] == maxi:
        res.append(key)

print(*sorted(res), sep='\n')

Measured memory_bytes: 34012
import java.util.*;
class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        System.out.println(((0 <= x - r) && (x + r <= w) && (0 <= y - r) && (y + r <= h)) ? "Yes" : "No");
    }
}

Measured memory_bytes: 17348
#include<bits/stdc++.h>
#include <math.h>
#include <limits.h>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}

int main(void){
  long long int k,i,j;
  long long int m,n;
  cin >> n >> m;

  cout << (1900*m + 100*(n-m))*pow(2,m) << endl;
  return 0;
}




Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <climits>
using namespace std;

// 双対セグメント木 (Dual Segment Tree)
// ref: https://kimiyuki.net/blog/2019/02/22/dual-segment-tree/
template <typename MonoidType, typename OperatorType, class SegFunc>
struct DualSegmentTree {
    int n;
    vector<MonoidType> bottom;
    vector<OperatorType> lazy;
    OperatorType E;

    inline void build(const vector<MonoidType> &v) {
        int m = v.size();
        n = 1; while(n < m) n *= 2;
        bottom = v; bottom.resize(n);
        lazy.resize(n - 1, E);
    }

    DualSegmentTree() {}
    DualSegmentTree(OperatorType E_, vector<MonoidType> v) : E(E_) {
        build(v);
    }

    void update(int a, int b, OperatorType x, int l, int r, int k) {
        if(b <= l or r <= a) return;
        if(a <= l and r <= b) {
            if(k < lazy.size())
                lazy[k] = SegFunc::lazy_update(lazy[k], x);
            else
                bottom[k-n+1] = SegFunc::update(bottom[k-n+1], x);
        }
        else {
            int mid = (l + r) >> 1;
            update(0, n, lazy[k], l, mid, 2*k+1);
            update(0, n, lazy[k], mid, r, 2*k+2);
            lazy[k] = E;
            update(a, b, x, l, mid, 2*k+1);
            update(a, b, x, mid, r, 2*k+2);
        }
    }

    void update(int a, int b, OperatorType x) {
        update(a, b, x, 0, n, 0);
    }

    MonoidType query(int k) {
        MonoidType res = bottom[k];
        for(k = (k+n)>>1; k>0; k>>=1) { // 1-indexed
            res = SegFunc::update(res, lazy[k-1]);
        }
        return res;
    }
};


void DSL_2_D() {
    using Pair = pair<int, int>;
    struct SegFunc {
        static Pair lazy_update(Pair a, Pair b) { return b.second ? b : a; }
        static int update(int x, Pair p) {
            if(p.second == 0) return x;
            return p.first;
        }
    };

    int N, Q; cin >> N >> Q;
    DualSegmentTree<int, Pair, SegFunc> seg(make_pair(0, 0), vector<int>(N, INT_MAX));

    int indexed = 0;
    for(int i=0; i<Q; i++) {
        int q; cin >> q;
        if(q == 0) {
            int s, t, x; cin >> s >> t >> x;
            s -= indexed, t -= indexed, t++;
            seg.update(s, t, make_pair(x, 1));
        }
        if(q == 1) {
            int x; cin >> x; x -= indexed;
            cout << seg.query(x) << endl;
        }
    }
}

void DSL_2_E() {
    struct SegFunc {
        static int update(int a, int b) { return a + b; }
        static int lazy_update(int a, int b) { return a + b; }
    };

    int N, Q; cin >> N >> Q;
    DualSegmentTree<int, int, SegFunc> seg(0, vector<int>(N, 0));
    
    int indexed = 1;
    for(int i=0; i<Q; i++) {
        int query_type; cin >> query_type;
        if(query_type == 0) {
            int s, t, x; cin >> s >> t >> x; t++;
            s -= indexed, t -= indexed;
            seg.update(s, t, x);
        }
        if(query_type == 1) {
            int s; cin >> s;
            s -= indexed;
            cout << seg.query(s) << endl;
        }
        // seg.dump();
    }    
}

int main() {
    // DSL_2_D();
    DSL_2_E();
}



Measured memory_bytes: 4128
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const int inf = 1e9;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

int n;
string s;
ll h[MAXN], p = 53, pp[MAXN];
ll h2[MAXN], p2 = 29, pp2[MAXN];
ll h3[MAXN], p3 = 59, pp3[MAXN];

ll getH(int l, int r) {
	ll H = h[r];
	if (l > 0) H = (H - h[l - 1] + mod) % mod;
	H = (H * pp[n - r - 1]) % mod;
	return H;
}

ll getH2(int l, int r) {
	ll H = h2[r];
	if (l > 0) H = (H - h2[l - 1] + mod) % mod;
	H = (H * pp2[n - r - 1]) % mod;
	return H;
}

ll getH3(int l, int r) {
	ll H = h3[r];
	if (l > 0) H = (H - h3[l - 1] + mod) % mod;
	H = (H * pp3[n - r - 1]) % mod;
	return H;
}


bool check(int len) {
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
		    if (i + len - 1 >= j) continue;
		    if (j + len - 1 >= n) continue;
			if (getH(i, i + len - 1) == getH(j, j + len - 1) && getH2(i, i + len - 1) == getH2(j, j + len - 1) && getH3(i, i + len - 1) == getH3(j, j + len - 1)) return 1;
		}
	}
	return 0;
}

int main() {
	//freopen(NAME".in", "r", stdin);
	//freopen(NAME".out", "w", stdout);
		
	cin >> n >> s;
	pp[0] = 1;
	pp2[0] = 1;
	pp3[0] = 1;
	for (int i = 1; i <= n; i++) {
		pp[i] = (pp[i - 1] * p) % mod;
	}
	h[0] = (s[0] - 'a' + 1);
	h3[0] = h2[0] = h[0];
	for (int i = 1; i < n; i++) {
		h[i] = (h[i - 1] + pp[i] * (s[i] - 'a' + 1)) % mod;
	}
	for (int i = 1; i <= n; i++) {
		pp2[i] = (pp2[i - 1] * p2) % mod;
	}
	for (int i = 1; i < n; i++) {
		h2[i] = (h2[i - 1] + pp2[i] * (s[i] - 'a' + 1)) % mod;
	}
	for (int i = 1; i <= n; i++) {
		pp3[i] = (pp3[i - 1] * p3) % mod;
	}
	for (int i = 1; i < n; i++) {
		h3[i] = (h3[i - 1] + pp3[i] * (s[i] - 'a' + 1)) % mod;
	}


	int l = 1, r = n, res = 0;
	while (l <= r) {
		int m = (l + r) >> 1;
		if (check(m)) {
			res = max(res, m);
			l = m + 1;
		}
		else r = m - 1;
	}
	cout << res;
	return 0;	
}

Measured memory_bytes: 10496
#include<stack>
#include<queue>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
long long comp(long long n,long long k){
  long long ans=1,i;
  for(i=1;i<=k;i++){
    ans=ans*(n-i+1)/i;
  }
  return ans;
}
int main(){
  map<long long,long long> x;
  long long ans=0,tmp=1,i,a[200010],n,p;
  string s;
  scanf("%lld %lld\n",&n,&p);
  cin >> s;
  if(p==2 || p==5){
    for(i=0;i<s.size();i++){
      if((s[i]-'0')%p==0){
        ans+=i+1;
      }
    }
    printf("%lld\n",ans);
    return 0;
  }
  reverse(s.begin(),s.end());
  a[0]=0;
  for(i=0;i<s.size();i++){
    a[i+1]=(a[i]+(s[i]-'0')*tmp)%p;
    tmp=tmp*10%p;
  }
  vector<long long> b;
  for(i=0;i<=s.size();i++){
    if(x[a[i]]==0){
      b.push_back(a[i]);
    }
    x[a[i]]++;
  }
  for(i=0;i<b.size();i++){
    ans=ans+comp(x[b[i]],2);
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define int long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define pii pair<int, int>
#define piii pair<int, pair<int, int>>
#define f first
#define s second
#define all(a) a.begin(), a.end()
#define endl '\n'
#define boost                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
#define file                          \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define N 2005
#define mod 1000000007
#define inf 1e17
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout << #x << " " << x << endl;
#define debug2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define debug3(x, y, z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " " << z << endl;
#define ub upper_bound
#define lb lower_bound

/*ll mod=1e9+7;
ll powi(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1){ans*=a;ans%=mod;}
        a*=a;a%=mod;
        n>>=1;

    }
    return ans;
}*/
int connected;
int root[500005], sz[500005];

void init(int n)
{
    for (int i = 1; i <= n; i++)
    {
        root[i] = i;
        sz[i] = 1;
    }
    connected = n;
}

int rt(int k)
{
    while (k != root[k])
    {
        root[k] = root[root[k]];
        k = root[k];
    }
    return k;
}

void merge(int u, int v)
{
    int rt1 = rt(u);
    int rt2 = rt(v);

    if (rt1 == rt2)
        return;

    connected--;

    if (sz[rt1] > sz[rt2])
        swap(rt1, rt2);

    sz[rt2] += sz[rt1];
    sz[rt1] = 0;
    root[rt1] = root[rt2];
}

int32_t main()
{
    // boost

    int t=1;
    //cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        init(n);
        for(int i=0;i<m;i++)
        {
            int x,y;
            cin>>x>>y;
            merge(x,y);
        }
        int ans=0;
        for (int i = 1; i <= n; i++)
            ans=max(ans,sz[root[i]]);
        cout << ans<<endl;
    }

    //cout<<"conn"<<connected<<endl;
}


Measured memory_bytes: 6716
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <utility>
#include <unordered_set>
#include <math.h>
#include <set>
#include <queue>
using namespace std; 

typedef long long ll;

int main()  {  
    int n = 0;
    ll ans = 0;
    cin >> n;
    for(int i = 1; i <= n; i++){
        if(i % 3 != 0 and i % 5 != 0){
            ans += i;
        }
    }
    cout << ans << endl;

    return 0;  
}  

Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int t = scan.nextInt();
		System.out.println((t/a)*b);
	}
    public static void main(String[] args) {
    	new Main().run();
    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;

int main() {
    int K;
    cin >> K;
    int Odd, Even;
    Odd = (K + 1) / 2;
    Even = K / 2;
    cout << Odd * Even << endl;
}

Measured memory_bytes: 256
import fractions
from functools import reduce


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


N, X = map(int, input().split())
x = [int(i) for i in input().split()]

x.append(X)
x.sort()

d = []
for i in range(N):
    d.append(x[i+1] - x[i])

print(gcd_list(d))

Measured memory_bytes: 16304
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
using g= vector<vector<pair<ll,ll>>>;
g tree;
vector <ll> a;
// v は現在見ている頂点, p は v の親
void dfs(ll v, ll p,ll c) {
  a[v]=c;//色を入れる
  for (auto nv : tree[v]) {//tree[v]の最初から最後まで
    if (nv.first == p) continue;  // これがツリー探索で一般的な書き方
    if(nv.second%2==1) dfs(nv.first,v,1-c);//重みが奇数なら今とは違う色
    else dfs(nv.first,v,c);
  }
}

int main() {
  ll n;
  cin >>n;
  tree.assign(n,vector<pair<ll,ll>>());//n個を初期化
  for(ll i=0;i<n-1;i++){
    ll u,v,w;
    cin >>u>>v>>w;
    u--;v--;
    tree[u].push_back(make_pair(v,w));
    tree[v].push_back(make_pair(u,w));
  }
  a.assign(n,0);//n個を0で初期化
  ll root=0;
  dfs(root,-1,1); // root の親はいないので -1
  for(auto i:a) cout <<i<<endl;
}


Measured memory_bytes: 9984
n,k=map(int,input().split())
fact=[1]
for i in range(1,2*n):
  fact.append((fact[i-1]*(i+1))%(10**9+7))
factinv=[]
for i in range(n):
  factinv.append(pow(fact[i],10**9+5,10**9+7))
if k==1:
  print((n*(n-1))%(10**9+7))
elif k>=n-1:
  print((fact[2*n-2]*factinv[n-1]*factinv[n-2])%(10**9+7))
else:
  ans=1
  for i in range (k):
    ans=(ans+fact[n-1]*factinv[i]*factinv[n-i-2]*fact[n-2]*factinv[i]*factinv[n-i-3])%(10**9+7)
  print(ans)

Measured memory_bytes: 26820
#include <stdio.h>

int main(void) {
	unsigned long T,time=0, sum = 0;
	int N, t[200000], i, sw = 1, n = 1;

	scanf("%d %d", &N, &T);
	for (i = 0; i<N; i++) {
		scanf("%d", &t[i]);
	}
	/*printf("N:%d T:%d\n", N, T);
	for (i = 0; i < N; i++) {
	printf("t[%d]:%d ", i, t[i]);
	if (i == N - 1) printf("\n");
	}*/
	do {
		if (sw) {
			for (i = 1; i <= T; i++) {
				//printf("%d\n", i);
				time++;
				sum++;
				if (t[n] == time) {
					i = 0;
					n++;
				}
			}
			if (n == N)n++;
			else sw = 0;
		}
		else {
			time++;
			if (t[n] == time) {
				sw = 1;
				n++;
			}
		}
	}while (n <= N);

	printf("%d\n", sum);

	return 0;
}


Measured memory_bytes: 896
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

calc :: Int -> Int -> Int
calc a n
  | a `mod` 2 == 0 = calc (a `div` 2) (n + 1)
  | otherwise = n

main = do
  n <- getInt
  as <- getIntList
  print $ sum (map (\x -> calc x 0) as)


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

class Point {
  public:
    int x;
    int y;
};

int main() {
    
    int x, y;
    cin>>x>>y;
    
    Point top_right, under_left;
    top_right.x = 1;
    top_right.y = 1;
    under_left.x = 0;
    under_left.y = 0;
    
    for (int i = 0;; i++) {
        if (top_right.x > x && top_right.y > y && under_left.x <= x && under_left.y <= y) {
            cout<<(i % 3) + 1<<endl;
            break;
        }
        
        if (i % 4 == 0) top_right.x += top_right.y - under_left.y;
        else if (i % 4 == 1) top_right.y += top_right.x - under_left.x;
        else if (i % 4 == 2) under_left.x += under_left.y - top_right.y;
        else under_left.y += under_left.x - top_right.x;
    }

    return 0;
}



Measured memory_bytes: 3132
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)
#define RFOR(it,c) for(__typeof((c).rbegin())it=(c).rbegin(); it!=(c).rend();++it)
#define exist(c, v) (find((c).begin(), (c).end(), (v)) != (c).end())

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
	return os;
}

inline int stoi(const string& s) {
	istringstream is(s);
	int res;
	is >> res;
	return res;
}

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

	const int mod = 256;

	int m;
	cin >> m;

	map<string, set<int> > memo;
	for(int i = 0; i < m; ++i) {
		int l, r;
		string name;
		cin >> name >> l >> r;

		set<int> s;
		for(int i = l; i <= r; ++i)
			s.insert(i);

		memo[name] = s;
	}


	int n;
	cin >> n;

	stack<set<int> > sta;
	for(int i = 0; i < n; ++i) {
		string e;
		cin >> e;

		if(memo.count(e))
			sta.push(memo[e]);

		else if(e == "+" || e == "-" || e == "*" || e == "/") {
			const set<int> b = sta.top();
			sta.pop();

			const set<int> a = sta.top();
			sta.pop();

			set<int> result;
			FOR(it, a) {
				FOR(it2, b) {
					if(e == "+")
						result.insert(((*it) + (*it2)) % mod);

					else if(e == "-")
						result.insert(((*it) - (*it2) + mod) % mod);

					else if(e == "*")
						result.insert(((*it) * (*it2)) % mod);

					else {
						if((*it2) == 0) {
							cout << "error" << endl;
							return EXIT_SUCCESS;

						}

						result.insert((*it) / (*it2));
					}
				}
			}

			sta.push(result);
		}

		else {
			set<int> s;
			s.insert(stoi(e));
			sta.push(s);
		}
	}

	cout << "correct" << endl;
	return EXIT_SUCCESS;
}

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    while(true) {
        int N;
        std::cin >> N;
        if(N == 0) break;

        std::vector<int> A(N);
        REP(i, N) {
            std::cin >> A[i];
        }
        auto ave = accumulate(ALL(A), 0LL) / A.size();

        auto ans = 0;
        REP(i, N) {
            if(A[i] <= ave) ans++;
        }
        std::cout << ans << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>


using namespace std;

int main(){
    int N; cin >> N;
    vector<float> x(N);
    vector<string> u(N);

    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> u[i];
    }

    double ans = 0;

    for (int i = 0; i < N; i++)
    {
        if (u[i] == "BTC")
        {
            ans += x[i]*380000.0;
        }else
        {
            ans += x[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
k = [-1 for i in range(N)]
ng = 0
for i in range(M):
  s,c = map(int,input().split())
  if k[s-1] == -1:
    k[s-1] = c
  elif k[s-1] != c:
    ng = 1
    break
if k[0] == 0:
  if N != 1:
    ng = 1
if ng==1:
  print("-1")
else:
  if k[0] == -1:
    if N == 1:
      k[0] = 0
    else:
      k[0] = 1
  for i in range(N):
    if k[i] == -1:
      k[i] = 0
  print("".join(map(str,k)))



Measured memory_bytes: 3064
k,n=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
p=0
for i in range(1,n):
    if a[i]-a[i-1]>p:
        p=a[i]-a[i-1]
if k-p>max(a)-min(a):
    print(max(a)-min(a))
else:
    print(k-p)

Measured memory_bytes: 26444
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define Rep(i,n) for(int i=1;i<=(n);++i)
using LL = long long;
using ULL = unsigned long long;

int main()
{
	LL a, b, n;
	cin >> a >> b >> n;
	if(b == 1) {
		puts("0");
		return 0;
	}
	LL x = min(b-1, n);
	cout << a * x / b << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using PP = pair<long, long>;
const int INF = 1e9;
template <class T> T Next() { T buf; cin >> buf; return buf; }

int n, k;
int main() {
  cin >> n >> k;
  int p = 2 * k + 1;
  cout << (n + p - 1) / p << endl;
}

Measured memory_bytes: 256
using System;

class ITP1_7_C
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int r = int.Parse(s[0]);
        int c = int.Parse(s[1]);

        int[,] sheet = new int[r + 1, c + 1];

        for (int i = 0; i < r; i++)
        {
            string[] input = Console.ReadLine().Split(' ');

            for (int j = 0; j < c; j++)
            {
                sheet[i, j] = int.Parse(input[j]);
                sheet[i, c] += sheet[i, j];
                sheet[r, j] += sheet[i, j];
                sheet[r, c] += sheet[i, j];
            }
        }

        for (int i = 0; i < r + 1; i++)
        {
            for (int j = 0; j < c; j++)
            {
                Console.Write(sheet[i, j] + " ");
            }
            Console.WriteLine(sheet[i, c]);
        }
    }
}



Measured memory_bytes: 15924
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	n := readInt()
	m := make(map[string]bool)
	prev := readString()
	m[prev] = true
	for i := 1; i < n; i++ {
		w := readString()
		if m[w] || prev[len(prev)-1] != w[0] {
			println("No")
			return
		}
		m[w] = true
		prev = w
	}
	println("Yes")
}

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


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

td = [[[0 for i in range(10)] for j in range(10)]  for j in range(10)]
sd = [[0 for i in range(10)] for i in range(10)]
fd = [0 for i in range(10)]

for i in range(N):
  s = int(S[i])
  #三桁目の更新
  for q in range(10):
    for r in range(10):
      if sd[q][r] == 1:
        td[q][r][s] = 1
  #二桁目の更新
  for p in range(10):
    if fd[p] == 1:
      sd[p][s] = 1           
  #一桁目の更新
  if fd[s] == 0:
    fd[s] = 1

 
###
c = 0
for i in range(10):
  for j in range(10):
    c += td[i][j].count(1)  
print(c)

Measured memory_bytes: 43884
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
#include<map>
using namespace std;

int N;
int main(){
	cin>>N;
	for(int i=1;;i++){
		if((i*(i+1))/2>=N){
			cout<<i<<endl;
			break;
		}
	}
}

Measured memory_bytes: 256