akhauriyash/Code-Regression huggingface dataset:
//jinhaonan
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
template<class T>inline void read(T &x){
	x=0;char c=getchar();bool f=0;
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';x=(x<<1)+(x<<3)+c-'0',c=getchar());
	x=f?-x:x;
}
template<class T>inline void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>=10)write(x/10);
	putchar(x%10+48);
}
template<class T>inline bool chkmax(T &a,T const &b){
	return a<b?a=b,1:0;
}
template<class T>inline bool chkmin(T &a,T const &b){
	return a>b?a=b,1:0;
}
pair<int,int> a[1<<18];
int main(){
	// freopen("in.txt","r",stdin);
	int n;read(n);
	int m=1<<n;
	for(int i=0;i<m;++i){
		read(a[i].first);
	}
	
	for(int j=0;j<n;++j){
		for(int i=1;i<m;++i)
			if(i>>j&1){
				int k=i^(1<<j);
				if(a[i].first<a[k].first){
					a[i].second=a[i].first;
					a[i].first=a[k].first;
					chkmax(a[i].second,a[k].second);
				}else{
					chkmax(a[i].second,a[k].first);
				}
			}
	}
	int ans=0;
	for(int i=1;i<m;++i){
		chkmax(ans,a[i].first+a[i].second);
		write(ans),putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 5120
a,b,c=list(map(int,input().split()))
mi=min([a,b,c])
ma=max([a,b,c])
mid=a+b+c-mi-ma
ans=0

if (mid-mi)%2==1:
  ans+=1
  ma+=1
  mi+=1
  ans+=(mid-mi)/2
  ans+=ma-mid
else:
  ans+=(mid-mi)/2
  ans+=ma-mid

print(int(ans))
           


Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

#define N 10000

int isPrime(int);

int main() {
  int i,x,count = 0;
  int data[N];
  
  scanf("%d",&x);
  for(i = 0; i < x; i++) {
    scanf("%d",&data[i]);
  }

  for(i = 0; i < x; i++) {
    count += isPrime(data[i]);
  }

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

  return 0;
}

int isPrime(int a) {
  int i = 3;
  if(a == 2) {
    return 1;
  }
  
  if(a < 2 || a % 2 == 0) {
      return 0;
  }
  while(i <= sqrt(a)) {
    if(a % i == 0) {
      return 0;
    }
    i = i + 2;
  }

  return 1;
}



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

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;


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

    double ans = 0.0;

    rep(i, n) {
        if(u[i] == "BTC") {
            ans += 380000 * x[i];
        } else {
            ans += x[i];
        }
    }
    
    cout << ans << endl;



    return 0;

}

Measured memory_bytes: 256
import numpy as np
row = input().split()
N = int(row[0])
M = int(row[1])
row2 = [input().split() for i in range(M)]
f = np.vectorize(int)
a = f(row2)
for i in range(1, N+1):
    count = 0
    for j in range(M):
        for k in range(2):
            if i == a[j][k]:
                count += 1
    print(count)


Measured memory_bytes: 12460
n,a,b = map(int,input().split())
h = [int(input()) for _ in range(n)]
l = 0
r = max(h)

def f(x):
    res = 0
    for i in range(n): res += max(0,(h[i]-b*x+a-b-1))//(a-b)
    return res <= x

while l+1 < r:
    m = (l+r)//2
    if f(m): r = m
    else: l = m
print(r)

Measured memory_bytes: 12952
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x,long long int y) {
	return(x + y-1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int n;
	cin >> n;
	cout << n * n * n;
}

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

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

    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a.at(i);

    sort(a.begin(), a.end(), greater<int>());

    // vector<int> A,B;
    int A=0,B=0;

    if (N%2==0){
        for (int i = 0; i < N; i+=2)
        {
            A += a.at(i);
            B += a.at(i+1);
        }
    }else{
        for (int i = 0; i < N-1; i+=2)
        {
            A += a.at(i);
            B += a.at(i+1);
        }
            A += a.at(N-1);
    }

    cout << A-B << endl;
}


