akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll dat[101010];
#define SIZE 262144
class BIT
{
public:
	ll bit[SIZE + 1];
	void add(int a, ll b)
	{
		a++;
		for (;;)
		{
			bit[a] += b;
			a += a&-a;
			if (a > SIZE)return;
		}
	}
	ll get(int a)
	{
		a++;
		ll ret = 0;
		for (;;)
		{
			ret += bit[a];
			a -= a&-a;
			if (a == 0)return ret;
		}
	}
};
BIT bi;
int main()
{
	ll num;
	scanf("%lld", &num);
	for (int i = 0; i < num; i++)scanf("%lld", &dat[i]);
	ll beg = 0, end = 1100000000LL;
	for (;;)
	{
		if (beg == end)break;
		ll med = (beg + end) / 2;
		ll cnt = 0, now = 0;
		fill(bi.bit, bi.bit + SIZE + 1, 0);
		bi.add(SIZE / 2, 1);
		for (int i = 0; i < num; i++)
		{
			now += (dat[i] <= med) ? 1 : -1;
			cnt += bi.get(SIZE / 2 + now - 1);
			bi.add(SIZE / 2 + now, 1);
		}
		if (cnt < num*(num + 1) / 4 + 1)beg = med + 1;
		else end = med;
	}
	printf("%lld\n", beg);
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main(){
    int n;  cin >> n;
    vector<ll> a(1000000, 0);
    REP(i, n){
        int x;  cin >> x;
        a[x] += 1;
    }

    int res=0;
    FOR(i, 1, 100001){
        int x = a[i-1]+a[i]+a[i+1];
        res = max(res, x);
    }
    cout << res << endl;
}

Measured memory_bytes: 8192
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author david yepes buitrago
 * @date 02-08-2017
 * @time 0.000 ms
 */
public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);

		StringTokenizer st;
		int a, b;
		for (String line; (line = in.readLine()) != null;) {
			st = new StringTokenizer(line);

			a = Integer.parseInt(st.nextToken());
			b = Integer.parseInt(st.nextToken());

			if ((a < 0 && b > 0) || (a == 0 || b == 0)) {
				out.println("Zero");
			} else if ((a > 0 && b > 0) || (Math.abs(Math.abs(b) + Math.abs(a)) % 2 != 0)) {
				out.println("Positive");
			} else {
				out.println("Negative");
			}

		}

		out.close();
		in.close();
	}
}


Measured memory_bytes: 20692
mod = 10**9 + 7
n,k = map(int,input().split())

fac = [1]*(n+1)
inv = [1]*(n+1)
for i in range(1,n+1):
  fac[i] = (fac[i-1]*i) % mod  
inv[n] = pow(fac[n], mod-2, mod)
for i in range(n, 0, -1):
  inv[i-1] = (inv[i]*i) % mod
    
def nCr(n,r):  
  if r < 1:
    return 1
  return (((fac[n] * inv[r])%mod) * inv[n-r]) % mod

ans = 0
for i in range( min(n-1,k) +1 ):    
  ans = (ans + nCr(n,i) * nCr(n-1,i)) % mod

print(ans)

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

