akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x){ostringstream sout; sout<<x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);

struct data {
	int b, w;
	string n;
	data(){};
	data(int b, int w, string n) : b(b), w(w), n(n){};
};
bool operator< (const data &l, const data &r) {
	return l.w < r.w;
}

int main(){
	int N, Q;
	while(cin >> N >> Q, N) {
		vector<data> d(N);
		REP(i, N) {
			string s;
			int b, w;
			cin >> s >> b >> w;
			d[i].n = s;
			d[i].b = b;
			d[i].w = w;
		}
		sort(ALL(d));

		REP(i, Q) {
			int y;
			cin >> y;

			REP(j, N) {
				if(d[j].w-d[j].b < y && y <= d[j].w) {
					cout << d[j].n << " " << y-(d[j].w-d[j].b) << endl;
					goto next;
				}
			}
			cout << "Unknown" << endl;
			next:;
		}
	}
}

Measured memory_bytes: 1284
import java.util.*;
import java.math.*;

public class Main{
	private static int S,A,C;
	private static int[] I, Rmemo;

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

		while(true){
			int n = sc.nextInt();
			if(n == 0) break;

			I = new int[n];
			for(int i=0;i<n;i++) I[i] = sc.nextInt();

			double minH = Double.MAX_VALUE;
			int minS=-1, minA=-1, minC=-1;
			for(S=0;S<=15;S++){
				for(A=0;A<=15;A++){
					for(C=0;C<=15;C++){
						double H = 0.0;

						Rmemo = new int[258];
						Arrays.fill(Rmemo,-1);

						int[] count = new int[258];
						for(int i=1;i<=n;i++) count[O(i)]++;
						for(int x : count){
							if(x > 0)
								H -= (double)x / n * Math.log((double)x / n);
						}
						if(minH > H && Math.abs(minH-H) > 0.00001){
							minH = H;
							minS = S;
							minA = A;
							minC = C;
						}
					}
				}
			}

			System.out.println(minS + " " + minA + " " + minC);
		}
	}

	private static int O(int i){
		return (I[i-1] + R(i)) % 256;
	}

	private static int R(int i){
		if(i == 0) return S;
		if(Rmemo[i] != -1) return Rmemo[i];
		return Rmemo[i] = (A * R(i-1) + C) % 256;
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int A, B, K; cin >> A >> B >> K;
	rep (i, K){
		if (i % 2 == 0){
			if (A % 2 != 0){
				--A;
			} // end if
			B += A / 2;
			A /= 2;
		}else{
			if (B % 2 != 0){
				--B;
			} // end if
			A += B / 2;
			B /= 2;
		} // end if
	} // end rep

	cout << A << ' ' << B << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

void out(vector<ll> a, vector<ll> b) {
	rep(i, a.size())rep(j, b.size()) {
		cout << a[i] << " " << b[j]<<endl;
	}
}



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

	ll M = N / 2;

	if (N % 2 == 0) {
		cout << 4 * M*(M-1)/2 << endl;

		vector<vector<ll>> s(M);
		rep(i, M) {
			s[i].push_back(i+1);
			s[i].push_back(N - i);
		}

		rep(i, M) {
			for (ll j = i + 1; j < M; j++) {
				out(s[i], s[j]);
			}
		}

	}

	if (N % 2 == 1) {
		cout << 4 * M*(M - 1)/2 + 2*M<<endl;

		vector<vector<ll>> s(M+1);
		rep(i, M) {
			s[i].push_back(i+1);
			s[i].push_back(N-1 - i);
		}

		s[M].push_back(N);

		rep(i, M+1) {
			for (ll j = i + 1; j < M+1; j++) {
				out(s[i], s[j]);
			}
		}

	}
	
	
	system("PAUSE");
}


Measured memory_bytes: 504
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;

int main()
{
	priority_queue<int> q;
	char op[20];
	int k;
	while (scanf("%s", op) != EOF&&op[2] != 'd') {
		if (op[0] == 'i') {
			scanf("%d", &k);
			q.push(k);
		}
		else {
			int k = q.top();
			q.pop();
			printf("%d\n", k);
		}
	}
	return 0;
}

Measured memory_bytes: 7004
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