Measured memory_bytes: 256
object Main extends App {
  val Array(n, k) = io.StdIn.readLine().split(' ').map(_.toInt)
  val k2 = k*2
  val end = k2-1
  // 0 ≦ x,y ≦ 2K に圧縮
  val squares = Array.fill(k2)(Array.fill(k2)(0))
  for (i <- 1 to n) {
    val Array(x, y, color) = io.StdIn.readLine().split(' ')
    // 'W'はY方向にKずらした'B'と同値
    squares(x.toInt % k2)((y.toInt + (if (color == "B") 0 else k)) % k2) += 1
  }
  // 計算量削減のために累積和を事前算出
  for {
    i <- 0 to end
    j <- 1 to end
  } squares(i)(j) += squares(i)(j-1)
  for {
    j <- 0 to end
    i <- 1 to end
  } squares(i)(j) += squares(i-1)(j)
  // ex) k = 2    
  //      □ □ ■ ■
  //    k □ □ ■ ■
  //      ■ ■ □ □
  //    0 ■ ■ □ □
  //      0   k 
  val cnt =
    (squares(k-1)(k-1)) +
    (squares(end)(end) - squares(k-1)(end) - squares(end)(k-1) + squares(k-1)(k-1))
  var max = Math.max(cnt, n - cnt)
  for {
    i <- 0 to k-1
    j <- 0 to k-1
  } {
    // ex) k = 2
    //      ■ □ □ ■ 
    //  j+k □ ■ ■ □
    //      □ ■ ■ □
    //    j ■ □ □ ■
    //      i   i+k
    val cnt =
      (squares(i)(j)) +
      (squares(end)(j) - squares(i+k)(j)) +
      (squares(i+k)(j+k) - squares(i+k)(j) - squares(i)(j+k) + squares(i)(j)) +
      (squares(i)(end) - squares(i)(j+k)) +
      (squares(end)(end) - squares(end)(j+k) - squares(i+k)(end) + squares(i+k)(j+k))
    max = Math.max(Math.max(cnt, n - cnt), max)
  }
  print(max)
}


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

#define ASORT(arr, n)          sort(arr,arr+n)
#define SORT(v)             sort(v.begin(), v.end())
#define REV(v)              reverse(v.begin(), v.end())
#define FOR(i, n)           for (int i=0; i<n; i++)
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI                  acos(-1.0)

using namespace std;

typedef long long              ll;
typedef unsigned long long     ull;
typedef vector<int>            vi;

const double eps = 1e-9;


int main()
{
  fastIO();
	ll n , k ,sum=0;
	cin>>n>>k;
	ll arr[n];
	for(int i=0; i<n; i++)
	{
		cin>>arr[i];
	}
	ASORT(arr,n);
	for(int i=0; i<k; i++)
	{
		 sum += arr[i];
	}
	cout<< sum <<'\n';



 return 0;
 }


Measured memory_bytes: 3640
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)
#define vec_all(vec) vec.begin(), vec.end()