int main() {
	int n, t; scanf("%d %d", &n, &t);

	int min = 1100;

	FOR(i, 0, n) {
		int cost, time; scanf("%d %d", &cost, &time);
		if (time <= t) {
			if (cost < min) {
				min = cost;
			}
		}
	}

	if (min == 1100) {
		printf("TLE\n");
	}
	else {
		printf("%d\n", min);
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

int main()
{
    ll A, B, C;
    cin >> A >> B >> C;

    cout << ((A <= C && C <= B) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
/*input
1 1
z
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=500005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int cnt[26];
int cc[26];
int main()
{
	IOS;
	int n,m;
	cin>>n>>m;
	REP(i,n){
		string s;
		cin>>s;
		REP(j,m) cc[s[j]-'a']++;
	}
	REP(i,26) cc[i]%=4;
	REP(i,26) cnt[cc[i]]++;

	if(n%2==0&&m%2==0){
		if(cnt[0]==26){
			cout<<"Yes\n";
		}
		else cout<<"No\n";
	}
	else if(n%2==0){
		if(cnt[1]||cnt[3]){
			cout<<"No\n";
		}
		else if(cnt[2]>n/2){
			cout<<"No\n";
		}
		else cout<<"Yes\n";
	}
	else if(m%2==0){
		if(cnt[1]||cnt[3]){
			cout<<"No\n";
		}
		else if(cnt[2]>m/2){
			cout<<"No\n";
		}
		else cout<<"Yes\n";
	}
	else{
		if(cnt[3]){
			cout<<"No\n";
		}
		else if(cnt[1]!=1){
			cout<<"No\n";
		}
		else if(cnt[2]>n/2+m/2){
			cout<<"No\n";
		}
		else cout<<"Yes\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5678, mod = 1000000007;
int mul(long long a, long long b){
	return a * b % mod;
}
int dp[2][maxn][maxn], tmp[2][maxn], sz[maxn], g[maxn];
vector<int> to[maxn];
void solve(int u, int v){
	sz[u] = 1;
	dp[0][u][1] = 1;
	for(int nxt : to[u]){
		if(nxt == v) continue;
		solve(nxt, u);
		for(int i = 0;  i <= sz[u] + sz[nxt]; i++) tmp[0][i] = tmp[1][i] = 0;
		for(int pi = 0; pi < 2; pi++) for(int pj = 0; pj < 2; pj++)
		for(int i = 0; i <= sz[u]; i++) for(int j = 0; j <= sz[nxt]; j++) {
			{
				int np = pi + pj; if(np >= 2) np -= 2;
				tmp[np][i + j] += mul(dp[pi][u][i], dp[pj][nxt][j]);
				if(tmp[np][i + j] >= mod) tmp[np][i + j] -= mod;
			}
			{
				int np = pi + pj + 1; if(np >= 2) np -= 2;
				tmp[np][i] += mul(dp[pi][u][i], mul(dp[pj][nxt][j], g[j]));
				if(tmp[np][i] >= mod) tmp[np][i] -= mod;
			}
		}
		sz[u] += sz[nxt];
		for(int pi = 0; pi < 2; pi++) for(int i = 0; i <= sz[u]; i++) dp[pi][u][i] = tmp[pi][i];
	}
}
int main(){
	g[0] = 1;
	for(int i = 2; i < maxn; i++){
		if(i%2 == 0) g[i] = mul(g[i - 2], i - 1);
	}
	int n; cin >> n;
	for(int i = 0; i < n - 1; i++){
		int x, y; cin >> x >> y;
		to[x].push_back(y);
		to[y].push_back(x);
	}
	solve(1, 0);
	for(int pi = 0; pi < 2; pi++) for(int i = 0; i <= n; i++) dp[pi][1][i] = mul(dp[pi][1][i], g[i]);
	int ans = 0;
	for(int pi = 0; pi < 2; pi++) for(int i = 0; i <= n; i++) {
		if(pi == 0) ans += dp[pi][1][i];
		else ans += mod - dp[pi][1][i];
		if(ans >= mod) ans -= mod;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
	string s;
	cin >> s;
	rep(i, 3) cout << s.at(i);
	cout << endl;
	return 0;
}

Measured memory_bytes: 3628
# frozen_string_literal: true

class Node
  attr_accessor :key, :parent, :left, :right

  def initialize(key)
    @key = key
  end

  def root?
    parent ? false : true
  end
end

class Tree < Array
  def insert(node)
    y = nil
    x = root_node

    until x.nil?
      y = x
      x = if node.key < x.key
        x.left
          else
        x.right
      end
    end
    node.parent = y

    if y.nil?
      push node
    elsif node.key < y.key
      y.left = node
    else
      y.right = node
    end
  end

  def find_node(key)
    node = root_node
    while node && node.key != key
      node = if key < node.key
        node.left
             else
        node.right
      end
    end

    node
  end

  def delete_node(key)
    node = find_node(key)
    return unless node

    if node.left.nil? && node.right.nil?
      if node.parent.left == node
        node.parent.left = nil
      else
        node.parent.right = nil
      end

      return
    end

    if !node.left ^ !node.right
      if node.parent.left == node
        node.parent.left = node.left || node.right
      else
        node.parent.right = node.left || node.right
      end
      
      child = node.right || node.left
      child.parent = node.parent
      return
    end

    if node.left && node.right
      zisetu = zisetu(node)

      delete_node(zisetu.key)
      node.key = zisetu.key
    end
  end

  def root_node
    find(&:root?)
  end
end

def zisetu(node)
  if node.right != nil
    return minmum(node.right)
  end

  y = node.parent
  while y != nil && node == y.right
    node = y
    y = y.parent
  end

  y
end

def minmum(node)
  while node.left != nil
    node = node.left
  end

  node
end

def print_order_by_preorder(node)
  return unless node

  print ' '
  print node.key
  print_order_by_preorder(node.left)
  print_order_by_preorder(node.right)
end

def print_order_by_inorder(node)
  return unless node

  print_order_by_inorder(node.left)
  print ' '
  print node.key
  print_order_by_inorder(node.right)
end

n = gets.to_i
array = readlines.map(&:chomp!).map do |line|
  if line == 'print'
    { print: 0}
  elsif line.include?('find')
    { find: line.split[1].to_i }
  elsif line.include?('insert')
    { insert: line.split[1].to_i }
  elsif line.include?('delete')
    { delete: line.split[1].to_i }
  end
end

tree = Tree.new

array.each do |e|
  if e[:insert]
    tree.insert(Node.new(e[:insert]))
  elsif e[:find]
    tree.find_node(e[:find]) ? puts('yes') : puts('no')
  elsif e[:delete]
    tree.delete_node(e[:delete])
  elsif e[:print]
    print_order_by_inorder(tree.root_node)
    print "\n"
    print_order_by_preorder(tree.root_node)
    print "\n"
  end
end





Measured memory_bytes: 184728
#141
N, K, Q = map(int, input().split())

cnt = 0
P = [K - Q] * N
for i in range(Q):
    idx = int(input()) - 1    
    P[idx] += 1

for j in range(N):
    if P[j] > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 6584
#include "bits/stdc++.h"

//#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
dx8[8] = { 0,1,1,1,0,-1,-1,-1 },
dy8[8] = { 1,1,0,-1,-1,-1,0,1 },
dx4[4] = { 0,1,0,-1 },
dy4[4] = { 1,0,-1,0 };

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

int main(){
	setc;

	lint a,b;cin>>a>>b;
	co(a-b+1);
	gc();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const ll LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
	int n, h, ans = 0, cmp = 0;
	vector<int> vec;
	cin >> n >> h;
	int a[n], b[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a, a + n);
	reverse(a, a + n);
	sort(b, b + n);
	reverse(b, b + n);
	for (int i = 0; i < n; i++) {
		if (b[i] > a[0]) {
			vec.push_back(b[i]);
		} else {
			break;
		}
	}
	for (int i = 0; i < (int)vec.size(); i++) {
		cmp += vec[i], ans++;
		if (cmp >= h) {
			cout << ans << endl;
			return 0;
		}
	}
	cout << ((h - cmp) % a[0] == 0 ? ans + ((h - cmp) / a[0]) : ans + (((h - cmp) / a[0]) + 1)) << endl;
	return 0;
}

Measured memory_bytes: 1660
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<utility>
#include<string>

using namespace std;

int f[505];
int r[505][505];
int n,m;
int ans;
void c(int now,int con);
main(){
  int i,j,a,b;
  while(1){
    ans=0;
    for(i=0;i<505;i++){
      f[i]=0;
      for(j=0;j<505;j++){
	r[i][j]=0;
      }
    }
    scanf("%d %d",&n,&m);
    if(n==0 && m==0){
      break;
    }
    for(i=1;i<=m;i++){
      scanf("%d %d",&a,&b);
      r[a][b]=1;
    }
    f[1]=1;
    c(1,1);
    for(i=0;i<505;i++){
      if(f[i]==1){
	ans++;
      }
    }
    /*
    for(i=1;i<=n;i++){
      cout << f[i];
    }
    puts("");
    */
    cout << ans-1 << endl;
  }
}

void c(int now,int con){
  int i,j;
  for(i=2;i<=n;i++){
    if(r[i][now]==1 || r[now][i]==1){
      f[i]=1;
      r[i][now]=0;
      r[now][i]=0;
      /*
      cout << i <<"  " << con << "  "; 
      for(j=1;j<=n;j++){
	cout << f[j];
      }
      puts("");
 
      */
      if(con<2){
	c(i,con+1);
      }
    }
  }
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

LL H,W;

LL INF = 100000;

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

  cin>>H>>W;

  vector<string> A(H);

  REP(i,H){
    cin >> A[i];
  }

  vector<vector<vector<LL>>> N(H+2, vector<vector<LL>>(W+2, vector<LL>(4,INF)));

  REP(i,H+2){
    REP(j,W+2){
      REP(k,4){
        if(i==0||i==H+1||j==0||j==W+1){
          N[i][j][k] == INF;
        }
      }
    }
  }

  for (LL i = 1; i <= H;++i){
    for (LL j = 1;j<=W;++j){
      if (A[i-1][j-1] == '#')
      {
        N[i][j][0] = 0;
      }else{
        N[i][j][0] = min(N[i - 1][j][0], N[i][j - 1][0]) + 1;
      }
    }
  }
  for (LL i = H; i >=1;--i){
    for (LL j = 1;j<=W;++j){
      if (A[i-1][j-1] == '#')
      {
        N[i][j][1] = 0;
      }else{
        N[i][j][1] = min(N[i + 1][j][1], N[i][j - 1][1]) + 1;
      }
    }
  }
  for (LL i = 1; i <= H;++i){
    for (LL j = W;j>=1;--j){
      if (A[i-1][j-1] == '#')
      {
        N[i][j][2] = 0;
      }else{
        N[i][j][2] = min(N[i - 1][j][2], N[i][j + 1][2]) + 1;
      }
    }
  }
  for (LL i = H; i >=1;--i){
    for (LL j = W;j>=1;--j){
      if (A[i-1][j-1] == '#')
      {
        N[i][j][3] = 0;
      }else{
        N[i][j][3] = min(N[i + 1][j][3], N[i][j + 1][3]) + 1;
      }
    }
  }

  LL maxi = 0;

  REP(i,H){
    REP(j,W){
      LL aa = min({N[i + 1][j + 1][0], N[i + 1][j + 1][1], N[i + 1][j + 1][2], N[i + 1][j + 1][3]});
      if (maxi < aa)
      {
        maxi = aa;
      }
    }
  }
  cout << maxi << endl;
}


Measured memory_bytes: 72064
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] array = new int[N];
		int[] arrayH = new int[N];
		int count = 0;

		for (int i = 0; i < N; i++) {
			array[i] = 1;
		}

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

		for (int k = 0; k < M; k++) {
			int X = sc.nextInt() - 1;
			int Y = sc.nextInt() - 1;
			if (arrayH[X] < arrayH[Y]) {
				array[X] = 0;
			} else if (arrayH[X] > arrayH[Y]) {
				array[Y] = 0;
			} else if (arrayH[X] == arrayH[Y]) {
				array[X] = 0;
				array[Y] = 0;
			}
		}

		for (int i = 0; i < array.length; i++) {
			if (array[i] == 1) {
				count++;
			}
		}

		System.out.println(count);
	}

}

