akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d;
    cin >> d;
    vector<int> c(26);
    for(int i=0; i<26; i++) cin >> c[i];
    vector<vector<int>> G(d,vector<int> (26));
    for(int i=0; i<d; i++){
        for(int j=0; j<26; j++){
            cin >> G[i][j];
        }
    }
    vector<int> t(d);
    for(int i=0; i<d; i++){
        cin >> t[i];
        t[i]--;
    }
    int m;
    cin >> m;
    for(int k=0; k<m; k++){
        int a,b;
        cin >> a >> b;
        a--;b--;      
        t[a] = b;
        vector<int> now(26,0);
        vector<int> last(26,0);
        for(int i=0; i<d; i++){
            last[t[i]] = i+1;
            now[t[i]] += G[i][t[i]];
            for(int j=0; j<26; j++){
                now[t[i]] -= c[j] * (i+1 - last[j]);
            }
        }
        int sum = 0;
        for(int j=0; j<26; j++){
            sum += now[j];
        }
        cout << sum << "\n";
    }
    return 0;
}

Measured memory_bytes: 3672
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String[] line = reader.readLine().split(" ");
		int n = Integer.parseInt(line[0]);
		int q = Integer.parseInt(line[1]);
		Queue<String[]> queue = new ArrayDeque<String[]>();
		for (int i = 0; i < n; i++) {
			queue.add(reader.readLine().split(" "));
		}
		String[] work = new String[2];
		int elapse = 0;
		while ((work = queue.poll()) != null) {
			int time = Integer.parseInt(work[1]);
			if (time <= q) {
				elapse += time;
				builder.append(work[0]).append(" ").append(elapse).append("\n");
			} else {
				time -= q;
				elapse += q;
				work[1] = String.valueOf(time);
				queue.add(work);
			}

		}
		System.out.print(builder);
	}
}


Measured memory_bytes: 66324
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5+5;
const int inf = 1001*1000*1000;
#define pb push_back
#define mp make_pair
vector<int> obj[maxN];
vector<pair<int,int>> bre;
int n,e,mark[maxN],fa[maxN],dp[maxN],hig[maxN];
pair<int,int> jof;
void dfs(int u)
{
	mark[u] =1;
	dp[u]=inf;
	for(int v:obj[u])
	{
		if(!mark[v])
		{
			hig[v]=hig[u]+1;
			mark[v]=1;
			fa[v]=u;
			dfs(v);
			dp[u]=min(dp[u],dp[v]);
		}
		else if(v!=fa[u]&&hig[v]<hig[u])
		{
			dp[u]=min(dp[u],hig[v]);
		}
	}
	if(dp[u]>=hig[u]&&u!=fa[u])
	{
		jof = mp(min(u,fa[u]),max(u,fa[u]));
		bre.pb(jof);
	}
}
int main()
{
	cin>>n>>e;
	int u,v;
	for(int i=0;i<e;i++)
	{
		cin>>u>>v;
		obj[u].pb(v);
		obj[v].pb(u);
	}
	dfs(0);
	sort(bre.begin(),bre.end());
	for(int i=0;i<bre.size();i++)
	{
		cout<<bre[i].first<<" "<<bre[i].second<<endl;
	}
}



Measured memory_bytes: 6760
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		// n=s.length();
		// ll a[n];
		repe(i,1,n+1)
		{
			m=to_string(i).size();
			if(m&1)c++;
		}
		
		cout<<c;
		
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
main(){int m,d,s[]={0,31,60,91,121,152,182,213,244,274,305,335};char a[7][9]={"Thurs","Fri","Satur","Sun","Mon","Tues","Wednes"};
  while(1)
    {
      scanf("%d %d",&m,&d);
      if(m==0)
	break;
      d+=s[m-1];
      printf("%sday\n",&a[(d%7==0)?6:(d%7-1)][0]);
    }
  return 0;
}

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

#define MAXN (100010)

int n, c, k;
int t[MAXN];