// vectorデバッグ
template<typename T>
void dump_vec(vector<T> vec) {
    rep(i, vec.size()) {
        cout << i << ": " << vec[i] << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main() {
    string s;
    cin >> s;
    int cnt = 0;

    char color = s[s.size() - 1];
    reprev(i, s.size()) {
        if (s[i] != color) {
            color = s[i];
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
    public static void Main()
    {
        String[] input = Console.ReadLine().Split();
        long N = long.Parse(input[0]);
        long K = long.Parse(input[1]);
        long[] ans = new long[N];
        for (int i = 0; i < K; i++)
        {
            long d = long.Parse(Console.ReadLine());
            String[] temp = Console.ReadLine().Split();
            for(int j = 0; j < d; j++)
            {
                ans[long.Parse(temp[j]) - 1]++;
            }
        }
        long a = 0;
        for(int i = 0; i < N; i++)
        {
            if (ans[i] == 0) a++;
        }
        Console.WriteLine(a);
    }
}

Measured memory_bytes: 27596
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
#define int long long
const int INF = 1e9 + 228;
const int MAXN = 1e6 + 228;
	vector<int> a, b;
map<pair<int, int>, int> mapa;

int solve(int id) {
	if (id + 1 == a.size()) {
		return a[id];
	}
	if (mapa.count({id, a[id]})) {
		return mapa[{id, a[id]}];
	}
	int x = solve(id + 1) + a[id];
	a[id + 1]++;
	int y = solve(id + 1) + (10 - a[id]);
	a[id + 1]--;
	//print4(id, a[id], x, y);
	return mapa[{id, a[id]}] = min(x, y);
}

int dp[MAXN][2];

signed main()
{
#ifdef LOCAL
    FILE;
#endif
    sh;
	string s;
	cin >> s;
	reverse(all(s));
	for (int i = 0; i < s.size(); i++) {
		a.pb(s[i] - '0');
	}
	a.pb(0);
	dp[a.size() - 1][0] = 0;
	dp[a.size() - 1][1] = 1;
	for (int i = a.size() - 2; i >= 0; i--) {
		int x = dp[i + 1][0] + a[i];
		int y = dp[i + 1][1] + (10 - a[i]);
		dp[i][0] = min(x, y);
		dp[i][1] = min(x + 1, y - 1);
	}
	cout << dp[0][0] << endl;
    return 0;
}


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

import sys

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

N = INT()
S = input()

def bisearch_max(mn, mx, func):
    """ 条件を満たす最大値を見つける二分探索 """

    ok = mn
    ng = mx
    while ok+1 < ng:
        mid = (ok+ng) // 2
        if func(mid):
            # 上を探しに行く
            ok = mid
        else:
            # 下を探しに行く
            ng = mid
    return ok

def calc(m):
    A = {}
    for i in range(N-m+1):
        a = S[i:i+m]
        if a in A:
            # aが2回目以降に出現したindex
            j = A[a]
            # iとjがm以上離れているかどうか
            if i-j >= m:
                return True
        else:
            # aが最初に出現したindex
            A[a] = i
    return False

print(bisearch_max(0, N, calc))


Measured memory_bytes: 9512
'use strict';
(function(stdin) {
  var lines = stdin.toString().split('\n');
  var result = (function(data) {
    return data
    .reduce(function(map,v){
      var animals = v.split(' ');
      switch(true) {
        case animals[0] > animals[1] :
          map[0] += 3;
          return map;
        case animals[0] < animals[1] :
          map[1] += 3;
          return map;
        default:
          map[0] += 1;
          map[1] += 1;
          return map;
      }
    },[0,0]).join(' ');
    
  }(
    lines.slice(0,lines.shift())
  ));
  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 8700
#include <iostream>
#include <cstdint>

using namespace std;

int main(int argc, char const* argv[]) {
	uint64_t N;
	uint64_t cnt = 0;

	cin >> N;

	for (uint64_t i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0)
			cnt += i;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
map<int,ll>ctr;
int main() {
	int n;
	cin >> n;
	ll sum = 0;
	ll num;
	for (int i = 1; i <= n; i++) {
		cin >> num;
		ctr[num]++;
		sum += num;
	}
	ll q,b,c;
	cin >> q;
	while (q--) {
		cin >> b >> c;
		sum = sum - ctr[b]*b + ctr[b]*c;
		ctr[c] += ctr[b];
		ctr[b] = 0;
		cout << sum << "\n";
	}
	return 0;
}

Measured memory_bytes: 9316
#include<iostream>
#include<queue>

#define MAX_N 1000

using namespace std;

int N, M, A, B;
int D[MAX_N];

int solve(){
  deque<int> que;

  int res = 0;

  for(int i=0;i<N;++i){
    if(D[i] >= A){
      que.push_back(i);
    }else{
      break;
    }
  }
  res = que.size();
  
  if(!que.empty() && N-res<M){
    while(!que.empty()){
      if(D[que.back()]<=B){
	que.pop_back();
	res = que.size();
      }else{
	res = que.size();
	que.clear();
      }
    }
  }
  return res;
}

int main(void){

  cin >> N >> M >> A >> B;

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

  cout << solve() << endl;
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;



int main(){
    int a, b, t;
    cin >> a >> b >> t;
    out(t/a*b);
}

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

int main(){
    int i,j;
    char s[100];
    int data[100];
    for(i=0;i<100;i++){
        data[i]=0;
    }
    i=0;

    while( scanf("%s", s) != EOF ){
        if ( s[0] == '+' ){
            data[i-2]=data[i-2]+data[i-1];
            i-=1;
            
        } else if ( s[0] == '-' ){
            data[i-2]=data[i-2]-data[i-1];
            i-=1;
            
        } else if ( s[0] == '*' ){
            data[i-2]=data[i-2]*data[i-1];
            i-=1;
            
        } else {
            data[i] = atoi(s);
            i++;
        }
        /*for(j=0;j<i;j++){
            printf("%d ",data[j]);
        }
        printf("\n");*/
    }
    printf("%d\n",data[0]);
    return 0;
}


Measured memory_bytes: 2044
#include <vector>
#include <iostream>
#include <set>
#include <cstdio>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <algorithm>
#include <limits>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int d[6][8][2] = {
{{2, 0}, {2, 1}, {2, 2}, {2, 3}, {2, 4}, {2, 5}, {2, 6}, {2, 7}},
{{2, 1}, {3, 1}, {4, 2}, {4, 3}, {3, 4}, {2, 4}, {1, 3}, {1, 2}},
{{2, 3}, {3, 3}, {4, 3}, {5, 3}, {3, 6}, {2, 6}, {0, 3}, {1, 3}},
{{3, 7}, {3, 6}, {3, 5}, {3, 4}, {3, 3}, {3, 2}, {3, 1}, {3, 0}},
{{2, 5}, {3, 5}, {5, 3}, {5, 2}, {3, 0}, {2, 0}, {0, 2}, {0, 3}},
{{5, 2}, {4, 2}, {3, 2}, {2, 2}, {1, 2}, {0, 2}, {2, 7}, {3, 7}},
};
int d2[6][2] = {
{0, 2}, {2, 2}, {2, 4}, {4, 2}, {2, 6}, {2, 0}
};
string cmd = "UFRDBL";
char data[6][9] = {
"..rr....",
"..rr....",
"ggyybbww",
"ggyybbww",
"..oo....",
"..oo....",
};
char datab[6][9];
int main() {
    string s;
    cin >> s;
    for (char c: s) {
        int t = 0;
        for (int i = 0; i < cmd.size(); i++) {
            if (c == cmd[i]) t = i;
        }
        copy_n(data[0], 54, datab[0]);
        for (int i = 0; i < 8; i++) {
            int x1 = d[t][i][0], y1 = d[t][i][1];
            int x2 = d[t][(i+2)%8][0], y2 = d[t][(i+2)%8][1];
            datab[x1][y1] = data[x2][y2];
        }
        int x = d2[t][0], y = d2[t][1];
        int dd[4][2] = {{x, y}, {x+1, y}, {x+1, y+1}, {x, y+1}};
        for (int i = 0; i < 4; i++) {
            int x1 = dd[i][0], y1 = dd[i][1];
            int x2 = dd[(i+1)%4][0], y2 = dd[(i+1)%4][1];
            datab[x1][y1] = data[x2][y2];
        }
        copy_n(datab[0], 54, data[0]);
    }
    for (int i = 0; i < 6; i++) {
        printf("%s\n", data[i]);
    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

//question_a
using namespace std;
using ll = long long;
int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = a * c;
	ans = max(ans, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);
	cout << ans << endl;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

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

const int inf=1e9+10;
const int maxn=2e5+10;

vector <int> g[maxn],v[3],c[2];
int n,ans[maxn];

void dfs(int x,int fa,int col){
	c[col].pb(x);
	for(int i=0;i<g[x].size();i++){
		int to=g[x][i];
		if(to!=fa) dfs(to,x,col^1);
	}
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int u,vv;
		scanf("%d%d",&u,&vv);
		u--; vv--;
		g[u].pb(vv);
		g[vv].pb(u);
	}
	dfs(0,-1,0);
	for(int i=1;i<=n;i++) v[i%3].pb(i);
	if(c[0].size()>c[1].size()) swap(c[0],c[1]);
	vector <int> v2,v3;
	if(c[0].size()>=v[2].size()){
		for(int i=0;i<v[2].size();i++)
			v2.pb(v[2][i]);
		for(int i=0;i<v[0].size();i++)
			v2.pb(v[0][i]);
		for(int i=0;i<v[1].size();i++)
			v2.pb(v[1][i]);
	}
	else{
		for(int i=0;i<v[0].size();i++)
			v2.pb(v[0][i]);
		for(int i=0;i<v[1].size();i++)
			v2.pb(v[1][i]);
		for(int i=0;i<v[2].size();i++)
			v2.pb(v[2][i]);
	}
	for(int i=0;i<c[0].size();i++) v3.pb(c[0][i]);
	for(int i=0;i<c[1].size();i++) v3.pb(c[1][i]);
//	for(int i=0;i<n;i++) printf("%d ",v2[i]); printf("\n");
	for(int i=0;i<n;i++)
		ans[v3[i]]=v2[i];
	for(int i=0;i<n;i++) printf("%d ",ans[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 21872
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
String  a= br.readLine();
String  b= br.readLine();
String  c= br.readLine();
String  d= br.readLine();

int n =Integer. parseInt(a);
int k =Integer. parseInt(b);
int x =Integer. parseInt(c);
int y =Integer. parseInt(d);
int z =n-k;

if(k>n){

System. out. println(n*x);
}else{
System. out. println(k*x+y*z);
}
}}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

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

		int count = 0;
		for (int i = a; i <= b; i++) {
			int a5 = i / 10000;
			int a4 = i % 10000 / 1000;
			int a2 = i % 100 / 10;
			int a1 = i % 10;
			if (a5 == a1 && a4 == a2) {
				count++;
			}
		}
		System.out.println(count);

		sc.close();
	}
}

Measured memory_bytes: 22608
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S,ans;
  int N, K,count=0;
  cin >> N >> K;
  vector<int> A(N,0);
  for(int i=0;i<K;i++){
    int d;
    cin >> d;
    for(int j=0;j<d;j++){
      int a;
      cin >> a;
      for(int k=0;k<N;k++){
        if(a == k + 1) A.at(k)++;
      }
    }
  }
  for(int i=0;i<N;i++){
    if(A.at(i) == 0) count++;
  }
  cout << count << endl;
  
}

Measured memory_bytes: 3628
n = int(input())
w = []
for i in range(n):
    a,b = map(int,input().split())
    w.append([a,b])
w.sort(key=lambda x:x[1])
time = 0
for i in range(n):
    time += w[i][0]
    if time > w[i][1]:
        print("No")
        exit()
print("Yes")


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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

template<typename T>
class Union_Find {
private:
  T n;
  vector<T> parent;

public:
  Union_Find(T v){
    n=v;
    parent.resize(n,-1);
  }

  T root(T v){
    if(parent[v]<0)return v;
    return parent[v]=root(parent[v]);
  }
  T size(T v){
    return -parent[root(v)];
  }
  bool connect(T a,T b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(size(a)<size(b)) swap(a,b);
    parent[a]+=parent[b];
    parent[b]=a;
    return true;
  }
  bool same(T a,T b){
    return root(a)==root(b);
  }

};

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll n;
  cin>>n;
  cout<<(n*n*n)<<endl;

  
  
}


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


int N, M;  //N頂点M辺
vector<int> visited;
vector<vector<int>> G;


int main() {
    cin >> N >> M;
    G = vector<vector<int>>(N); // サイズを確保する
    visited = vector<int>(N, 0); // 全頂点を「未訪問」に初期化
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        // 頂点番号を 0-indexed とする
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

     queue<int> que;
     map<int,int> ans;
    int ft=0;

    que.push(ft); // ft を橙色頂点にする
    visited[ft]=1; // 初期条件 (頂点 ft を初期ノードとする)

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]){
            if (visited[nv] != 0) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            visited[nv] = 1;
            que.push(nv);
            ans[nv]=v;
        }
    }
    rep(i,N){
      if(visited[i]==0){
        cout <<"No" << endl;
        return 0;}}
    cout << "Yes" << endl;
    for(int i=1;i<N;i++){cout << ans[i]+1 << endl;}
}

Measured memory_bytes: 14748
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

class UnionFind{
  public:
    //親の番号を格納．親の場合は-(その集合のサイズ)
    vector<int> Parent;
    //親との距離
    vector<int> Distance;
    //作るときはParentの値をすべて-1にする
    UnionFind(int N){
      Parent = vector<int>(N,-1);
      Distance = vector<int>(N,0);
    }

    //親を求める
    int find(int x){
      if(Parent[x] < 0) return x;
      //親の紐づけを変更
      int p = Parent[x];
      int fp = find(Parent[x]);
      int d = Distance[p];
      if(p != fp) Distance[x] += d; 
      return Parent[x] = find(Parent[x]);
    }

    //xの属する集合のサイズを取ってくる
    int size(int x){
      return -Parent[find(x)];
    }

    //2点間の距離を計算
    //xからみてy
    int getDistance(int x,int y){
      find(x);
      find(y);
      return  Distance[y] - Distance[x];
    }

    //xとyの属する集合を併合
    //併合できたらtrue，すでに併合していたらfalse 
    bool unite(int x, int y, int d){
      //xとyを直接つけない，親同士をつける
      //int x_ = find(x);
      //int y_ = find(y);
      d += Distance[x] - Distance[y];
      x = find(x);
      y = find(y);
      if(x==y) return false;

      //大きいほうに小さいほうをくっつける
      if(size(x) < size(y)){
        swap(x,y);
        d *= -1;
      }

      //xのサイズを更新
      Parent[x] += Parent[y];
      Parent[y] = x;
      Distance[y] = d;
      return true;
    }

    //xとyが同じ集合に属するか
    bool same(int x, int y){
      return find(x) == find(y);
    }
};
int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,M;cin >> N >> M;
  UnionFind uni =  UnionFind(N);
  bool isExist = true;
  rep(i,M){
    int L,R,D;cin >> L >> R >> D;
    L--;R--;
    if(uni.same(L,R)){ 
      if(uni.getDistance(L,R) != D){
        isExist = false;
        break;
      }
    } else uni.unite(L,R,D);
  }
  YesNo(isExist);
  return 0;
}


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

bool pal(int f) {
	vector<int> vc;
	while (f > 0) {
		vc.push_back(f % 10);
		f = f / 10;
	}
	for (int i=0; i+i<vc.size(); i++) {
		if (vc[i] != vc[vc.size()-1-i]) return false;
	}
	return true;
}

int main() {
    
    int a, b;
    cin >> a >> b;
    int x = 0;
    for (int i=a; i<=b; i++) x += pal(i);
	cout << x << endl;
	
}


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

int main() {
  string s, t;
  int a, b;
  string u;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if ( s == u ) { a--; } else { b--; }
  cout << a << ' ' << b << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<ll> a(n);
    int ones = 0;
    for (ll &x : a) {
        cin >> x;
        ones += (x == 1);
    }
    const int MAX_A = (int) 1e6 + 100;
    vector<ll> div(MAX_A);
    for (ll i = 2; i < MAX_A; i++) {
        if (!div[i]) {
            div[i] = i;
            for (ll j = i * i; j < MAX_A; j += i) {
                div[j] = i;
            }
        }
    }
    vector<ll> cnt(MAX_A, 0);
    vector<ll> counter(MAX_A, 0);
    for (int i = 0; i < n; i++) {
        counter[a[i]]++;
    }
    sort(a.begin(), a.end());
    int res = 0;
    for (int i = 0; i < n; i++) {
        ll x = a[i];
        bool bad = (counter[x] > 1);
        if (ones - (a[i] == 1) > 0) {
            bad = true;
        }
//        cerr << "Cur: " << x << "\n";
//        while (x > 1 && !bad) {
//            cerr << div[x] << "\n";
//            if (cnt[div[x]]) {
//                cerr << "Was: " << div[x] << "\n";
//                bad = true;
//            }
//            x /= div[x];
//        }
        for (ll i = 2; i * i <= x && !bad; i++) {
            if (x % i == 0) {
                ll j = x / i;
                if (cnt[i] || cnt[j]) {
                    bad = true;
                }
            }
        }
        if (!bad) {
            res++;
        }
        cnt[a[i]]++;
    }
    cout << res << "\n";
}


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

int main(){
  ll n;
  ll k;
  cin>>n>>k;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  
  vector<ll> seen(n,-1);
  seen[0]=0;
  ll now=0;
  ll p=1000000;
  ll q=0;
  rep(i,n+1){
    now=a[now];
    if(seen[now]!=-1){
      p=i+1-seen[now];
      q=seen[now]+1;
      break;
    }
    seen[now]=i+1;
  }
  
  if(k>=q) k=(k-q)%p+q;
  now=0;
  rep(i,k){
    now=a[now];
  }
  cout<<++now;
}

Measured memory_bytes: 6428
#include <algorithm>
#include <array>
#include <complex>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;


typedef int Key;
typedef int Val;

const int MAX_V = 100000;
const Key INF = 1e9;

struct edge { Key to; Val cost; };

int V;
array<vector<edge>, MAX_V> G;
vector<Val> dist;

void addEdge(const Key& from, const Key& to, const Val& cost){
  G[from].push_back({to, cost});
}

void dijkstra(const Key& s){
  dist.resize(V);
  typedef pair<Key, Val> P;
  priority_queue<P, vector<P>, greater<P> > que;
  fill(dist.begin(), dist.end(), INF);
  dist[s] = 0;
  que.push(P(0, s));

  while(!que.empty()){
    const auto p = que.top(); que.pop();
    const auto v = p.second;
    if(dist[v] < p.first) continue;
    for(auto e : G[v]){
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        que.push(P(dist[e.to], e.to));
      }
    }
  }
}