Measured memory_bytes: 62004
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parent = [-1 for _ in range(n)]
  def find(self, x):
    if self.parent[x] < 0:
      return x
    else:
      self.parent[x] = self.find(self.parent[x])
      return self.parent[x]
  def unite(self, x, y):
    x, y = self.find(x), self.find(y)
    if x == y:
      return False
    else:
      if self.size(x) < self.size(y):
        x, y = y, x
      self.parent[x] += self.parent[y]
      self.parent[y] = x
      return True
 
  def same(self, x, y):
    return self.find(x) == self.find(y)
  def size(self, x):
    x = self.find(x)
    return -self.parent[x]
  def is_root(self, x):
    return self.parent[x] < 0
 
  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

n,m,k = map(int, input().split())
uf=UnionFind(n)
deg=[0]*n
l=[[] for i in range(n)]
for i in range(m):
  a,b = map(int, input().split())
  deg[a-1]+=1
  deg[b-1]+=1
  uf.unite(a-1,b-1)
for i in range(k):
  c,d = map(int, input().split())
  l[c-1].append(d-1)
  l[d-1].append(c-1)
ans=[]
for i in range(n):
  tmp=uf.size(i)-1-deg[i]
  for u in l[i]:
    if uf.same(i,u):
      tmp-=1
  ans.append(tmp)