int main(){
	scanf("%d%d%d", &n, &c, &k);
	for(int i = 1; i <= n; ++ i){
		scanf("%d", t + i);
	}
	std::sort(t + 1, n + t + 1);
	int ans = 0;
	for(int i = 1; i <= n; ){
		int depart = t[i] + k, now = 0;
		ans ++;
		while(now < c && t[i] <= depart && depart <= t[i] + k){
			now ++;
			i ++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
    int a,b,n,T,cas=0;
    int A[5];
    cin>>A[0]>>A[1]>>A[2];
    sort(A,A+3);
    int s=A[1]-A[0];
    s+=A[2]-A[1];
    cout<<s;
    return 0;
}

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

using namespace std;
#define ll long long

int main(){
  ll n,k;
  vector<ll> h;
  std::cin>>n>>k;
  ll i,j;
  for(i=0;i<n;i++)
  {
    std::cin>>j;
    h.push_back(j);
  }
  sort(h.begin(),h.end());
  ll count=0;
  for(i=0;i<n-k;i++)
  {
    count+=h[i];
  }
  std::cout<<count;
  return 0;
}
      

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

int main(){
  ll N, x;  cin >> N >> x;
  vector<ll> a(N);
  for(ll i = 0; i < N; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  
  ll ans = 0;
  ll cnt = 0;
  while(x > 0){
    if(cnt == N-1){
      if(x == a[cnt]) ans++;
      break;
    }
    if(x >= a[cnt]){
      ans++;
      x -= a[cnt];
    }else
      break;
    
    cnt++;
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int n;
	cin >> n;
	vector<ll> a(n);

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

	ll ans = 0;
	for (int i = a.size() - 1; i >= 0; i--)
	{
		if ((i + 1) % 2 == 1)
		{
			ans += a[i];
		}
		else
		{
			ans -= a[i];
		}
	}

	vector<ll> ansD(n);
	ansD[0] = ans;
	cout << ansD[0];
	for (int i = 1; i < n; i++)
	{
			ansD[i] = a[i-1] * 2 - ansD[i-1];
			cout << " " << ansD[i];
	}
	cout << endl;

}

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

int main()
{
    int mark[10009];
    int n;
    while(cin>>n)
    {
        memset(mark,0,sizeof(mark));
        int cnt = 0;
        for(int i=1; i<=n; i++)
        {
            int val;
            cin>>val;
            if(!mark[val])
            {
                ++cnt;
                mark[val] = 1;
            }
        }
        cout<<cnt<<endl;
    }
}


Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		mut cs: Chars,
	}

	if (cs[0] == cs[1] && cs[1] == cs[2]) || (cs[1] == cs[2] && cs[2] == cs[3]) {
		println!("Yes");
	}
	else {
		println!("No");
	}
}



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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   string s;
   cin>>s;
   cout << s[0] << s[1] << s[2] << endl;
   return 0;
}


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

using namespace std;

const int MAXN = 500005;
const int INF = 1000000007;

int n, k, ofs;
int p[MAXN], fen[MAXN], d[MAXN], sol[MAXN];

struct node {
    int val, pos, prop;
    node () {
        val = INF; pos = prop = 0;
    }
    node (int _val, int _pos) {
        val = _val; pos = _pos; prop = 0;
    }
} t[MAXN * 3];

void propagate (int x) {
    if (t[x].prop == 0) return;
    if (x < ofs) {
        t[2*x].prop += t[x].prop;
        t[2*x+1].prop += t[x].prop;
    }
    t[x].val += t[x].prop;
    t[x].prop = 0;
}

node spoji (node a, node b) {
    if (a.val < b.val) return a;
    if (a.val > b.val) return b;
    if (a.pos < b.pos) return a; return b;
}

void build () {
    ofs = 1;
    while (ofs < n) ofs *= 2;
    for (int i=0; i<n; i++) {
        t[i + ofs] = node(d[i], i);
    }
    for (int i = ofs-1; i > 0; i--) {
        t[i] = spoji(t[2*i], t[2*i+1]);
    }
}

void update (int x, int from, int to, int low, int high, int val) {
    propagate(x);
    if (from <= low && high <= to) {
        t[x].prop += val;
        propagate(x);
        return;
    }
    if (to < low || high < from) return;
    update(2*x, from, to, low, (low + high)/2, val);
    update(2*x+1, from, to, (low + high)/2 + 1, high, val);
    t[x] = spoji(t[2*x], t[2*x+1]);
}

void ubaci (int x, int k) {
    for (; x < MAXN; x += x&-x) fen[x] += k;
}

int upit (int x) {
    int res = 0;
    for (; x > 0; x -= x&-x) res += fen[x];
    return res;
}

void get_deg () {
    for (int i=0; i<k; i++) {
        ubaci(p[i], 1);
    }
    for (int i=0; i<n; i++) {
        d[i] = upit(p[i]) - 1;
        if (i + k < n) ubaci(p[i + k], 1);
        if (i - k + 1 >= 0) ubaci(p[i - k + 1], -1);
    }
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i=0; i<n; i++) {
        cin >> p[i];
    }
    get_deg();
    build();
    for (int i=1; i<=n; i++) {
        node curr = t[1];
        sol[curr.pos] = i;
        update(1, max(0, curr.pos - k + 1), min(n-1, curr.pos + k - 1), 0, ofs-1, -1);
        update(1, curr.pos, curr.pos, 0, ofs-1, INF);
    }
    for (int i=0; i<n; i++) {
        cout << sol[i] << endl;
    }
    return 0;
}


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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