void iostream_init() {
  ios::sync_with_stdio(false); // stdin????????¨???????????????
  cin.tie(0); // cin?????????flush?????????
  cout.setf(ios::fixed);
  cout.precision(3); // ?????¨?????\?????????????????°??¨???
}

int main() {
  iostream_init();
  int E, r;
  cin >> V >> E >> r;
  for(int i = 0; i < E; ++i) {
    int s, t, d;
    cin >> s >> t >> d;
    addEdge(s, t, d);
  }
  dijkstra(r);
  for(auto d : dist){
    if(d == INF){
      cout << "INF" << endl;
    }else{
      cout << d << endl;
    }
  }

}

Measured memory_bytes: 11304
#include<iostream>
using namespace std;
int main() {
  string S;
  cin>>S;
  int n = S.length();
  int Ans = 1000;
  for (int i = 0;i<=n-3;i++) {
    int a = S[i] - '0';
    int b = S[i+1] - '0';
    int c = S[i+2] - '0';
    int x = 100*a + 10*b + c;
    Ans = min(Ans,abs(753-x));
  }
  cout<<Ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
a = LIST()

lim = 3001
dp = [[0]*lim for _ in range(lim)]
cnt = 0
for i in range(1, N+1):
	for l in range(N-i+1):
		cnt += 1
		r = l+i
		if (N-i)%2: #後手
			dp[l][r] = min(dp[l+1][r]-a[l], dp[l][r-1]-a[r-1])
		else: #先手
			dp[l][r] = max(dp[l+1][r]+a[l], dp[l][r-1]+a[r-1])

print(dp[0][N])


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}	
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll n, a, b, ans = 0;
	cin>>n>>a>>b;
	vll x(n);
	for(int i = 0; i < n; i++) cin>>x[i];
	for(int i = 0; i < n-1; i++)
		ans+=min(b, (x[i+1]-x[i])*a);
	p(ans);
	return 0;
}	

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N, A, B;
  cin >> N >> A >> B;
  i64 ans = 0;
  ans += (N / (A + B)) * A;
  ans += std::min(N % (A + B), A);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<((ll)n);i++)