print(*ans)


Measured memory_bytes: 31784
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;

void output(bool winning) {
  cout << (!winning ? "Second" : "First") << endl;
  exit(0);
}

int main(void){
  int n;
  cin >> n;
  VI a(n);
  REP(i, 0, n) {
    cin >> a[i];
  }
  sort(a.rbegin(), a.rend());
  a.push_back(0);
  int k = 0;
  while (k < n && k < a[k]) k++;
  // Where is the intersection point of y=x and block's border?
  int start = k;
  while (start >= 0) {
    if (a[k] == a[start]) start--;
    else break;
  }
  start++;
  int end = k;
  while (end < n) {
    if (a[end] == a[k]) end++;
    else break;
  }
  if (k == a[k]) {
    if (start == k) {
      output((end - k) % 2 == 1 || (a[k - 1] - k) % 2 == 1); 
    }
    output((end - k) % 2 == 1);
  }
  output((a[k - 1] - k) % 2 == 1);
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read().ToList();
            var Q = ReadInt();
            var right = true;
            var S1 = new List<char>();
            var S2 = new List<char>();
            var ans = "";
            for (int i = 0; i < Q; i++)
            {
                var qry = ReadArrayString();
                if (qry.Count() == 1)
                {
                    right = !right;
                }
                else
                {
                    var F = int.Parse(qry[1]);
                    var C = qry[2][0];
                    if (right)
                    {
                        if (F == 1) S1.Add(C);
                        else S2.Add(C);
                    }
                    else
                    {
                        if (F == 1) S2.Add(C);
                        else S1.Add(C);
                    }
                }
            }
            if (right)
            {
                S1.Reverse();
                ans = string.Join("", S1) + string.Join("", S) + string.Join("", S2);
            }
            else
            {
                S.Reverse();
                S2.Reverse();
                ans = string.Join("", S2) + string.Join("", S) + string.Join("", S1);
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static string[] ReadArrayString() { return Read().Split(' '); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

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

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll INF = TEN(18);
ll a[20];

ll calc(int l, int r, int lx, int rx) {
	if (r == l+1) {
		return 0ll;
	}
	int mx = lx + rx;
	ll res = INF;
	for (int m = l + 1; m < r; ++m) {
		res = min(res, calc(l, m, lx, mx) + calc(m, r, mx, rx) + mx * a[m]);
	}
	return res;
}

int main() {
	int N; cin >> N;
	rep(i, N) cin >> a[i];
	ll res = calc(0, N-1, 1, 1) + a[0] + a[N-1];
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

const int MAX_N = 2e5 + 5;
const int MAX_M = 2e5 + 5;

int d[MAX_N], t[MAX_M];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n;
	cin >> n;

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

	sort(d, d + n);

	int m;
	cin >> m;

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

	sort(t, t + m);

	int ind = 0;
	for(int i = 0; i < m; i++) {
		while(ind < n && d[ind] < t[i]) {
			ind++;
		}

		if(ind == n || d[ind] != t[i]) {
			cout << "NO" << endl;
			return 0;
		}

		ind++;
	}

	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007LL;
int main() {
    string L;
    cin >> L;
    int sz = L.size();
    vector<ll> dp_u(sz+1,0), dp_l(sz+1,0);
    dp_u[0] = 1;
    for ( int i = 0; i < sz; i++ ) {
        if ( L[i] == '1' ) {
            dp_u[i+1] += dp_u[i] * 2;
            dp_l[i+1] += dp_u[i] + dp_l[i] * 3;
        } else {
            dp_u[i+1] += dp_u[i];
            dp_l[i+1] += dp_l[i] * 3;
        }
        dp_u[i+1] %= MOD;
        dp_l[i+1] %= MOD;
    }
    
    ll ans = dp_u[sz] + dp_l[sz];
    ans %= MOD;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 2048
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n, m = LI()
    print(n * (n - 1) // 2 + m * (m - 1)//2)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39024
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] A = new long[n], B = new long[n];
        for(int i=0;i<n;i++) A[i]=sc.nextLong();
        for(int i=0;i<n;i++) B[i]=sc.nextLong();
        int ans = help(n,A,B);
        System.out.println(ans);
    }
    static int help(int n, long[] a, long[] b){
        long sum = 0;
        long[] c = new long[n];
        for(int i=0;i<n;i++) c[i]=a[i]-b[i];
        for(long w:c) sum += w;
        if(sum<0) return -1;
        boolean flag = true;
        for(int i=0;i<n;i++) flag &= a[i]>=b[i];
        if(flag) return 0;
        Arrays.sort(c);
        int  left = 0, right = n-1;
        boolean[] vis = new boolean[n];
        while(c[left]<0){
            if(c[left]+c[right]==0){
                vis[left]=vis[right]=true;
                left++;
                right--;
            }else if(c[left]+c[right]>0){
                vis[left]=vis[right]=true;
                c[right]+=c[left];
                left++;
            }else{
                vis[left]=vis[right]=true;
                c[left] += c[right];
                right--;
            }
        }
        int ans = 0;
        for(int i=0;i<n;i++) ans += vis[i]?1:0;
        return ans;
    }
}


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

#define endl "\n"
#define int long long

const int MOD = 1e9 + 7;
const int INF = 2e10;
const int mx = 1e4 + 5;

void debug(vector <int> &dp, int l, int r) {
	for (int i = 1; i <= r; i++) {
		if (dp[i] == INF) cout << "inf ";
		else cout << dp[i] << " ";
	}
	cout << endl;
}

void max_self(int &a, int b) {
	a = max(a, b);
}

void min_self(int &a, int b) {
	a = min(a, b);
}

signed main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

	string s, t;
	cin >> s >> t;

	int m = s.size();
	int n = t.size();

	vector <vector <int> > dp(m + 1, vector <int> (n + 1, 0));
	dp[0][0] = 0;

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
			}
			else dp[i + 1][j + 1] = max({dp[i + 1][j], dp[i][j + 1], dp[i][j]});
		}
	}

	string ans = "";
	int i = m;
	int j = n;

	while (i > 0 and j > 0) {
		if (s[i - 1] == t[j - 1]) {
			ans += s[i - 1];
			i--;
			j--;
		}
		else {
			if (dp[i][j] == dp[i - 1][j - 1]) {
				i--;
				j--;
			}
			else if (dp[i][j] == dp[i - 1][j]) {
				i--;
			}
			else j--;
		}
	}

	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	cerr << dp[m][n] << endl;
}