ll n, x;

ll f(ll a, ll b) {
  return b % a == 0 ? (2 * b / a - 1) * a : 2 * a * (b / a) + f(b % a, a);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> x;
  cout << n + f(x, n - x) << "\n";
}


Measured memory_bytes: 256
L,R = map(int,input().split())
ans = 10**9
for i in range(L, min(L+2020, R+1)):
    for j in range(i+1, min(L+2020, R+1)):
        if i*j % 2019 < ans:
            ans = i*j%2019
        if ans == 0:
            print(ans)
            exit()
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 3010
using namespace std;
ll n,m,k,dp[N][N][4],val[N][N];
int main(){
	ll i,j,l,x,y,z;
	scanf("%lld%lld%lld",&n,&m,&k);
	for(i=0;i<k;i++)
	{
		scanf("%lld%lld%lld",&x,&y,&z);
		x--;
		y--;
		val[x][y]=z;
	}
	memset(dp,-127,sizeof(dp));
	dp[0][0][0]=0;
	dp[0][0][1]=val[0][0];
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			if(i>0)
			{
				dp[i][j][0]=max(dp[i-1][j][0],max(dp[i-1][j][0],max(dp[i-1][j][1],max(dp[i-1][j][2],dp[i-1][j][3]))));
				dp[i][j][1]=max(dp[i][j][1],val[i][j]+max(dp[i-1][j][0],max(dp[i-1][j][1],max(dp[i-1][j][2],dp[i-1][j][3]))));
			}
			if(j>0)
			{
				dp[i][j][0]=max(dp[i][j][0],dp[i][j-1][0]);
			}
			for(l=1;l<4;l++)
			{
				if(j>0)
				{
					dp[i][j][l]=max(dp[i][j][l],dp[i][j-1][l-1]+val[i][j]);
					dp[i][j][l]=max(dp[i][j][l],dp[i][j-1][l]);
				}
			}
		}
	}
	printf("%lld\n",max(dp[n-1][m-1][0],max(dp[n-1][m-1][1],max(dp[n-1][m-1][2],dp[n-1][m-1][3]))));
	return 0;
}