#define rep1(i,n) for(ll i=1;i<=((ll)n);i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define meow(a) cout<<a<<" meow\n";
typedef pair<long long,long long> pii;
const ll maxn=200005;
const ll MOD=998244353;
double mypow(ll a,ll b){
	double res=1;
	while(b){
		if(b&1) res=res*a;
		a=a*a;

		b>>=1;
	}
	return res;
}
ll x,y;


int main()
{
    //IOS;
    while(cin>>x>>y)
    {
        if(x<6) cout<<0<<"\n";
        else if(x<=12) cout<<y/2<<"\n";
        else cout<<y<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cerr << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> PII;

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}

ll N;

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

    // 100 -> 99, 9+9
    // 9995 -> 9989
    // 3141592653589793 -> 137
    // 一番下の桁はNのときor9
    // 桁は0~9でしか変わらない，1個前の桁を1減らして9を増やすことが最善

    ll ans = 0;
    while (N >= 10) {
        int t = N % 10;
        N /= 10;
        if (t < 9) {
            t = 9;
            N -= 1;
        }
        ans += t;
    }

    ans += N;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
using System;

namespace A
{
	class Program
	{
		static void Main(string[] args)
		{
			var line = Console.ReadLine();
			var lineSplited = line.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);

			var A = int.Parse(lineSplited[0]);
			var B = int.Parse(lineSplited[1]);

			if (B % A == 0) {
				Console.WriteLine(A + B);
			} else {
				Console.WriteLine(B - A);
			}
		}
	}
}

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