int main(){
	int n;
	while(~scanf("%d",&n)){
		for(int i=0;i<n;i++){
			int sx,sy,W,H;
			scanf("%d %d %d %d",&sx,&sy,&W,&H);
			int N;
			scanf("%d",&N);
			int count = 0;
			for(int j=0;j<N;j++){
				int x,y;
				scanf("%d %d",&x,&y);
				if(x < sx || x > sx+W
					|| y < sy || y > sy+H){
						continue;
				}

				count++;
			}

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

Measured memory_bytes: 1184
#include <iostream>

std::string divide[] = {
        "dream",
        "dreamer",
        "erase",
        "eraser"
};

int main(int argc, char const* argv[]) {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::string S;
    std::cin >> S;

    bool canDiv;
    while (true) {
        bool isFit = false;
        for (const auto d: divide) {
            if (d.length() > S.length()) continue;
            std::string substr = S.substr(S.length() - d.length());
            if (d == substr) {
                S = S.substr(0, S.length() - d.length());
                isFit = true;
                break;
            }
        }
        if (!isFit) {
            canDiv = false;
            break;
        }
        if (S.length() <= 0) {
            canDiv = true;
            break;
        }
    }

    if (canDiv)
        std::cout << "YES\n";
    else
        std::cout << "NO\n";
    return 0;
}


Measured memory_bytes: 512
N,X,Y=map(int,input().split())
klist=[0 for i in range(N-1)]
def returndis(x,y):
  d=min(y-x,1+abs(Y-y)+abs(X-x))
  return d
for i in range(N-1):
  for j in range(N-1-i):
    p=returndis(i+1,j+i+2)
    klist[p-1]+=1

for i in range(N-1):
  print(klist[i])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b,int c){
    int ans=1;
    for(int i=2;i<=min(min(a,b),c);i++){
        if(a%i==0 && b%i==0 && c%i==0) ans=i;
    }
    return ans;
}
int main() {
   int a;
   cin>>a;
   int sum=0;
   for(int i=1;i<=a;i++){
       for(int j=1;j<=a;j++){
           for(int k=1;k<=a;k++){
               sum+=gcd(i,j,k);
           }
       }
   }
  cout<<sum;
   

    
}


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

int f1(int n, int k) {
  int ret = 0;
  int tmp = k;
  while (n >= tmp) {
    tmp += k;
    ret++;
  }
  return ret;
}

int f2(int n, int k, int m) {
  int ret = 0;
  for(int i =1;i<=n;i++){
    if(i%k ==m) ret++;
  }
  return ret;
}



int main() {
  int n, k;
  cin >> n >> k;

  if (k % 2 == 1) {
    int v = f1(n, k);
    ll ans = (ll)v * v * v;
    cout << ans << endl;
  }else{
    int v = f2(n, k, 0);
    ll ans = (ll)v * v * v;
    v = f2(n, k, k/2);
    ans += (ll)v * v * v;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#include<bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr <<"at line "<< __LINE__<<": [" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

const int mx=1e4+5;

int fre[mx];

void solve()
{
	for(int i=1;i<=100;i++)
	{
		for(int j=1;j<=100;j++)
		{
			for(int k=1;k<=100;k++)
			{
				int temp=i*i+j*j+k*k+i*j+j*k+k*i;
				if(temp<mx) fre[temp]++;
			}
		}
	}
	
	int n;
	cin>>n;
	
	for(int i=1;i<=n;i++) cout<<fre[i]<<"\n";
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


Measured memory_bytes: 3548
# At DP F
def paths(M):
    A = [ [0] * len(M[0]) for _ in range(len(M)) ]
    A[0][0] = 1
    for row in range(len(A)):
        for col in range(len(A[row])):
            count = A[row][col]
            if row > 0 and M[row - 1][col] != '#':
                count += A[row - 1][col]
            if col > 0 and M[row][col - 1] != '#':
                count += A[row][col - 1]
            A[row][col] = count
    return A[-1][-1] % 1000000007

X1 = [
    "...#",
    ".#..",
    "...."
]

assert paths(X1) == 3

X2 = [
  "..",
  "#.",
  "..",
  ".#",
  "..",
]

assert paths(X2) == 0

X3 = [
    "..#..",
    ".....",
    "#...#",
    ".....",
    "..#.."
]

assert paths(X3) == 24

X4 = [
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
  "....................",
]
assert paths(X4) == 345263555

h, w = map(int, input().split())
M = [ None ] * h

for i in range(h):
    row = input().strip()
    M[i] = row

ans = paths(M)
print(ans)




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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	class Pair{
		public long A,B;
		public Pair(long a, long b){
			A = a; B = b;
		}
	}
	public void Solve(){
		
		Pair[] P = new Pair[N];
		for(int i=0;i<N;i++) P[i] = new Pair(A[i], B[i]);
		Array.Sort(P, (p, q) => p.B.CompareTo(q.B));
		
		long tot = 0;
		for(int i=0;i<N;i++){
			tot += P[i].A;
			if(tot > P[i].B){
				Console.WriteLine("No");
				return;
			}
		}
		
		Console.WriteLine("Yes");
		
		
	}
	int N;
	int[] A,B;
	public Sol(){
		N = ri();
		A = new int[N];
		B = new int[N];
		for(int i=0;i<N;i++){
			var d = ria();
			A[i] = d[0]; B[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main(void){
    long long n, t[1100], a[1100];
    cin >> n;
    long long ans1, ans2;
    for(int i=0;i<n;++i) cin >> t[i] >> a[i];
    ans1 = t[0];
    ans2 = a[0];
    for(int i=1;i<n;++i){
        long long tmp1, tmp2;
        if(t[i]<ans1 || a[i]<ans2){
            tmp1 = (ans1+t[i]-1)/t[i];
            tmp2 = (ans2+a[i]-1)/a[i];
            t[i] *= max(tmp1, tmp2);
            a[i] *= max(tmp1, tmp2);
        }
        ans1 = t[i];
        ans2 = a[i];
    }
    cout << ans1 + ans2 << endl;
}

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

int main()
{
		int i;
		string s;
		getline(cin, s);
		for (i=0;i<s.size(); i++) {
				if (isupper(s[i])) s[i] = tolower(s[i]);
				else if (islower(s[i])) s[i] = toupper(s[i]);
				else s[i] = s[i];
		}
		cout << s << endl;
}

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

const LL maxn = 1e3+5;
const LL mod = 1e9+7;
LL n,m;
bool state[maxn][maxn];
string s;



int32_t main()
{
    // n row     m column
    cin >> n >> m;
    for(LL i = 1;i<=n;i++){
        cin >> s;
        for(LL j = 0;j<m;j++){
            if(s.substr(j,1) == "."){
                state[i][j+1] = true;
            }
            else{
                state[i][j+1] = false;
            }
        }
    }
    LL dp[maxn][maxn];
    for(LL i = 0;i<=n;i++){
        dp[i][0] = 0;
    }
    for(LL i = 0;i<=m;i++){
        dp[0][i] = 0;
    }
    dp[1][1] = 1;
    for(LL i = 1;i<=n;i++){
        for(LL j = 1;j<=m;j++){
            if(i == 1 && j == 1){
                continue;
            }
            if(!state[i][j]){
                dp[i][j] = 0;
            }
            else{
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
            }
        }
    }

    cout << dp[n][m] << endl;

    return 0;

}


Measured memory_bytes: 12440
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long 
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void go()
{
	cin >> n >> m;
	if( n  < m ) swap(n , m);

	if( m == 1 )
	{
		cout << 1 << endl;
		return;
	}
	int ans = (n*m)/2 + ((n*m)&1);
	cout << ans << endl;
}

int32_t main()
{
	//INP(); 
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}

 

Measured memory_bytes: 5504
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	n = int(rl())
	A = []
	for _ in range(n):
		w, s, v = rli()
		A.append((w, s, v))
	ans = 0
	A.sort(key = lambda I: (I[0] + I[1]))
	maxs = 2*10**4 + 100
	dp = [0 for _ in range(maxs+1)]
	for w, s, v in A:
		for i in range(maxs, -1, -1):
			if i - w < 0: continue
			if i - w > s: continue
			dp[i] = max(dp[i], dp[i-w] + v)
			ans = max(ans, dp[i])	
	print(ans)
	stdout.close()

if __name__ == "__main__":
	main()

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

int main(){
	int i,n;
	double ave,alpha,s[1001];
	while (1){
		scanf("%d",&n);
		if (n==0) break;
		ave=0.0;
		for (i=0;i<n;i++){
			scanf("%lf",&s[i]);
			ave+=s[i];
		}
		ave/=n;
		alpha=0.0;
		for (i=0;i<n;i++){
			alpha+=pow(s[i]-ave,2);
		}
		printf("%lf\n",sqrt(alpha/n));
	}
	return 0;
}

Measured memory_bytes: 664
// Problem : A - Five Variables
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	for(int i = 1; i<=5; i++){
		int n;
		cin >> n;
		if(!n){
			cout << i << "\n";
			break;
		}
	}
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const int INF = 1e9;

ld f(ll x, ll y) { return sqrt(x * x + y * y); }

int main() {
  ll n, d, ans = 0, x, y;
  cin >> n >> d;
  rep(i, n) {
    cin >> x >> y;
    if (f(x, y) <= d) ans++;
  }

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



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

int main(){
  int N,K;
  cin>>N>>K;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  int ans=1e9+7;
  for(int i=0;i+K-1<N;i++)ans=min(ans,v[i+K-1]-v[i]);
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define MOD 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    if(n%2==0)
        cout<<n/2<<endl;
    else
        cout<<n/2+1<<endl;
    return 0;
}

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

int main (){
  int x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,x7,y7;
  cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4 >> x5 >> y5 >> x6 >> y6 >> x7 >> y7;
  
 
  cout << x1 - y1 <<endl << x2 - y2 <<endl<< x3 - y3<<endl<< x4 - y4<<endl<< x5 -y5 <<endl<< x6 - y6 <<endl<< x7 - y7 <<endl;
  return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
struct data {
  int nt, to;
} a[N << 1];
int head[N], w[N], cnt = 0;

void add(int x, int y) {
  a[++cnt].to = y;
  a[cnt].nt = head[x];
  head[x] = cnt;
}

int tot = 0, ans = 0, d[N], us[N];

void dfs(int u, int fa) {
  us[u] = w[u];
  for(int i = head[u]; i; i = a[i].nt) {
    int to = a[i].to;
    if(to == fa) continue;
    dfs(to, u);
    us[u] &= us[to];
    if(!us[to] && !us[u]) d[to]++, d[u]++;
  }
}

int f1[N], f2[N], v[N], inf = -1e6;
void go(int u, int fa) {
  tot += d[u];
  if((d[u] + w[u]) & 1) v[u] = 0;
  else v[u] = 2, ++tot;
  int mx1 = 0, mx2 = 0, flg = 0;
  for(int i = head[u]; i; i = a[i].nt) {
    int to = a[i].to;
    if(to == fa || us[to]) continue;
    flg = 1;
    go(to, u);
    ans = max(ans, max(mx1 + f2[to] + v[u], mx2 + f1[to] + v[u]));
    mx1 = max(mx1, f1[to]), mx2 = max(mx2, f2[to]);
  }
  mx1 += v[u], mx2 += v[u];
  f1[u] = mx1, f2[u] = flg ? mx2 : inf;
}

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 2, x, y; i <= n; ++i) {
    scanf("%d%d", &x, &y);
    add(x, y), add(y, x);
  }
  int rt = 0;
  for(int i = 1; i <= n; ++i) {
    char ch;
    cin >> ch;
    if(ch == 'W') w[i] = 0, rt = i;
    else w[i] = 1;
  }
  if(!rt) puts("0");
  else {
    dfs(rt, 0);
    go(rt, 0);
    printf("%d\n", tot - ans);
  }
  return 0;
}

Measured memory_bytes: 12288
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,a,b,k=map(int,input().split())\n"
"m=998244353\n"
"I=[0]*n\n"
"for i in range(n):\n"
"  I[i]=pow(i+1,m-2,m)\n"
"c=[0]*(n+1)\n"
"c[0]=1\n"
"for i in range(1,n+1):\n"
"  c[i]=(c[i-1]*(n-i+1)*I[i-1])%m\n"
"q=0\n"
"for i in range(n+1):\n"
"  j=(k-i*a)//b\n"
"  if (k-i*a)%b or j<0 or j>n:continue\n"
"  q=(q+c[i]*c[j])%m \n"
"print(q%m)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 29036
// base: https://atcoder.jp/contests/agc030/submissions/7566849#
// cf. https://ferin-tech.hatenablog.com/entry/2019/01/04/052343

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

ll N, L;

ll solve(const vector<ll>& x) {
  vector<ll> sumx(x);
  for (int i = 1; i < N; i++) {
    sumx[i] += sumx[i - 1];
  }

  ll res = 0;
  rep(i, N) {  // i: starting point of turn.
    int mid = i + (N - i) / 2;  // The last index. e.g. If N = 10 and i = 0, then mid = 5.
    if ((N - i) % 2 == 0) {  // The number of remaining is odd. e.g. 0, 1, ... 9 exist, and i = 0. remaining is 1, 2, ... 9. mid is 5.
      // The result is (X[i]) + (X[i] + revX[N-1]) + (revX[N-1] + X[i+1]) + ... + (X[mid-1] + revX[mid]) = (X[i]*2 + X[i+1]*2 + ... X[mid-1]*2) + ((L-X[mid+1])*2 + (L-X[mid+2])*2 + ... + (L-X[N-1])*2) + (L - X[mid])
      // = (X[i] + X[i+1] + ... + X[mid-1])*2 + (L-X[mid]) + (L-X[mid+1] + L-X[mid+2] + ... + L-X[N-1])*2

      // [i, mid-1]
      ll val = 2 * (sumx[mid] - x[mid] - (sumx[i] - x[i])); // Same with sumx[mid-1] - sumx[i-1] when mid > 0 and i > 0
      // [mid]
      val += L - x[mid];
      // [mid + 1, N-1]
      val += 2 * (N - 1 - mid) * L - 2 * (sumx[N - 1] - sumx[mid]);
      res = max(res, val);
    } else {  // The number of remaining is even. e.g. 0, 1, ... 8 exist, and i = 0. remaining is 1, 2, ... 8. mid is 4.
      // (X[i] + X[i+1] + ... + X[mid-1])*2 + X[mid] + (L-X[mid+1] + L-X[mid+2] + ... + L-X[N-1])*2

      // [i, mid-1]
      ll val = 2 * (sumx[mid] - x[mid] - (sumx[i] - x[i])); // Same with sumx[mid-1] - sumx[i-1] when mid > 0 and i > 0
      // [mid]
      val += x[mid];
      // [mid + 1, N-1]
      val += 2 * (N - 1 - mid) * L - 2 * (sumx[N - 1] - sumx[mid]);
      res = max(res, val);
    }
  }
  return res;
}

int main(int argc, char** argv) {
  cin >> L >> N;
  vector<ll> X(N);
  rep(i, N) {
    cin >> X[i];
  }
  // Try anti-clock order at first.
  ll ans = 0;
  ans = max(ans, solve(X));

  // Calculate reversed.
  reverse(all(X));
  rep(i, N) {
    X[i] = L - X[i];
  }
  ans = max(ans, solve(X));

  cout << ans << endl;
}


Measured memory_bytes: 3428
import sys
from collections import Counter

a, b, c, d = map(int, input().split())
f_array = [0, 0]
l_array = [0, 0]

if a == c:
    if b == d:
        print(b - a)
    else:
        print(min(b - a, d - c))
    sys.exit()    

elif a < c:
    f_array[0], f_array[1] = a, b
    l_array[0], l_array[1] = c, d
else:
    f_array[0], f_array[1] = c, d
    l_array[0], l_array[1] = a, b

if f_array[1] < l_array[1]:
    if f_array[1] - l_array[0] < 0:
        print(0)
    else:
        print(f_array[1] - l_array[0])
    sys.exit()
else:
    print(l_array[1] - l_array[0])


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
    public static void main (String[] args){
        solve2000();
    }

    static int robo_x;
    static int robo_y;
    static boolean[][] map;

    public static void solve2000() {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int N = sc.nextInt();
            if(N == 0){
                break;
            }
            // ???????????????
            map = new boolean[21][21];
            for(int n = 0; n < N; n++){
                int x = sc.nextInt();
                int y = sc.nextInt();
                // ??\???????????????????????????????????????
                map[y][x] = true;
            }

            // ????????????????????¨??????????????????
            robo_x = 10;
            robo_y = 10;

            int M = sc.nextInt();
            for(int m = 0; m < M; m++){
                String direction = sc.next();
                int stepCount = sc.nextInt();
                // ????????¨??§???????????\???
                move(direction, stepCount);
            }

            //map???true????????£????????????No
            boolean result = true;
            for(int i=0; i < map.length; i++){
                for(int j=0; j < map[i].length; j++){
                    if(map[i][j] == true){
                        result = false;
                        break;
                    }
                }
            }
            System.out.println(result ? "Yes" : "No");
        }
    }

    public static void move(String direction, int stepCount){
        for(int i = 0; i < stepCount; i++) {
            switch (direction) {
                case "N":
                    // ?????¨???????????´??°
                    robo_y++;
                    // map????§???????????????????false
                    map[robo_y][robo_x] = false;
                    break;
                case "E":
                    robo_x++;
                    map[robo_y][robo_x] = false;
                    break;
                case "S":
                    robo_y--;
                    map[robo_y][robo_x] = false;
                    break;
                case "W":
                    robo_x--;
                    map[robo_y][robo_x] = false;
                    break;
                default:
                    break;
            }
        }
    }
}

Measured memory_bytes: 42716
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin >> s;
    bool a = 0,b = 0;
    for(int i = 0; i < s.size();i++){
        if(a == 0){
            if(s[i] == 'C'){
                a = 1;
            }
        }
        if(a == 1){
            if(s[i] == 'F')
            b = 1;
        }
    }
    if(a == 1 && b == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int LMAX=300+2,MAXVAL=LMAX*LMAX;
int nbLig,nbCol,d,val[LMAX][LMAX],q,l,r,ligVal[MAXVAL],colVal[MAXVAL],dp[MAXVAL];

int abs(int x){
	return max(x,-x);
}

void memoizer(int x){
	if(x<=d) return;
	
	dp[x]=dp[x-d]+abs(ligVal[x]-ligVal[x-d])+abs(colVal[x]-colVal[x-d]);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> nbLig >> nbCol >> d;
	
	for(int i=0;i<nbLig;i++){
		for(int j=0;j<nbCol;j++){
			cin >> val[i][j];
			
			ligVal[val[i][j]]=i;
			colVal[val[i][j]]=j;
		}
	}
	
	
	cin >> q;
	
	
	for(int i=1;i<=nbLig*nbCol;i++) memoizer(i);
	
	for(int i=0;i<q;i++){
		cin >> l >> r;
		cout << dp[r]-dp[l] << '\n';
	}
			
	
	
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef pair<string,int> Ps;
typedef pair<int,int> P;
int main(void){
  int n,i,j,p[110];
  string s;
  vector<Ps> r;
  cin >> n;
  for (i=0;i<n;i++){
    cin >> s >> p[i];
    r.push_back(Ps(s,i));
  }
  sort(r.begin(),r.end());
  i=0;
  while (i<n){
    vector<P> rk;
    while (i<n && (rk.size()==0 || r[i].first==r[i-1].first)){
      rk.push_back(P(p[r[i].second],r[i].second));
      i++;
    }
    sort(rk.begin(),rk.end(),greater<P>());
    for (j=0;j<rk.size();j++) cout << rk[j].second+1 << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int a, b;
        cin >> a >> b;
        for (int x = 0; x <= 100000; x++)
                if (8 * x / 100 == a && 10 * x / 100 == b) {
                        cout << x << "\n";
                        return 0;
                }
        cout << "-1\n";
        return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc152/tasks/abc152_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll a, b;
  cin >> a >> b;

  if (a >= b) {
    cout << string(a, '0' + b) << endl;
  } else {
    cout << string(b, '0' + a) << endl;
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define MAXN 100005
# define eps 1e-5
# define MAXM 500001
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
typedef long long LL;
typedef unsigned long long ULL;
int _MAX(int a, int b){return a>b?a:b;}
int _MIN(int a, int b){return a>b?b:a;}

char s[100005];

int main ()
{
    int flag;
    scanf("%s",s);
    int len=strlen(s);
    if (s[0]==s[len-1]) flag=!(len%2);
    else flag=len%2;
    puts(flag?"First":"Second");
    return 0;
}


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

int main(void){
    string str1, str2;
    cin >> str1 >> str2;
    
    int result = 0;
    
    for (int i = 0; i < str1.size(); i++){
        if (str1[i] != str2[i]) result++;
    }
    
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>

int main(){

  int a;
  std::cin >> a;
  //std::cout << a << std::endl;

  long int sum = 0;

  for(int i=1; i<a+1; i++){
    if(i % 3 != 0 && i % 5 != 0){
      sum += i;
    }
  }

  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 3188
fun main() {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(java.util.Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun <A> List<Comparable<A>>.upperBoundOf(target: A): Int {
        var l = -1
        var r = this.count()
        while (l + 1 < r) {
            val mid = (l + r) / 2
            if (this[mid] > target) {
                r = mid
            } else {
                l = mid
            }
        }
        return r
    }

    lateinit var count: (al: List<Int>, bl: List<Int>, cl: List<Int>) -> Long

    fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val S = sc.next().toCharArray()
        val R = mutableListOf<Int>()
        val G = mutableListOf<Int>()
        val B = mutableListOf<Int>()
        repeat(N) { i ->
            when {
                S[i] == 'R' -> R += i
                S[i] == 'G' -> G += i
                S[i] == 'B' -> B += i
            }
        }

        count = { al, bl, cl ->
            var ans = 0L
            val cs = cl.toSet()
            al.forEach { a ->
                bl.forEach { b ->
                    if (a < b) {
                        ans += cl.count() - cl.upperBoundOf(b)
                        if (cs.contains(b + b - a)) {
                            ans--
                        }
                    }
                }
            }
            ans
        }

        var ans = 0L
        ans += count(R, G, B)
        ans += count(R, B, G)
        ans += count(G, B, R)
        ans += count(G, R, B)
        ans += count(B, R, G)
        ans += count(B, G, R)
        pw.println(ans)
    }
}


Measured memory_bytes: 57352
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	ll a,v,b,w,t;
	cin >> a >> v >> b >> w >> t;
	if(a == b){
		cout << "YES" << endl;
		return 0;
	}
	if(w >= v){
		cout << "NO" << endl;
		return 0;
	}
	ll dist = abs(a-b);
	ll vel = v - w;

	if(vel * t < dist){
		cout << "NO" << endl;
	}
	else cout << "YES" << endl;
}


Measured memory_bytes: 3636
let lower_bound (a : int array) first last v =
  let rec doit len first =
    if len = 0 then first
    else
      let half = len / 2 in
      let mid = first + half in
      if a.(mid) < v then doit (len - half - 1) (mid + 1)
      else doit half first in
  doit (last - first + 1) first

let () =
  let n = read_int () in
  let dp = Array.make (n + 1) max_int in
  for _ = 0 to n - 1 do
    let a = read_int () in
    dp.(lower_bound dp 0 n a) <- a
  done;
  lower_bound dp 0 n max_int |> Printf.printf "%d\n"

Measured memory_bytes: 5232
/*
                                             ::                     ::
                                             ':                     :
                                              :.                    :
                                           ;' ::                   ::  '
                                          .'  ';                   ;'  '.
                                         ::    :;                 ;:    ::
                                         ;      :;.             ,;:     ::
                                         :;      :;:           ,;"      ::
                                         ::.      ':;  ..,.;  ;:'     ,.;:
                                          "'"...   '::,::::: ;:   .;.;""'
                                              '"""....;:::::;,;.;"""
                                          .:::.....'"':::::::'",...;::::;.
                                         ;:' '""'"";.,;:::::;.'""""""  ':;
                                        ::'         ;::;:::;::..         :;
                                       ::         ,;:::::::::::;:..       ::
                                       ;'     ,;;:;::::::::::::::;";..    ':.
                                      ::     ;:"  ::::::"""'::::::  ":     ::
                                       :.    ::   ::::::;  :::::::   :     ;
                                        ;    ::   :::::::  :::::::   :    ;
                                         '   ::   ::::::....:::::'  ,:   '
                                          '  ::    :::::::::::::"   ::
                                             ::     ':::::::::"'    ::
                                             ':       """""""'      ::
                                              ::                   ;:
                                              ':;                 ;:"


                                                     P_r_A_d_Y
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 300005;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void cs(int &x)
{
    cout << "Case #" << x << ": ";
}
bool cmp(string a, string b)
{
    return a + b < b + a;
}

int32_t main()
{
    // fastIO;
    // int t; cin >> t;
    // int x = 1;
    // while (t--)
    // {
       int n;cin>>n;
       map<string,int>m;
       string s;
       for(int i=0;i<n;i++)
       {cin>>s;m[s]++;}

       cout<<m.size()<<endl; 
        
    // }
    return 0;
}


Measured memory_bytes: 19052
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
	map<string,int>mp;
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		string str;cin>>str;
		mp[str]++;
	}
	cout<<"AC x "<<mp["AC"]<<'\n';
	cout<<"WA x "<<mp["WA"]<<'\n';
	cout<<"TLE x "<<mp["TLE"]<<'\n';
	cout<<"RE x "<<mp["RE"]<<'\n';
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);	 
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(long long (i)=0;(i)<(n);(i)++)
#define ll long long
#define pr_qu priority_queue
#define vec(name,size,common) vector<ll> (name)((size),(common))
 
 
 
 
 
int main(){

char a,b;
cin>>a>>b;

if(a==b){
  cout<<'H';
}else{
  cout<<'D';
}
}

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

using namespace std;
static const int N = 100;
static const int INFTY = (1 << 21);

int n, M[N][N];
int d[N];


void bfs(int s) {
	queue<int> q;
	q.push(s);
	for (int i = 0;i < n;i++) d[i] = INFTY;
	d[s] = 0;
	int u;
	while (!q.empty()) {
		u = q.front();q.pop();
		for (int v = 0;v < n;v++) {
			if (M[u][v] == 0)continue;
			if (d[v] != INFTY)continue;
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	for (int i = 0;i < n;i++) {
		cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
	}
}

int main() {
	int u, k, v;
	cin >> n;
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			M[i][j] = 0;
		}
	}

	for (int i = 0;i < n;i++) {
		cin >> u >> k;
		u--;
		for (int j = 0;j < k;j++) {
			cin >> v;
			v--;
			M[u][v] = 1;

		}
	}
	bfs(0);
}


Measured memory_bytes: 3120
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(),(x).end()

using namespace std;

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


template<typename T>
void dump(T *arr, int h, int w){
	rep(i,h){
		rep(j,w) cout << arr[i][j] << "\t";
		cout << "\n";
	}
}

template<typename T>
void dump(T *arr, int a){
	rep(i,a) cout << arr[i] << "\t";
	cout << "\n";
}

const int INF = 1e9;
const int MOD = 1e9+7;

bool compare(P a, P b){
	if(a.second != b.second) return a.second > b.second;
	else	return a.first > b.first;
}


int digits(ll num){
	ll d=0;
	while(num >= 1){
		num/= 10;
		d++;
	}
	return d;
}

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

	int n, k;
	cin >> n >> k;

	int h[n];
	rep(i,n){
		cin >> h[i];
	}
	sort(h, h+n, greater<int>());
	
	ll ans = 0;
	repi(i, k, n){
		ans += h[i];
	}

	cout << ans << "\n";
	return 0;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  int n, k;
  cin>>n>>k;
  //Sieve sieve(k);
  vector<mint> d(k+1);
  for (int i=k;i>=1;i--){
    d[i]=mint(k/i).pow(n);
    int now=i+i;
    while (now<=k){
      d[i]-=d[now];
      now+=i;
    }
  //  cout<<d[i]<<endl;
  }

  mint ans=0;
  rep(i,k){
    mint temp=d[i+1];
    temp*=(i+1);
    ans+=temp;
  }
cout<<ans;
}


Measured memory_bytes: 4056
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#define Lens 1005

using namespace std;
string x, y;
int C[Lens][Lens];
int N;

int com(string x,string y)
{
	int m = x.length();
	int n = y.length();
	x = ' ' + x;
	y = ' ' + y;
	for(int i=1;i<=m;i++)
		for (int j = 1; j <= n; j++)
		{
			if (x[i] == y[j])
			{
				C[i][j] = C[i - 1][j - 1] + 1;
			}
			else
			{
				C[i][j] = max(C[i - 1][j], C[i][j - 1]);
			}
		}
	return C[m][n];

}

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> x >> y;
		int ans=com(x, y);
		cout << ans << endl;
	}


	return 0;
}



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

int main() {
	long long int n;
	long long int ans = 0;
	long long int temp = 0;
	cin>>n;
	
	ans = n/500;
	ans = ans*1000;
	temp = n%500;
	temp = temp/5;
	ans+=(5*temp);
	
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int result = 700;
  if (s[0] == 'o') result += 100;
  if (s[1] == 'o') result += 100;
  if (s[2] == 'o') result += 100;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[1000];
int main()
{
	int n,ans=0;	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x=1;
		while(i/x>=10)
			x*=10;
		if(i%10==0)
			continue;
		a[i/x*10+i%10]++;
		//cout<<i<<" "<<i/x*10+i%10<<endl;
	}
	for(int i=1;i<=9;i++)
		for(int j=i+1;j<=9;j++)
			ans+=a[i*10+j]*a[j*10+i]*2;
	for(int i=11;i<=99;i+=11)
		ans+=a[i]*a[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(V) V.begin,V.end
const int N = 100005;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if(s[5]>'0' || s[6]>'4')
    cout << "TBD";
    else if(s[5]=='0' && s[6]=='4')
    {
        if(s[8]<='3')
        {
            cout << "Heisei";
        }
        else
        cout << "TBD";
    }
    else
    cout << "Heisei";
    
}

Measured memory_bytes: 256
N = int(input())
*A, = map(int, input().split())
m = max(A)
cnt = [0] * (m + 1)
for elem in A:
    cnt[elem] += 1
# print(cnt)

unique = []
for i in range(m + 1):
    if cnt[i] == 1:
        unique.append(i)
# print(unique)
# unique = list(set(A))

cnt = [0] * (m + 1)
A = list(set(A))
for elem in A:
    for mul in range(elem * 2, m + 1, elem):
        cnt[mul] = 1
ans = 0

for elem in unique:
    if cnt[elem] == 0:
        ans += 1
print(ans)

Measured memory_bytes: 48028