Measured memory_bytes: 73624
import queue

q = queue.Queue()
bool = True


def bfs():
    q.put(0)
    while not q.empty():
        now = q.get()
        for i in nodes[now]:
            if dist[i] != -1:
                continue
            dist[i] = dist[now] + 1
            q.put(i)
            ans[i] = now
    # bool = False


N, M = map(int, input().split())
nodes = [[] for i in range(N)]
idxStock = []
for i in range(M):
    a, b = map(int, input().split())
    nodes[a - 1].append(b - 1)
    nodes[b - 1].append(a - 1)

dist = [-1] * N
ans = [-1] * N
bfs()
if bool:
    print("Yes")
    for i in range(1, N):
        print(ans[i] + 1)
else:
    print("No")


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

int main() {
	ll x;
	cin >> x;

	ll five_hundred = x / 500;
	x %= 500;

	ll five = x / 5;

	cout << five_hundred * 1000ll + five * 5 << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N,K;
    cin >> N >> K;

    cout << (N%K == 0? 0 : 1) << endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, s, c, flag = 1, i;
    cin>>n>>m;
    vector<ll> num(n, -1);
    while(m--) {
    	cin>>s>>c;
    	s--;
    	if(num[s] == c || num[s] == -1) {
    		if(s == 0 && c == 0 && n != 1) {
    			flag = 0;
    		}
    		num[s] = c;
    	} else {
    		flag = 0;
    	}
    }
    if(flag) {
    	for(i = 0; i < n; i++) {
    		if(num[i] == -1) {
    			if(i == 0 && n != 1) {
    				num[i] = 1;
    			} else {
    				num[i] = 0;
    			}
    		}
    	}
    	for(auto u: num) {
    		cout<<u;
    	} cout<<"\n";
    } else {
    	cout<<"-1\n";
    }
}