int main()
{
	int n;
	string s;
	cin >> n >> s;
	auto cnt = vector<int>('z' + 1, 0);
	auto fit = vector<bool>('z' + 1, 0);
	int ans = 0, a = 0;
	for(auto c : s) ++cnt[c];
	for(auto c : s){
		if(--cnt[c] != 0 && !fit[c]){
			++a;
			fit[c] = true;
		}else if(cnt[c] == 0 && fit[c]){
			--a;
		}
		ans = max(ans, a);
	}
	cout << ans << endl;
	return 0;
}

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

const ll INF = 1e15;

int main() {
    ll A, B, Q; cin >> A >> B >> Q;
    vector<ll> s(A); for (int i = 0; i < A; i++) cin >> s[i];
    vector<ll> t(B); for (int i = 0; i < B; i++) cin >> t[i];
    for (int i = 0; i < Q; i++) {
        ll x; cin >> x;
        ll sl, sr;
        if (s[0] < x) {
            int ok = 0, ng = A;
            while (ng - ok != 1) {
                int med = (ng + ok) / 2;
                if (s[med] < x) {
                    ok = med;
                } else {
                    ng = med;
                }
            }
            if (ok == A-1) {
                sl = x - s[ok];
                sr = INF;
            } else {
                sl = x - s[ok];
                sr = s[ok+1] - x;
            }
        } else {
            sl = INF, sr = s[0] - x;
        }
        ll tl, tr;
        if (t[0] < x) {
            int ok = 0, ng = B;
            while (ng - ok != 1) {
                int med = (ng + ok) / 2;
                if (t[med] < x) {
                    ok = med;
                } else {
                    ng = med;
                }
            }
            if (ok == B-1) {
                tl = x - t[ok];
                tr = INF;
            } else {
                tl = x - t[ok];
                tr = t[ok+1] - x;
            }
        } else {
            tl = INF, tr = t[0] - x;
        }
        cout << min(min(max(sl, tl), max(sr, tr)), min(min(sl, tr)*2 + max(sl, tr), min(sr, tl)*2 + max(sr, tl))) << endl;
    }
}


Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double a = 2 * x1 - 2 * x2, b = 2 * y1 - 2 * y2, c = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2, d = 2 * x1 - 2 * x3, e = 2 * y1 - 2 * y3, f = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;
		double px = (c * e - b * f) / (a * e - b * d), py = (a * f - c * d) / (a * e - b * d), r = hypot(x1 - px, y1 - py);
		cout << fixed << setprecision(3) << px << ' ' << py << ' ' << r << endl;
	}
}


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