Measured memory_bytes: 357236
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define maxn 100009
using namespace std;
int n, m;
int cnt[maxn];
bool check(){
	for(int i  = 1; i <= n; i++)
		if(cnt[i] % 2 == 1)
			return 0;
	return 1;
}
int main(){
	cin >> n >> m;
	for(int i = 1; i <= m ; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		cnt[x]++;
		cnt[y]++;
	}
	if(check())
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 640
# F - LIS on Tree
import bisect
import sys
sys.setrecursionlimit(10**7)

INF = 10**18

n = int(input())
a = list(int(x) for x in input().split())
g = [[] for _ in range(n)]
for _ in range(n-1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)

def dfs(now, par):
    idx = bisect.bisect_left(dp, a[now])    
    tmp = dp[idx]
    dp[idx] = a[now]
    # 親のLIS以上であれば、その値で更新
    if ans[par] <= idx:
        ans[now] = idx
    # そうでなければ親のLISを引き継ぐ
    else:
        ans[now] = ans[par]

    for i in g[now]:
        if i!=par:
            # 次にみる頂点と、自分（親）の情報を渡す
            dfs(i, now)
    dp[idx] = tmp

ans = [0] * n
dp = [-INF] + [INF] * n
dfs(0, -1)
for a in ans:
    print(a)


Measured memory_bytes: 221168
#include<stdio.h>

int field[91][91], n, m;
int xm[] = {0, 1, 0, -1}, ym[] = {1, 0, -1, 0};
int dfs(int x, int y){
  int i, res = 1;
  for(i = 0;i < 4;i++){
    int nx = x + xm[i];
    int ny = y + ym[i];
    if(nx < 0 || nx >= n || ny < 0 || ny >= m){
      continue;
    }
    field[x][y] = 0;
    if(field[nx][ny] == 1){
      int longest = dfs(nx, ny) + 1;
      if(longest > res){
	res = longest;
      }
    }
    field[x][y] = 1;
  }
  return res;
}

int main(){
  while(1){
    int i, j, max = 0;
    scanf("%d%d", &m, &n);
    if(m == 0 && n == 0){
      break;
    }

    for(i = 0;i < n;i++){
      for(j = 0;j < m;j++){
	scanf("%d",field[i] + j);
      }
    }
    
    for(i = 0;i < n;i++){
      for(j = 0;j < m;j++){
	if(field[i][j] == 1){
	  int longest = dfs(i, j);
	  if(longest > max){
	    max = longest;
	  }
	}
      }
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 632
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	long long int N,s,k;
	long long int ans=0;
	cin>>N;
	for(long long int i=1;i<=N;i++){
		s=N/i;
		ans+=i*s*(s+1)/2;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long 

using namespace std ;

int n ;
int height[100001];
int dp[100002];

int32_t main(){
        ios_base::sync_with_stdio(0); cin.tie(0);

        cin >> n; 
        for(int i=0;i<n;i++)
                cin>>height[i];
        
        dp[0]=0; dp[1]=abs(height[0]-height[1]);
        for(int i=2;i<n;i++){
                dp[i] = min(dp[i-2]+abs(height[i]-height[i-2]),dp[i-1]+abs(height[i-1]-height[i]));
        }

        cout << dp[n-1] << endl;

        return 0;
}

Measured memory_bytes: 1920
import sys
import math
import copy
import itertools
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def solve():
    n,C = getList()
    li = []

    start = [[0] * 100100 for i in range(31)]
    end = [[0] * 100100 for i in range(31)]
    pt = [0] * 100100

    for i in range(n):
        s, t, c = getList()
        start[c][s] += 1
        end[c][t] += 1
        pt[s] += 1
        pt[t+1] -= 1

    for i in range(100099):
        pt[i+1] += pt[i]

    ans = 0
    for i in range(100100):
        tmp = pt[i]
        for j in range(31):
            if start[j][i] and end[j][i]:
                tmp -= 1
        ans = max(ans, tmp)

    print(ans)






def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()


Measured memory_bytes: 143180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    vector<ll> a(3);
    cin >> a[0] >> a[1] >> a[2];

    if(a[0]%2 && a[1]%2 && a[2]%2){
        sort(all(a));
        cout << a[0]*a[1] << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,q;
    	scanf("%d %d\n",&n,&q);
    	char s[n];
    	int l[2][q];
    	scanf("%s",s);
    	int i=0;
  	int h[n];
    	h[0]=0;
     	for(i=0;i<q;i++){
    		scanf("%d %d\n",&l[0][i],&l[1][i]);
    	}
    	for(i=0;i<n-1;i++){
    		if(s[i]=='A'&&s[i+1]=='C') h[i+1] = 1+h[i];
    		else h[i+1]=h[i];
    	}
    	for(i=0;i<q;i++){
    		printf("%d\n",h[l[1][i]-1]-h[l[0][i]-1]);
    	}
    	return 0;
}

Measured memory_bytes: 2048
N=int(input())
a=list(map(int, input().split()))
b=[0]*N

for i in range(N-1,-1,-1):
  summ = sum(b[2*i+1::i+1])
  if summ%2==0:
    b[i] = a[i]
  else:
    b[i] = 1-a[i]
  #print(i,summ,b[i])
    
ans=[]
print(sum(b))
for i,num in enumerate(b):
  if num==1:
    ans.append(i+1)

print(*ans)

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

int d[100000];
int c1[100000], c2[100000];
vector<int>E[100000];
void bfs(int*c, int s) {
	memset(d, -1, sizeof(d));
	queue<int>que;
	d[s] = 0; que.push(s);
	while (!que.empty()) {
		int p = que.front(); que.pop();
		c[d[p]]++;
		for (int v : E[p]) {
			if (d[v] == -1) {
				d[v] = d[p] + 1; que.push(v);
			}
		}
	}
}
int main() {
	int n, m, s, t; scanf("%d%d%d%d", &n, &m, &s, &t); s--; t--;
	rep(i, m) {
		int x, y; scanf("%d%d", &x, &y); x--; y--;
		E[x].push_back(y); E[y].push_back(x);
	}
	bfs(c1, t); bfs(c2, s);
	ll ans = 0;
	for (int i = 0; i <= d[t] - 2; i++) {
		ans += (ll)c1[i] * c2[d[t] - 2 - i];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 9736
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int kk = sc.nextInt();
		
		char[][] map = new char[h][w];
		for(int i=0; i<h; i++){
			String str = sc.next();
			map[i] = str.toCharArray();
		}
		int ans=0;
		for(int i = 0; i < (Math.pow(2, h)); i++){
			for(int j=0;j < (Math.pow(2, w)); j++){
				int black=0;
				for(int k=0; k<h; k++){
					for(int l=0; l<w; l++){
						if(((i>>k)&1)==0 && ((j>>l)&1)==0 && map[k][l]=='#'){
							black++;
						}
					}
				}
				if(black==kk){
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            String s = sc.next();
            if (s.equals("#")) {
                break;
            }
            
            int ans = solve(s);
            System.out.println(ans);
        }
    }
    
    public static int solve(String s) {
        int ans = 0;
        for (int i = 1; i < s.length(); i++) {
            boolean a = isLeftHand(s.charAt(i));
            boolean b = isLeftHand(s.charAt(i - 1));
            if (a && !b || !a && b) {
                ans++;
            }
        }
        
        return ans;
    }
    
    public static boolean isLeftHand(char c) {
        char[] cArray = {'a', 'b', 'c', 'd', 'e', 'f', 'g',
                         'q', 'r', 's', 't', 'v', 'w', 'x', 'z'};
        int tmp = Arrays.binarySearch(cArray, c);
        if (tmp >= 0) {
            return true;
        } else {
            return false;
        }
    }
}

Measured memory_bytes: 20596
// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll getsum(ll n){
	ll sum=0;
	while(n>0){
		sum+=n%10;
		n/=10;
	}
	return sum;
}

int main(){
	ios_base::sync_with_stdio(false);
	ll n;
	cin>>n;
	ll mini = 999999999999999;
	for(ll i=1;i<n;i++){
		mini = min(mini, getsum(i)+getsum(n-i));
	}
	cout<<mini<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

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

const int INF = 100000002;

int main(){
	string S;
	cin >> S;
	for(auto s:S){
		if(s == '7'){
			 cout << "Yes" << endl;
			 return 0;	
		}	
	}
	
	cout << "No" << endl;
}	

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;

int main(){
  int n,m;
  ll a[SIZE];
  priority_queue<P> cb;
  cin >> n >> m;
  rep(i,0,n) cin >> a[i];
  rep(i,0,m){
    ll b,c;
    cin >> b >> c;
    cb.push(P(c,b));
  }
  //cout << cb.top().first;

  sort(a,a+n);

  rep(i,0,n){
    if(cb.empty())break;
    if(a[i] < cb.top().first){
      a[i] = cb.top().first;
      P d = cb.top();cb.pop();
      d.second--;
      if(d.second >0) cb.push(d);
    }
  }

  ll sum=0;
  rep(i,0,n) sum += a[i];

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3188
n = gets.chomp.to_i
s = gets.split(" ").map{|x| x.to_i}
q = gets.chomp.to_i
t = gets.split(" ").map{|x| x.to_i}
count = 0
pos = 0
t.sort!
lim = t.size
s.each do |num|
  if  nil == t[pos]
    break
  end
  if num == t[pos]
    pos+=1
    count+=1
    redo
  elsif num < t[pos]  
    next
  else
    pos+=1
    redo
  end
end
p count

Measured memory_bytes: 15560
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
 vector<int> vi[maxii];
 vector<int>:: iterator child;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
bool check[maxii];

bool dfs(int node,int c)
{
    check[node]=true;
    arr2[node]=c;
    for(int child=0;child<vi[node].size();child++)
    {
        if(check[vi[node][child]]==false)
        {
            if(dfs(vi[node][child],c^1)==false)
            {
                return false;
            }
        }
        else if(arr2[node]==arr2[vi[node][child]])
        {
            return false;
        }
        //else if()
    }
    return true;
}

int main()
{
   string a;
   cin>>a;
   int len=a.size();
   for(int i=0;i<len;i++)
   {
       arr[a[i]-'a']++;
   }
   int c=0;
   for(int i=0;i<26;i++)
   {
       if(arr[i]%2!=0)
       {
           c=1;
           break;
       }
   }
   if(c==0)
   {
       printf("Yes\n");
   }
   else cout<<"No";
}






Measured memory_bytes: 5956
#include<bits/stdc++.h>
#define pf(x) x*x
using namespace std;
int n, d[2], col[2][360007];
vector<pair<int, int> >e[2];
int id(int a, int b) { return a * 2 * n + b; }
int check(int pos) { return pos >= 0 && pos < 2 * n; }
int dfs(int p, int a, int b)
{
	for (int i = 0, lim = e[p].size(); i < lim; i++)
	{
		int c = a + e[p][i].first, d = b + e[p][i].second;
		if (!check(c) || !check(d))continue;
		if (!col[p][id(c, d)])
		{
			col[p][id(c, d)] = -col[p][id(a, b)];
			dfs(p, c, d);
		}
	}
	return 0;
}
int main()
{
	cin >> n >> d[0] >> d[1];
	for (int p = 0; p <= 1; p++)
		for (int x = 0; x <= d[p]; x++)
		{
			int y = sqrt(d[p] - x * x);
			if (x * x + y * y != d[p])continue;
			e[p].push_back(make_pair(x, y));
			e[p].push_back(make_pair(-x, y));
			e[p].push_back(make_pair(x, -y));
			e[p].push_back(make_pair(-x, -y));
		}
	for (int i = 0; i < 2 * n; i++)
		for (int j = 0; j < 2 * n; j++)
			for (int p = 0; p <= 1; p++)
				if (!col[p][id(i, j)])
				{
					col[p][id(i, j)] = 1;
					dfs(p, i, j);
				}
	int now,haha;
	int tot = 0;
	for (int i = 0; i < 2 * n; i++)
		for (int j = 0; j < 2 * n; j++)
			if (col[0][id(i, j)] == 1 && col[1][id(i, j)] == 1)
			{
				printf("%d %d\n", i, j);
				if (++tot == n * n)return 0;
			}
	return 0;
}

Measured memory_bytes: 31872
#! /usr/bin/env python3

import sys
import numpy as np
from itertools import combinations
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, P, *A, = map(int, read().split())

n_odd = 0
n_even = 0
for a in A:
    if a % 2 == 0:
        n_even += 1
    else:
        n_odd += 1

if n_even == N:
    if P == 0:
        print(pow(2, N))
    else:
        print(0)
else:
    print(pow(2, (N - 1)))


Measured memory_bytes: 27024
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=2*1e5+2;
int add(int a,int b)
{
      a+=b;
      if(a>=MOD) a-=MOD;
      return a;
}
int sub(int a,int b)
{
      a-=b;
      if(a<0) a+=MOD;
      return a;
}
int mul(int a,int b)
{     
      return ((long long)a*b)%MOD;
}
int rev(int a)
{
	return mpow(a,MOD-2);
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n,a,b;
	cin>>n>>a>>b;
	int ans=sub(mpow(2,n),1);
	// cout<<ans<<" ";
	int lol=1;
	for(int i=n;i>n-a;i--)
	{
		lol=lol*i;
		lol%=MOD;
	}
	int lol1=1;
	for(int i=n;i>n-b;i--)
	{
		lol1=lol1*i;
		lol1%=MOD;
	}
	int lolr=1;
	for(int i=1;i<=a;i++)
	{
		lolr=mul(lolr,i);
	}
	int lol1r=1;
	for(int i=1;i<=b;i++)
	{
		lol1r=mul(lol1r,i);
	}
	int oof=mul(lol,rev(lolr));
	// cout<<oof<<"  ";
	int oof1=mul(lol1,rev(lol1r));
	// cout<<lol<<" ";
	ans=sub(ans,oof);
	ans=sub(ans,oof1);
	cout<<ans;
} 
// 4c3
// 4!/3!*1!
// 2^n-1-(nca)-(ncb)
// I never lose. I either win or I learn

Measured memory_bytes: 256
from collections import Counter
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

check = [True]*N
for A, B in AB:
    A_H = H[A-1]
    B_H = H[B-1]
    if A_H > B_H:
        check[B-1] = False
    elif A_H < B_H:
        check[A-1] = False
    else:
        check[A-1] = False
        check[B-1] = False

print(Counter(check)[True])

Measured memory_bytes: 93080
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int N = rei();
	cout << (N-1) / 2 << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl(1);
const ll mod = 1000000007;
//const ll mod = 998244353;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

void solve(){
  ll n,k;cin>>n>>k;
  vector<ll>count(k,0);
  for(int i=1;i<=n;i++)count[i%k]++;
  ll ans=0; 
  rep(i,k){
    ll j=(k-i)%k;
    if((2*j)%k==0){
      ans+=count[i]*count[j]*count[j];
    }
  }
  cout<<ans<<endl;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);cout<<fixed;
  cout<<setprecision(30);
  solve();
}


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
using namespace std;
int n;
long long a[200005],ans,Max;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		Max=max(Max,a[i]);
		if(a[i]<Max)
			ans+=Max-a[i];
	}
	printf("%lld",ans);
}

Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )

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

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

const int INF = 100000000;
const double PI=3.14159265358979323846;

int main () {
    
    int N, W;
    cin >> N >> W;
    vector<ll> v(N);
    vector<ll> w(N);
    vector<vector<ll>> dp(N+1,vector<ll> (W+1, 0));

    rep(i,0,N) {
        cin  >> w[i]>>v[i];
    }

    rep(i,0,N) {
        rep(j,0,W+1) {
            chmax(dp[i+1][j],dp[i][j]);
            if (j-w[i]>=0) {
                chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;

}









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

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vp;
const int inf = 1e9;
const ll INF = 1e18;
const db eps = 1e-10;

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ep emplace
#define mem(a) memset(a, 0, sizeof(a))
#define copy(a, b) memcpy(a, b, sizeof(b))
#define PA cout << "pass\n"
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define TM cout << db(clock()) / CLOCKS_PER_SEC << '\n'

int n, m, v, p;
const int maxn = 1e5 + 233;
int a[maxn];
ll sum[maxn];

int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m >> v >> p;
    for(int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1, greater<int>());
    for(int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
    int res = 0;
    for(int i = 1; i <= n; i++){
        if(i <= p) {
            res++;
            continue;
        }
        if(a[p] > a[i] + m) continue;
        ll tmp = 1ll * m * v - 1ll * (n - i + 1) * m - 1ll * (p - 1) * m;
        if(tmp <= 0){
            if(a[i] + m >= a[p]) res++;
            continue;
        }
        if(1ll * (i - p) * (a[i] + m) - (sum[i - 1] - sum[p - 1]) >= tmp){
            if(a[p] > a[i] + m) continue;
            res++;
            continue;
        }
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 1408
level=["heavy","light heavy","middle","light middle","welter","light welter","light","feather","bantam","fly"]
weight=[91,81,75,69,64,60,57,54,51,48]
while True:
    try:
        w=float(input())
    except:
        break
    f=False
    for wei,lev in zip(weight,level):
        if w>wei:
            print(lev)
            f=True
            break
    if not f:
        print("light fly")
            

Measured memory_bytes: 7336
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
struct Interval {int start, end;};
bool compare(pll i1, pll i2) {return (i1.s < i2.s);}
int main()
{
    ll r,d,x;
    cin>>r>>d>>x;
    rep(i,10)
    {
        x=r*x-d;
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0
for i in range(N):
    ans += A[i] // 2
    if A[i] % 2:
        if i < N-1 and A[i+1]:
            ans += 1
            A[i+1] -= 1

print(ans)

Measured memory_bytes: 7072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, M, R;
  cin >> N >> M >> R;

  vector<int> town(R), root(R);
  rep(i, R)
  {
    cin >> town[i];
    town[i]--;
    root[i] = i;
  }
  sort(root.begin(), root.end());

  long long INF = 100000000;
  vector<vector<long long>> d(N, vector<long long>(N, INF));
  rep(i, M)
  {
    int A, B, C;
    cin >> A >> B >> C;
    A--;
    B--;
    d[A][B] = C;
    d[B][A] = C;
  }
  rep(i, N)
  {
    d[i][i] = 0;
  }
  rep(k, N) rep(i, N) rep(j, N) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

  long long ans = INT32_MAX;
  do
  {
    long long cost = 0;
    rep(i, R - 1)
    {
      cost += d[town[root[i]]][town[root[i + 1]]];
    }
    ans = min(ans, cost);
  } while (next_permutation(root.begin(), root.end()));

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

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

int main() {
	
	int n, m;
	cin >> n >> m;
	int l = 0, r = n + 1;
	rep(i, m){
		int a, b;
		cin >> a >> b;
		if(a > l) l = a;
		if(b < r) r = b;
	}
	if(r - l + 1 > 0) cout << r - l + 1 << endl;
	else puts("0");
	return 0;
}

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

int main()
{
	long long n,x=0;
	cin>>n;
	for(int i=1;i<=10000000;i++)
	{
		x=(x*10+7)%n;
		if(x==0)
		{
		  cout<<i;
		  return 0;	
		}
	}
	
	cout<<"-1";
	
	return 0;
	
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define P 1000000007

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
	
	int x;
	cin >> x;
	
	for(int i = 1; i <= x; i++) if((360 * i) % x == 0) {
		cout << ((360 * i) / x) << endl;
		break;
	}
	
	return 0;
}

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


int main(){
    ll n,d; cin >> n >> d;
    ll res = 0;
    rep(i,n){
        double x,y; cin >> x >> y;
        if(sqrt(x*x + y*y) <= d) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


int main() {
  int n;
  cin >> n;
  vp red(n),blue(n);
  rep(i,n){
    cin >> red[i].fi >> red[i].se;
  }
  rep(i,n){
    cin >> blue[i].fi >> blue[i].se;
  }
  sort(rng(red));
  sort(rng(blue));
  int ans = 0;
  vi check(n,0);
  rep(i,n){
    int x = blue[i].fi;
    int y = blue[i].se;
    int h = -1;
    int c = -1;
    rep(j,n){
        if(x > red[j].fi && y > red[j].se && !check[j]){
          if(h<red[j].se){
             h = red[j].se;
             c = j;
          }
        }
    }
    if(c!=-1){
      check[c] = 1;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
//By Koios1143
#include<bits/stdc++.h>
#define LL long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pii pair<int,int>
using namespace std;
int n;
double now,dp[3005];
int main(){
	IOS
	while(cin>>n){
		dp[0]=1;
		for(int i=0 ; i<n ; i++){
			cin>>now;
			for(int j=i+1 ; j>=0 ; j--){
				dp[j] = (j==0 ? 0 : dp[j-1]*now) + dp[j]*(1-now);
			}
		}
		double ans=0;
		for(int i=n/2+1 ; i<=n ; i++){
			ans+=dp[i];
		}
		cout<<fixed<<setprecision(10)<<ans<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3848
N, M = map(int, input().split())
cnt = [0]*M
for i in range(N):
    A = list(map(int, input().split()))
    for j in A[1:]:
        cnt[j-1] += 1

ans = 0
for i in range(M):
    if cnt[i]==N:
        ans += 1
        
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
char words[10][5]={"Mon","Tue","Wed","Thu","Fri","Sat","Sun"};
char in[10];
long long fact[210000];
long long inv[210000];
long long finv[210000];
long long C(int a,int b){
	if(a<b||b<0)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
int main(){
	fact[0]=finv[0]=1;
	inv[1]=1;
	for(int i=2;i<210000;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<210000;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
	int a,b;scanf("%d%d",&a,&b);

	int R=a-b;
	if(R==0){
		for(int i=1;i<=b;i++){
			if(i==1)printf("1\n");
			else printf("0\n");
		}
		return 0;
	}
	for(int i=1;i<=b;i++){
		long long ret=0;
		long long tmp;
		if(i<=R-1){
			tmp=C(R-1,i);
			ret=(ret+tmp)%mod;
		}
		if(i<=R){
			tmp=C(R-1,i-1);
			tmp=tmp*2%mod;
			ret=(ret+tmp)%mod;
		}
		if(i>1&&i<=R+1){
			tmp=C(R-1,i-2);
			ret=(ret+tmp)%mod;
		}
		ret=ret*C(b-1,i-1)%mod;
		printf("%lld\n",ret);
	}
}

Measured memory_bytes: 5120
n = int(input())
c = [0]*n
s = [0]*n
f = [0]*n
t = [0]*n
for i in range(n-1):
    c[i], s[i], f[i] = (int(x) for x in input().split())
for i in range(n-1):
    for j in range(i+1):
        if t[j] < s[i]:
            t[j] = s[i]+c[i]
        else:
            r = t[j]%f[i]
            if r != 0:
                t[j] += f[i]-r
            t[j] += c[i]
for i in range(n):
    print(t[i])


Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        ll W, H;
        cin >> W >> H;
        ll x, y;
        cin >> x >> y;

        double ans1 = 1.0 * (W * H) / 2;

        int ans2 = 0;
        if (2 * x == W && 2 * y == H) {
            ans2 = 1;
        }

        cout << ans1 << " " << ans2 << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

string s;

int fstL[100005];
int fstR[100005];
int ans[100005];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> s;
    int n = s.size();
    s = '#' + s;

    for(int i = n; i >= 1; i--) {
        fstL[i] = s[i] == 'L' ? i : fstL[i + 1];
    }
    for(int i = 1; i <= n; i++) {
        fstR[i] = s[i] == 'R' ? i : fstR[i - 1];
    }

    for(int i = 1; i <= n; i++) {
        if(s[i] == 'L') {
            if((i - fstR[i]) % 2 == 0)
                ans[fstR[i]]++;
            else
                ans[fstR[i] + 1]++;
        } else {
            if((fstL[i] - i) % 2 == 0)
                ans[fstL[i]]++;
            else
                ans[fstL[i] - 1]++;
        }
    }
    for(int i = 1; i <= n; i++)
        cout << ans[i] << " ";

}

Measured memory_bytes: 1772
#include <iostream>

using namespace std;
int H,A,N,sum=0;
int main()
{
    cin>>H>>N;
    for(int i=1;i<=N;i++){
        cin>>A;
        sum=sum+A;
    }
    if(sum>=H){
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long
#define N 100005
#define Abs(x) ((x) > 0 ? (x) : -(x))
#define Min(x,y) ((x) < (y) ? (x) : (y))
#define Max(x,y) ((x) > (y) ? (x) : (y))
inline ll read(){
	ll x = 0,f = 1;char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x*10+ch-'0';ch = getchar();}
	return x*f;
}

ll c[N],d[N];
ll a[N];
ll n,m,tot,to,Mx;
ll ans,all;

int main(){
	n = read(); m = read();
	for(ll i = 1;i <= n;i++){
		ll x = read();
		if(i == 1 || x != a[tot])
			a[++tot] = x;
	}
	
	for(ll i = 2;i <= tot;i++){
		ll l = a[i-1],r = a[i];
		if(l > r) r += m;
		all += r-l;
		if(r-l > 1){
			d[l+2] += 1;
			d[r+1] -= (r-(l+2)+1)+1;
			d[r+2] += (r-(l+2)+1);
		} 
	}
	for(ll i = 1;i <= 2*m;i++)
		d[i] += d[i-1];
	for(ll i = 1;i <= 2*m;i++)
		d[i] += d[i-1];
	for(ll i = 1;i <= m;i++)
		ans = max(ans,d[i]+d[i+m]);
	printf("%lld\n",all-ans);
	return 0;
}

Measured memory_bytes: 2560