Measured memory_bytes: 256
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll r,D,x;
	cin >>r>>D>>x;
	
	// 解法
	REP(i,10){
		x = x*r-D;
		cout<<x<<endl;
	}
}


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

int main(){
  int R;
  cin >> R;
  cout << fixed << setprecision(20);
  cout << 2 * M_PI * R << endl;
}


Measured memory_bytes: 3788
s = input()

n = len(s)

res = [0]*n

swi = 'R'

r = [-1]*n
l = [-1]*n

for i in range(n):
	if s[i] == 'L':
		if l[i-1] == -1:
			l[i] = 0
		else:
			l[i] = l[i-1]+1

for i in reversed(range(n)):
	if s[i] == 'R':
		if r[i+1] == -1:
			r[i] = 0
		else:
			r[i] = r[i+1]+1
			
for i in range(n):
	if s[i] == 'L':
		res[i-l[i]-l[i]%2] += 1
	else:
		res[i+r[i]+r[i]%2] += 1

print(' '.join(map(str, res)))

Measured memory_bytes: 15220
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)		memset(v, d, sizeof(v))
const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>P;
const ll mod = ll(1e9 + 7);
int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, -1, 1 };
const int N = 1000001;
#define endl '\n'
#define ever ;;
#define F first
#define S second
#define pii pair<int,int>
#define sz(v) ((int)((v).size()))
#define pll pair<ll,ll>
void stop() {
#ifndef ONLINE_JUDGE
	system("pause");
#endif
}
void file() {
#ifndef ONLINE_JUDGE
	freopen("pizza.in", "r", stdin);
	freopen("pizza.out", "w", stdout);
#endif
}
struct point {
	double x, y;
};
ull gcd(ull a, ull b) { return !b ? a : gcd(b, a % b); }
ll fixMod(ll a, ll b) { return ((a%b) + b) % b; }
double triangle_area(int x1, int y1, int x2, int y2, int x3, int y3) {
	return abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2.;
};
ll dis(point a, point b) {
	ll x = a.x - b.x, y = a.y - b.y;
	return x * x + y * y;
}
ull LCM(ull a, ull b) {
	return a / gcd(a, b)*b;
}
ll power(ll x, ll y)
{
	if (y == 0)return 1;
	if (y == 1)return x;
	ll r = power(x, y / 2) % mod;
	return r%mod*r%mod*power(x, y % 2) % mod;
}
int main() {
	fast
		ll a, b;
	cin >> a >> b;
	cout << (a * 3 + b) / 2;
	stop();
	return 0;
}