signed main(void)
{
	int w, a, b;
	cin >> w >> a >> b;
	if (a <= b && b <= a + w)
		cout << 0 << endl;
	else
	{
		if (b - (a + w) >= 0)
			cout << b - (a + w) << endl;
		else
			cout << a - (b + w) << endl;
	}
	return 0;
}


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

int main() {
    int n, r; cin >> n >> r;
    if(n < 10) r += 100*(10-n);
    cout << r << endl;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = sum(B)
for i in range(1,n):
    if A[i] - A[i-1] == 1:
        ans += C[A[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#5
N,W=map(int,input().split())
A=[[0]]+[[int(x) for x in input().split()] for i in range(N)]
A_w=[]
V=N*10**3

dp=[[float("inf") for i in range(V+1)] for j in range(N+1)]
dp[0][0]=0

for i in range(1,N+1):
    w=A[i][0]
    v=A[i][1]
    for sum_v in range(V+1):
        if sum_v-v>=0:
            dp[i][sum_v]=min(dp[i][sum_v],dp[i-1][sum_v-v]+w)
        dp[i][sum_v]=min(dp[i][sum_v],dp[i-1][sum_v])
Max=0
for i in range(V+1):
    if dp[-1][i]<=W:
        Max=i
print(Max)

Measured memory_bytes: 320880
n,m = map(int,input().split())
a = []
ans = [0]*n
for i in range(m):
  a.append(list(map(int,input().split())))
for i in range(m):
  for j in range(n):
    ans[j] += a[i].count(j+1)
for i in range(n):
  print(ans[i])
    
  

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

double s(double a,double b,double c){
    double s = (a+b+c)/2;
    return sqrt(s*(s-a)*(s-b)*(s-c));
}

int main(){
    double a,l,x;
    while(cin >> a >> l >> x){
        double y = (l+x)/2;
        printf("%.15f\n",s(a,l,l)+s(y,y,l)*2);
    }
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  int a,s,d;
  cin>>a>>s>>d;
  if(a+s+d>=22) COUT("bust");
  else COUT("win");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> x, y;
    ll zero = 0;
    ll a[n];
    rep(i,n){
        cin >> a[i];
        if(a[i] < 0){
            x.push_back(-a[i]);
        }else if(a[i] == 0){
            zero++;
        }else{
            y.push_back(a[i]);
        }
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    ll nx = x.size();
    ll ny = y.size();
    // cout << nx << ny << endl;

    if(k <= nx * ny){
        ll l = 1;
        ll r = 1e18+7;
        while(l + 1 < r){
            ll mid = (l + r) / 2;
            ll cnt = 0;
            rep(i,nx){
                cnt += ny - (ll)(lower_bound(y.begin(), y.end(), (mid - 1) / x[i] + 1) - y.begin());
            }
            // cout << cnt << endl;
            if(cnt >= k){
                l = mid;
            }else{
                r = mid;
            }
        }
        cout << -l << endl;
        return 0;
    }else if(k <= nx * ny + zero * (n - zero) + zero * (zero - 1) / 2){
        cout << 0 << endl;
        return 0;
    }else{
        k -= nx * ny + zero * (n - zero) + zero * (zero - 1) / 2;
        // cout << k << endl;
        ll l = 1;
        ll r = 1001001001001001001;
        while(l + 1 < r){
            ll mid = (l + r) / 2;
            ll cnt = 0;
            rep(i,nx){
                ll tmp = nx - (ll)(lower_bound(x.begin(), x.end(), (mid - 1) / x[i] + 1) - x.begin());
                if(tmp >= nx - i)tmp--;
                cnt += tmp;
            }
            rep(i,ny){
                ll tmp = ny - (ll)(lower_bound(y.begin(), y.end(), (mid - 1) / y[i] + 1) - y.begin());
                if(tmp >= ny - i)tmp--;
                cnt += tmp;
            }
            cnt /= 2;
            // cout << mid << ' ' << cnt << endl;
            if(nx * (nx - 1) / 2 + ny * (ny - 1) / 2 - k >= cnt){
                r = mid;
            }else{
                l = mid;
            }
        }
        cout << l << endl;
        return 0;
    }
    
    return 0;
}
 
 


Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> l(q);
    vector<int> r(q);
    REP(i,q){
        cin >> l[i] >> r[i];
        r[i]--;
        l[i]--;
    }
    vector<int> ac(n,0);
    REP(i,n-1){
        if(s[i]=='A'&&s[i+1]=='C'){
            ac[i+1] = 1;
        }
    }
    vector<int> sac(n+1);
    sac[0] = 0;
    REP(i,n){
        sac[i+1] = sac[i]+ac[i];
    }
    REP(i,q){
        if(ac[l[i]]==1){
            put(sac[r[i]+1]-sac[l[i]]-1);
        }else{
            put(sac[r[i]+1]-sac[l[i]]);
        }
        
    }
    return 0;
}


Measured memory_bytes: 2560
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    x <- getIntList
    print $ 15 - (sum x)

Measured memory_bytes: 3688
program main
  implicit none
  integer N, K, i
  character(10) s, v, sbit
  character(1) ref1, ref2
  read(*, *) N
  read(*, *) v
  read(*, *) K
  s = v(1:N)
  sbit = s
  sbit = trim(sbit)
  ref1 = s(K:K)
  do i = 1,N
    ref2 = s(i:i)
    if (ref1 /= ref2) then
      sbit(i:i) = '*'
    end if
  end do
  write(*,'(A)') sbit
end program main


Measured memory_bytes: 768