Measured memory_bytes: 504
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int h,w,k;
int cnt;
bool board[10][10];
bool tmp[10][10];
bool check(int a,int b){
	int cnt_tmp=cnt;
	memset(tmp,false,sizeof(tmp));
	memcpy(tmp,board,sizeof(tmp));
	for(int i=0;i<h;i++){
		if(((a>>i)&1)==0) continue;
		for(int j=0;j<w;j++){
			if(tmp[i][j]){
				tmp[i][j]=false;
				cnt_tmp--;
			}
		}
	}
	for(int i=0;i<w;i++){
		if(((b>>i)&1)==0) continue;
		for(int j=0;j<h;j++){
			if(tmp[j][i]){
				tmp[j][i]=false;
				cnt_tmp--;
			}
		}
	}
	if(cnt_tmp==k) return true;
	return false;
}
int main(){
	memset(board,false,sizeof(board));
	cin>>h>>w>>k;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char ctmp;
			cin>>ctmp;
			if(ctmp=='#') board[i][j]=true,cnt++;
		}
	}
	int ans=0;
	for(int i=0;i<(1<<h);i++){
		for(int j=0;j<(1<<w);j++){
			if(check(i,j)) ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    if(e-a<=k){
        cout<<"Yay!"<<endl;
    }else{
        cout<<":("<<endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma G++ optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
const ll INF = 0x3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 2e5 + 7;
const int maxm = 1e5 + 7;
const int mod = 192600817;
#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
map<int,int>num;
int main()
{
    IO;
    int n,k;
    cin>>n>>k;
    while (k--)
    {
        int d;
        cin>>d;
        while (d--)
        {
            int x;
            cin>>x;
            num[x]=1;
        }
    }
    cout<<n-num.size()<<endl;
    return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	REP(i, 3) {
		string s;
		cin >> s;
		printf("%c", s[0] - 'a' + 'A');
	}
	puts("");
	
	return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    B = input()
    B = B.split()
    B = [int(i) for i in B]
    s = 0
    for i in range(0, n-1):
        if i == 0:
            s += B[0]
        else:
            s += min(B[i - 1], B[i])
    s += B[-1]
    return s

print(main())

Measured memory_bytes: 3064
import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
from math import sin,pi

def main():
    h,w = map(int,input().split())
    dic = {}
    for _ in range(h):
        a = list(input())
        for s in a:
            if s in dic:
                dic[s] += 1
            else:
                dic[s] = 1
    
    ans = 'Yes'
    if h%2 == 0 and w%2 == 0:
        for v in dic.values():
            if v%4 != 0:
                ans = 'No'
                cnt = 0
                break
    
    elif h%2 == 0:
        cnt = 0
        for v in dic.values():
            if v%4 == 0:
                cnt += cnt//4
            elif v%2 == 0:
                cnt += (v - 2)//4
            else:
                ans = 'No'
                cnt = 0
                break
        
        if cnt < (h//2) * (w//2):
            ans = 'No'
    
    elif w%2 == 0:
        cnt = 0
        for v in dic.values():
            if v%4 == 0:
                cnt += v//4
            elif v%2 == 0:
                cnt += (v - 2)//4
            else:
                ans = 'No'
                cnt = 0
                break
        
        if cnt < (h//2) * (w//2):
            ans = 'No'
    
    else:
        cnt = 0
        flag = False
        for v in dic.values():
            if v%4 == 0:
                cnt += v//4
            elif v%2 == 0:
                cnt += (v - 2)//4
            else:
                if flag:
                    ans = 'No'
                    cnt = 0
                    break
                flag = True
                v -= 1
                if v%4 == 0:
                    cnt += v//4
                else:
                    cnt += (v - 2)//4
        if cnt < (h//2) * (w//2):
            ans = 'No'
    
    print(ans)
if __name__=='__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    long long N;
    cin >> N;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];
    long long X = 0;
    for(long long i=2; i<N; i++) X ^= A[i];
    long long S = A[0] + A[1];

    long long dp[50][2][2];
    REP(i, 50) REP(j, 2) REP(k, 2) dp[i][j][k] = -1;
    dp[0][0][0] = 0;
    for(long long i=0; i<49; i++){
        long long s = (1LL&(S>>i));
        long long x = (1LL&(X>>i));
        long long aa = (1LL&(A[0]>>i));

        for(long long j=0; j<2; j++){
            for(long long k=0; k<2; k++){
                if(dp[i][j][k]==-1) continue;

                for(long long a=0; a<2; a++){
                    long long b = x^a;
                    long long cur = a^b^j;
                    if(s!=cur) continue;
                    long long jj = (a+b+j>=2 ? 1 : 0);

                    long long kk = k;
                    if(a > aa) kk = 1;
                    if(a < aa) kk = 0;

                    dp[i+1][jj][kk] = max(dp[i+1][jj][kk], dp[i][j][k] + (a<<i));
                }
            }
        }
    }
    if(dp[49][0][0]<=0) cout << -1 << endl;
    else cout << A[0] - dp[49][0][0] << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(3e5)+10;
int n,cnt[maxn],mx,k;
ll s[maxn];
bool solve(int mid) {
	int x=lower_bound(cnt+1,cnt+n+1,mid)-cnt;
	return n-k*mid>=s[x]-(ll)mid*(n-x+1);
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); int x;
	for (int i=1;i<=n;i++) read(x),cnt[x]++;
	sort(cnt+1,cnt+n+1);
	for (int i=n;i>=1;i--) s[i]=s[i+1]+cnt[i];
	for (int i=1;i<=n;i++) {
		int l=0,r=n/i,res,mid; k=i;
		while (l<=r) {
			mid=(l+r)/2;
			if (solve(mid)) res=mid,l=mid+1;
			else r=mid-1;
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <map>
#include <iostream>
#include <vector>

using namespace std;
#define DEBUG(X) cerr<<__LINE__<<" "<<#X<<": "<<X<<endl;
#define sci(x) int x;scanf("%d",&x);
#define scii(x, y) int x,y;scanf("%d%d",&x,&y);
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
typedef long long ll;
multimap<int, int> mp;
int N; ll K;
int main() {
  scanf("%d%llu",&N,&K);
  REP(i,N) {
    scii(a,b)
    mp.emplace(a,b);
  }

  ll sum=0;
  for(auto pair : mp) {
    if (sum < K && K <= sum+pair.second) {
      printf("%d\n",pair.first);
      return 0;
    } else {
      sum += pair.second;
    }
  }
}

Measured memory_bytes: 4992
#include<stdio.h>
int main()

{
int i,a,b,c=0,d=0,n,e,f=0;
	scanf("%d",&n);
while(n!=0){
	for(i=0;i<n;i++){
	scanf("%d",&a);
	if(a>1) f=1;
	if(a==0) d++;
	}
	e=n+1-d;
	if(f==1) printf("%d\n",e);
	else printf("NA\n");
	scanf("%d",&n);
	f=0;
	c=0;
	d=0;
	}
	return 0;
	
}

Measured memory_bytes: 1040
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
ll dp[100010][13];

int main(){
  string s;
  cin >> s;
  ll n=s.size();
  dp[0][0]=1;
  for(ll i=1;i<=n;i++){
    for(ll j=0;j<13;j++){
      if(s[i-1]=='?'){
        for(ll k=0;k<10;k++){
          dp[i][(10*j+k)%13]+=dp[i-1][j];
          dp[i][(10*j+k)%13]%=mod;
        }
      }
      else{
        ll k=s[i-1]-'0';
          dp[i][(10*j+k)%13]+=dp[i-1][j];
          dp[i][(10*j+k)%13]%=mod;
      }
    }
  }
  cout << dp[n][5] << endl;
}      

Measured memory_bytes: 10624
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long n = Long.parseLong(sc.next());
		long input = n;

		// nを素因数分解する。結果はmapに、素因数と指数のペアで入れていくことにする。
		HashMap<Long, Long> map = new HashMap<Long, Long>();
		for (long i = 2; i * i <= input; i++) {
			long j = 0;
			while (true) {
				if (n % i == 0) {
					j++;
					map.put(i, j);
					n /= i;
				} else {
					break;
				}
			}
		}
		if (n != 1) {
			map.put(n, 1L); // 最後に残った数も忘れずに入れる
		}

		// 素因数分解の結果
		for (long key : map.keySet()) {
			// System.out.println(key + " " + map.get(key));
		}

		// 結果を求めて出力
		int result = 0;
		for (long key : map.keySet()) {
			long z = map.get(key);
			for (int j = 1; j < 10000; j++) {
				if (j <= z) {
					z -= j;
					result++;
				} else {
					break;
				}
			}
		}

		System.out.println(result);

	}
}

Measured memory_bytes: 37272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

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

Measured memory_bytes: 3596
import java.io.*;
import java.util.*;
import java.util.ArrayList;
 
class Main
{
  public static void main (String[] arg)
  {
    Scanner scan = new Scanner(System.in);
    
    long H = Integer.parseInt(scan.next()); //H
    long W = Integer.parseInt(scan.next()); //H
    
    long ans = 0;
    
    if(H == 1 && W != 1){
      ans = 1;
    }
    else if(H != 1 && W == 1){
      ans = 1;
    }
      
    else if(H % 2 == 1 && W % 2 ==1){
      ans = (H * W)/2 + 1;
    }
    else{
      ans = (H * W)/2;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844