akhauriyash/Code-Regression huggingface dataset:
class Heap
  attr_accessor :data, :size

  def initialize
    @data=[]
  end

  def push(e)
    @data.push(e)

    cur = @data.size-1
    return if cur.zero?
    parent_i = parent(cur)

    while cur > 0 && @data[cur] < @data[parent_i]
      parent = @data[parent_i]
      @data[parent_i] = e
      @data[cur] = parent
      cur = parent_i
      parent_i = parent(cur)
    end
  end

  def pop
    ret = @data.first
    last = data.last

    cur = 0
    while left_i(cur)<data.size
      li = left_i(cur)
      ri = right_i(cur)
      l=data[li]
      r=data[ri]
      ni=li
      ni=ri if r && r < l

      break if @data[ni] >= last

      @data[cur] = @data[ni]
      cur = ni
    end

    data[cur]=last
    data.pop

    ret
  end

  def left_i(i)
    2*i+1
  end

  def right_i(i)
    2*i+2
  end

  def parent(i)
    return 0 if i.zero?
    (i-1)/2
  end
end

n = gets.strip.to_i
aa = gets.strip.split.map(&:to_i)

left_h = Heap.new
right_h = Heap.new
n.times do |i|
  left_h.push(aa[i])
  right_h.push(-aa[2*n+i])
end

left_score = left_h.data.inject(:+)
left_scores = [left_score]
right_score = right_h.data.inject(:+)
right_scores = [-right_score]

n.times do |i|
  c_l = aa[n+i]
  if c_l >= left_h.data.first
    left_h.push(c_l)
    left_score += c_l
    left_score -= left_h.pop
  end
  left_scores.push(left_score)

  c_r = -aa[2*n-1-i]
  if c_r >= right_h.data.first
    right_h.push(c_r)
    right_score += c_r
    right_score -= right_h.pop
  end
  right_scores.unshift(-right_score)

end

#p left_scores.zip(right_scores)
#p left_scores.zip(right_scores).map {|l, r| l-r }
p left_scores.zip(right_scores).map {|l, r| l-r }.max



Measured memory_bytes: 34872
#include<iostream>

using namespace std;

int main(){
    int N,check;
    int d[120];
    cin >> N;
    for(int i = 0; i < N;i++){
        cin >> d[i];
    }

    int num [120] = {0};
    for(int j = 0;j < N;j++){
        num[d[j]]++;
    }

    int ans = 0;
    for(int k = 0;k < 101;k++){
        if(num[k] > 0){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int cnt[26] = { 0 };
	int ch = 0;
	char buf[1200];
	int i;
	while ( scanf("%c", &ch) != EOF)
	{
		if (ch >= 'a' && ch <= 'z')
			cnt[ch - 'a']++;
		else if (ch >= 'A' && ch <= 'Z')
			cnt[ch - 'A']++;
	}
	for (i = 0; i < 26; i++)
	{
		printf("%c : %d\n", 'a' + i, cnt[i]);
	}

	return 0;    
}



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

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

    vector<int> table(n + 10,0);
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j <= n; j += i)
        {
            table[j]++;
        }
    }
    
    long long ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += (long long)i * table[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 42324
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), M = cin.getInt();
    let AB = new Array(M);
    for (let m = 0; m < M; m++) {
        let a = cin.getInt(), b = cin.getInt();
        AB[m] = [a, b];
    }
    AB.sort((a,b) => a[1] - b[1]);
    let now = AB[0][1], ans = 1;
    for (let m = 1; m < M; m++) {
if (AB[m][0] < now && now <= AB[m][1]) {}
else {
    ans++;
    now = AB[m][1];
}
}
console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0;this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');if(t<1)throw new Error('引数は1以上であること！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');if(t<1)throw new Error('引数は1以上であること！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 56012
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter};
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = [$(&stringify!([$arg]:), &$arg as &Debug),*];
            stderr().write_fmt(format_args!("{:#?}\n", entries)).unwrap();
        }
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let N = read!(usize);
    let A = read!(i64; N);

    let mut k = 0;
    for A in A.split(|&x| x == 0) {
        k += A.iter().sum::<i64>() / 2;
    }

    println!("{}", k);
    return;
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <sstream>
#include <cstdlib>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(a,min(b,c))<<" "<<max(a,max(b,c))<<endl;
	return 0;
}


Measured memory_bytes: 3108
# -*- coding: utf-8 -*-
s = input()
q_num = int(input())

mae = ""
ushiro = ""
docchi = True

for i in range(q_num):
    query = input()
    if query == '1':
        if docchi:
            docchi = False
        else:
            docchi = True
    else:
        tmp = query.split(' ')
        f = int(tmp[1])
        c = tmp[2]
        if (f == 1 and docchi) or (f == 2 and not docchi):
            mae = c + mae
        else:
            ushiro = ushiro + c

if docchi:
    print(mae + s + ushiro)
else:
    print(''.join(list(reversed(mae + s + ushiro))))


Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define in(s,x) s.find(x) != s.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
const ll INF= 1LL<<60-1;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}
// head


int m,n,k,res,tmp,tmp2,tmp3,h,w,ans;
//int a[5200] = {};
int a[3000][3000] = {};
deque<PII> que;
string s;
map<int,VPII> kukan;
vector<PII> g[3000];
//int dp[200000];
int flag;
//VPII g2[200000];
int cost[200005];
double dp[1020][2] = {};
double dp2[1020][2] = {};
//VVI g(200005);
int x[3000][3000][4] = {};



signed main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
	cin>>h>>w;
  rep(i,0,h){cin>>s;
  rep(j,0,w){
    if (s[j] == '.') a[i][j] = 1;
  }
  }
rep(i,0,h){
        rep(j,0,w){
                if ((a[i][j] == 1) && (0<j) && (a[i][j-1] == 1))
                        x[i][j][0] = x[i][j-1][0] +1;}
}
rep(i,0,h){
        per(j,0,w-1){
                if ((a[i][j] == 1) && (w-1>j) && (a[i][j+1] == 1))
                        x[i][j][1] = x[i][j+1][1] +1;}
}
rep(i,0,w){
        rep(j,0,h){
                if ((a[j][i] == 1) && (0<j) && (a[j-1][i] == 1))
                        x[j][i][2] = x[j-1][i][2] +1;}
}
 
rep(i,0,w){
        per(j,0,h-1){
                if ((a[j][i] == 1) && (h-1>j) && (a[j+1][i] == 1))
                        x[j][i][3] = x[j+1][i][3] +1;}
}               
ans = 0;
rep(i,0,h){
        rep(j,0,w){
                if ((a[i][j] == 1))
                        ans = max(ans,x[i][j][0]+x[i][j][1]+x[i][j][2]+x[i][j][3]+1);}
}
 cout<<ans<<endl; 
}


Measured memory_bytes: 237312
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll ans=0;
    vint node(n);
    vvint child(n);
    vint nei(n,0);
    queue<int> q;
    vint c(n);
    REP(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        child[a].pb(b);
        child[b].pb(a);
        nei[a]++;
        nei[b]++;
    }
    REP(i,n){
        cin >> c[i];
    }
    sort(ALL(c));
    REP(i,n){
        if(nei[i]==1){
            q.push(i);
        }
    }
    int last;
    REP(i,n-1){
        int next = q.front();
        int p = child[next][0];
        q.pop();
        if(i==n-2){
            node[next]=c[i];
            ans+=c[i];
            last=p;
             //cout << next << " " << c[i] << endl;
        }else{
            node[next]=c[i];
            //cout << next << " " << c[i] << endl;
            ans+=c[i];
            int s = (int)child[p].size();
            nei[p]--;
            REP(j,s){
                if(child[p][j]==next){
                    child[p].erase(child[p].begin()+j);
                    break;
                }
            }
            if(nei[p]==1){
                q.push(p);
            }
        }
    }
    //cout << last << " " << c[n-1] <<endl;
    node[last]=c[n-1];
    cout << ans << endl;
    REP(i,n-1){
        cout << node[i] << " ";
    }
    cout << node[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long long int> VLL;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    io;
    int n;
    cin >> n;
    VLL a(n);
    for (auto & x : a) {
        cin >> x;
        if (x == 0) {
            cout << 0 << "\n";
            return 0;
        }
    }
    ll ans = 1;
    for (auto x : a) {
        if ((long double)ans > 1e18/(long double)x) {
            cout << -1 << "\n";
            return 0;
        }
        ans *= x;
    }
    cout << ans << "\n";
}



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

int main() {
  int N;
  cin >> N;
  vector<int64_t> R(N+1);
  R.at(0) = 2;
  R.at(1) = 1;
  
  for(int i=0 ;i<N-1; i++){
    R.at(i+2) = R.at(i+1) + R.at(i);
  }
  
  cout << R.at(N) << endl;
}


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

int main(){
	int N,count=0;
	vector<int> v;
	cin >> N;


	v.resize(N);
	for(int i=0;i<N;i++){
		cin >> v[i];
		v[i]--;
	}

	for(int i=1;i<N;i++){
		if(v[i] < i && v[v[i]] == i) count++;
	}
	
	cout << count << endl;
}

Measured memory_bytes: 640
n=int(input())
l=list(map(int,input().split()))
l.sort()
a=0
b=0
c=0
ans=0
for i in range(n-2):
  a=l[i]
  for j in range(i+1,n-1):
    if l[j]!=a:
      b=l[j]
      for k in range(j+1,n):
        if l[k]!=b:
          c=l[k]
          if a+b>c:
            ans+=1
print(ans)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
int n;
map<int,int> mp;
int main(){
    while(~scanf("%d",&n)){
        mp.clear();
        for(int i = 0; i < n; i++){
            int id;
            scanf("%d",&id);
            if(!mp.count(id)){
                mp[id] = 1;
            }
            else{
                mp[id] = mp[id] ^ 1;
            }
        }
        int ans = 0;
        for(auto it : mp){
            if(it.second == 1) ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 4864
#include <stdio.h>
#include <float.h>

int main(void) {
    double v, max = DBL_MIN, min = DBL_MAX;
    while(~scanf("%lf", &v)) {
        v > max && (max = v);
        v < min && (min = v);
    }
    printf("%f\n", max - min);
    return 0;
}

Measured memory_bytes: 644
#include <iostream>

int main(){
	std::ios::sync_with_stdio(false);
    while(true){
		int n, a_score = 0, b_score = 0;
		std::cin >> n;
		
		if(n == 0)
			break;

		for(int i = 0; i < n; ++i){
			int a, b;
			std::cin >> a >> b;
			if(a > b)
				a_score += a + b;
			else if(a < b)
				b_score += a + b;
			else
				a_score += a, b_score += b;
		}

		std::cout << a_score << " " << b_score << std::endl;
    }
    return 0;
}

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


int main(){
  priority_queue<int>PQ;
  string order;
  int num;
  
  while(1){
    cin>>order;
    if(order=="end"){
      return 0;
    }
    if(order=="insert"){
      cin>>num;
      PQ.push(num);
    }
    else {
      cout<<PQ.top()<<endl;
      PQ.pop();
    }
  }
  return 0;
 }
 



Measured memory_bytes: 7056
// AOJ ITP1_10_D Distance II
// 2018.4.29 bal4u
 
#include <stdio.h>
#include <math.h>
 
#define gc() getchar_unlocked()
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc();
    while (c >= '0');
    return n;
}
 
int x[102], y[102];
 
int main()
{
    int n, i, t, t2;
    int d, d1, d2;
    long long d3;
     
    n = in();
    for (i = 0; i < n; i++) x[i] = in();
    for (i = 0; i < n; i++) y[i] = in();
    d = 0, d1 = 0, d2 = 0, d3 = 0;
    for (i = 0; i < n; i++) {
        t = x[i] - y[i];
        if (t < 0) t = -t;
        if (t > d) d = t;
        d1 += t;
        t2 = t*t, d2 += t2;
        d3 += t2*t;
    }
    printf("%d\n", d1);
    printf("%.8lf\n", sqrt((double)d2));
    printf("%.8lf\n", pow((double)d3, 1.0/3));
    printf("%d\n", d);
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
# define M_PI 3.14159265358979323846
using namespace std;
int main()
{
  	int n,m,a;
	cin>>n>>m;
  	int sum = 0;
  	for (int i=0;i<m;i++)
    {
      cin>>a;
      sum += a;
    }
    if (sum > n)
        cout<<-1<<endl;
    else
        cout<<(n-sum)<<endl;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll N, H, W;
    cin >> N >> H >> W;

    cout << (N-H+1)*(N-W+1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define F first
#define S second 
#define pb(n) push_back(n)
const int N=1e5+6;
const ll M=1e9+7;
vector<int> g[N];
int visit[N],ans,dp[N];

void dfs(int node)
{
	visit[node]=1;
	for(int it:g[node])
	{
		if(!visit[it])		
			dfs(it);		
		dp[node]=max(dp[node],dp[it]+1);		
	}
	ans=max(ans,dp[node]);
}

int main()
{
	int n,m,x,y;
	scn(n);scn(m);
	set<int> st;	
	for(int i=0;i<m;i++)
	{
		scn(x);scn(y);
		g[x].pb(y);
	}
	for(int i=1;i<=n;i++)
	{
		if(!visit[i])
			dfs(i);
	}
	pri(ans);
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define qtr ios::sync_with_stdio(0); cin.tie(0);
#define int long long
using namespace std;

struct SegmentTree{
	vector<int> data;
	vector<int> tree;
	vector<int> lazytag;
	queue<int> q;
	queue<int> updateQueue;
	int n;
	SegmentTree(vector<int> data){
		n = data.size();
		if((1 << __lg(n)) != n){
			n = 1 << (__lg(n) + 1);
		}
		data.resize(n);
		tree.resize(2*n);
		lazytag.resize(2*n);
		for(int i = 0; i < n; i++){
			q.push((n+i)/2);
			tree[n+i] = data[i];
		}
		build();
	}
	void build(){
		while(!q.empty()){
			int index = q.front();
			int a = tree[index*2];
			int b = tree[index*2+1];
			tree[index] = a+b;
			q.pop();
			if(index / 2 == 0) continue;
			q.push(index/2);
		}
	}
	int query(int l, int r, int lt){
		queue<tuple<int,int,int>> bfs;
		int sum = 0;
		bfs.push(make_tuple(1,n,1));
		while(!bfs.empty()){
			tuple<int,int,int> top = bfs.front();
			int ll = get<0>(top);
			int rr = get<1>(top);
			int index = get<2>(top);
			int mid = (ll+rr)/2;
			bfs.pop();
			if(lazytag[index] > 0){
				passOnLazyTag(index);
			}
			if(ll >= l && rr <= r){
				if(lt > 0){
					//cout << "update push " << index << endl; 
					updateQueue.push(index/2);
					lazytag[index] += (rr-ll+1) * lt;
					passOnLazyTag(index);
				}
				sum += tree[index];
				continue;
			}
			if(r <= mid){
				bfs.push(make_tuple(ll, mid, index*2));
			}else if(l > mid){
				bfs.push(make_tuple(mid+1, rr, index*2+1));
			}else{
				bfs.push(make_tuple(ll, mid, index*2));
				bfs.push(make_tuple(mid+1, rr, index*2+1));
			}
		}
		if(!updateQueue.empty()) update();
		//print();
		return sum;
	}
	void passOnLazyTag(int index){
		tree[index] += lazytag[index];
		if(index*2 < tree.size()){
			lazytag[index*2] += lazytag[index] / 2;
		}
		if(index*2+1 < tree.size()){
			lazytag[index*2+1] += lazytag[index] / 2;
		}
		lazytag[index] = 0;
	}
	void update(){
		while(!updateQueue.empty()){
			int index = updateQueue.front();
			passOnLazyTag(index);
			passOnLazyTag(index*2);
			passOnLazyTag(index*2+1);
			tree[index] = tree[index*2] + tree[index*2+1];
			if(index / 2 != 0) updateQueue.push(index/2);
			updateQueue.pop();
		}
	}
	void print(){
		for(int i = 1; i < tree.size(); i++){
			cout << tree[i] << " "; 
		}
		cout << endl;
	}
};

int32_t main(){ qtr
	int n;
	cin >> n;
	int ac = 0, wa = 0, tle = 0, re = 0;
	while(n--){
		string str;
		cin >> str;
		if(str == "AC") ac++;
		if(str == "WA") wa++;
		if(str == "TLE") tle++;
		if(str == "RE") re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
}

Measured memory_bytes: 3596
import sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    n = sc.intarr()[0]
    s, t = sc.strarr()
    text = ''

    for ss, tt in zip(s, t):

        text = text + ss
        text = text + tt

    print(text)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def natural_num(n):
    for j in range(2, int(math.sqrt(n))+1):
        if n % j == 0:
            return 0
    return 1


main()


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int m = sc.nextInt();
				int d = sc.nextInt();
				if(m+d == 0) break;
				switch(m) {
					case 12 : d+=30;
					case 11 : d+=31;
					case 10 : d+=30;
					case  9 : d+=31;
					case  8 : d+=31;
					case  7 : d+=30;
					case  6 : d+=31;
					case  5 : d+=30;
					case  4 : d+=31;
					case  3 : d+=29;
					case  2 : d+=31;
				}
				String [] day = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
				System.out.println(day[d%7]);
			}
		}
	}
}



Measured memory_bytes: 26248
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, n, m; cin >> a >> n >> m;
    ll ans = 0;
    for(ll i = 1; pow(i, n) <= m; i++)
    {
        ll x = pow(i, n), y = 0;
        ll tmp = x;
        while(tmp > 0)
        {
            y += tmp % 10;
            tmp /= 10;
        }
        if(x == pow(y + a, n)) ans++;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3272
#include <cassert>
#include <queue>
#include <map>
typedef long long ll;

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

template<int m>
class Prime{
  std::vector<bool> p;
  std::vector<int> ps;
public:
  Prime(){
    p = std::vector<bool>(m,true);
    assert(m>1);
    p[0]=p[1]=false;
    for(int i=4;i<m;i+=2)
      p[i]=false;
    ps.push_back(2);
    for(int i=3;i<m;i+=2){
      if(p[i]){
        ps.push_back(i);
        for(int j=i+i;j<m;j+=i)
          p[j]=false;
      }
    }
  }

  bool isPrime(int n){
    assert(m>n);
    return p[n];
  }

  int operator [] (int n){
    if(n<ps.size()) return ps[n];
    else return 0;
  }

  int size(){
    return ps.size();
  }
};


int main(){
  const int n = getInt();
  Prime<1024> p;
  map<int, int> m;

  for (int i = 2; i <= n; i++) {
    int t = i;
    for(int j = 2; j <= t; j++) {
      if(p.isPrime(j)) {
        while(t % j == 0) { m[j]++; t /= j; }
      }
    }
  }

  ll ans = 1;
  for (const auto &p : m) {
    ans = (ans * (p.second + 1)) % 1000000007;
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline

# int = int(input())
# s = input().split()
# i = list(map(int, input().split()))
# s = [input() for i in range(3)]

x = list(map(int, input().split()))
n = x[0]
m = x[1]

s = [0] * m
c = [0] * m

for i in range(m):
    x = list(map(int, input().split()))
    s[i] = x[0]
    c[i] = x[1]


flag = False
for i in range(1000):
    string = str(i)

    if len(string) != n:
        continue
    
    cflag = False
    for j in range(m):
        if int(string[s[j] - 1]) != c[j]:
            cflag = True
    
    if cflag:
        continue
    
    print(i)
    flag = True
    break

if not flag:
    print(-1)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  double len;
  while(~scanf("%lf",&len)){
    ll left = -1, right = 1e18;
    while(left+1<right){
      ll mid = (left+right)/2;
      double height = 5*mid - 5;
      double t = sqrt(height/4.9);
      double v = 9.8*t;
      if(v>=len){
        right = mid;
      }else{
        left = mid;
      }
    }
    cout<<right<<endl;
  }
  return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;
    vector<int> nums;
    int now = 1;
    int cnt = 0;
    rep(i, N){
        if(S.at(i) == (char)('0' + now)) cnt++;
        else {
            nums.push_back(cnt);
            now ^= 1;
            cnt = 1;
        }
    }
    if(cnt != 0) nums.push_back(cnt);
    if(nums.size() % 2 == 0) nums.push_back(0);

    int Add = 2 * K + 1;

    int ans = 0;
    for(int i = 0; i < nums.size(); i += 2){
        int tmp = 0;
        int left = i;
        int right = min(i + Add, (int)nums.size());
        for(int j = left; j < right; j++){
            tmp += nums.at(j);
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int no_of_moves, no_of_stones;
    cin >> no_of_moves >> no_of_stones;

    vector <int> move(no_of_moves + 1);
    for(int i = 1; i <= no_of_moves; i++)
        cin >> move[i];

    vector <int> winner(no_of_stones + 1, 2);
    for(int i = 1; i <= no_of_stones; i++)
    {
        for(int j = 1; j <= no_of_moves; j++)
        {
            if(move[j] > i) continue;

            if(winner[i - move[j]] == 2)
                winner[i] = 1;
        }
    }

    cout << (winner[no_of_stones] == 1 ? "First\n" : "Second\n");
    return 0;
}


Measured memory_bytes: 640
//15-3 ?°??±??????±?£?
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main(){
    int H,W;
    cin >> H >> W;
    for(int i=0; i<H; i++){
        string S;
        cin >> S;
        int jikan = -1;
        for(int j=0; j<W; j++){
            if(S[j] == 'c'){
                cout << 0;
                jikan = 0;
            }
            else if(S[j] == '.'){
                if(jikan == -1){
                    cout << -1;
                }
                else{
                    jikan++;
                    cout << jikan;
                }
            }
            if(j<W-1) cout << " ";
            else if(j=W-1) cout << endl;
        }
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

map <ll, int> br;

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    int n;
    cin >> n;
    ll res = 0;
    for(int i=1; i<=n; i++){
        ll x;
        cin >> x;
        /// j-i = a[i]+a[j]
        /// j-a[j] = a[i]+i
        res += br[i-x];
        br[x+i]++;
    }
    cout << res;
    return 0;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int dp[11111][11111];

void print(string s, string t) {
   int n = s.size(), m = t.size();
   rep (i, n+1) {
      rep (j, m+1) {
         printf("%2lld ", dp[i][j]);
      }
      puts("");
   }
}

int dist(string s, string t) {
   fill(dp[0], dp[1010], 1 << 28);
   dp[0][0] = 0;
   dp[0][0] = 0;
   int N = s.size(), M = t.size();
   rep (i, N+1) dp[i][0] = i;
   rep (i, M+1) dp[0][i] = i;

   rep (i, N) {
      rep (j, M) {
         dp[i+1][j+1] = min({dp[i][j+1]+2, dp[i+1][j]+2, dp[i][j] + (s[i] != t[j])});
      }
   }

   cout << dp[N][M] << endl;
}

int lcs(string s, string t) {
   for (int i = 0; i < s.size(); i++) {
      for (int j = 0; j < t.size(); j++) {
         dp[i+1][j+1] = (s[i] == t[j] ? dp[i][j]+1 : max(dp[i][j+1], dp[i+1][j]));
      }
   }
   return dp[s.size()][t.size()];
}

signed main() {
   int n;
   cin >> n;

   while (n--) {
      string s, t;
      cin >> s >> t;

      cout << lcs(s, t) << endl;
   }

   return 0;
}


Measured memory_bytes: 14968
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FILLINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a, T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a, T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) { for(auto &e : t) fill_v(e, v); }
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const lint MOD = 1000000007;

void _main() {
    string S;
    cin >> S;
    char pre = S[0];
    int ans = 0;
    FOR (i, 1, S.size()) {
        if (S[i] != pre) {
            pre = S[i];
            ans++;
        }
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  ll q,h,s,d,n;
  pair <ll,int> a[4];
  cin>>q>>h>>s>>d>>n; 
  n*=4; 
  a[0]={q*8,1};
  a[1]={h*4,2};
  a[2]={s*2,4};
  a[3]={d*1,8};
  //sort(a,a+4,greater<pair<ll,ll>>());
  sort(a,a+4);
  ll ans(0);
  for (int i(0);i<4;i++){
    ans+=((n/a[i].second)*(a[i].first/(8/a[i].second)));
    n%=a[i].second;
  }
  cout << ans << endl;
}


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

struct UnionFind {
  vector<int> parent;
  vector<int> size;

  UnionFind(int n) : parent(n, -1), size(n, 1) {}

  int find(int i) {
    if (parent[i] == -1) {
      return i;
    }
    return parent[i] = find(parent[i]);
  }

  void unite(int i, int j) {
    i = find(i);
    j = find(j);
    if (i == j) {
      return;
    }
    if (size[i] < size[j]) {
      parent[i] = j;
      size[j] += size[i];
    } else {
      parent[j] = i;
      size[i] += size[j];
    }
  }
};
int main() {
  int n, m;
  cin>>n>>m;
  int p[n];
  for (int i=0; i<n; i++) cin>>p[i];
  for (int i=0; i<n; i++) --p[i];
  UnionFind uf(n);
  for (int i=0; i<m; i++) {
    int x, y;
    cin>>x>>y;
    --x;
    --y;
    uf.unite(x, y);
  }
  int cnt = 0;
  for (int i=0; i<n; i++) {
    if (uf.find(i) == uf.find(p[i])) ++cnt;
  }
  cout<<cnt<<endl;
}

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

using namespace std;
#define PI              3.1415926536

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define REP(i,n) for(i=0;i<n;i++)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

bool f(int x, int y)
{
	return x > y;
}
void c_p_c()
{
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void solve()
{


}
int32_t main()
{
	//c_p_c();
	FIO;

	int n;
	cin >> n;

	int i, j;
	int c = 0;
	for (i = 1; i <= 1000000; i++)
	{
		for (j = 1; j <= 1000000; j++)
		{
			if (n - (i * j) > 0)
				c++;
			else
				break;

		}
	}
	cout << c;







}

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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;


int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n,x,t;
    cin>>n>>x>>t;
    
    cout << ((n+x-1)/x)*t << endl;
    return 0;
    
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    string t;
    cin >> t;
    for (int i=0; i<t.size(); ++i) {
        if (t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
}

Measured memory_bytes: 3752
import sys

sys.setrecursionlimit(100000000)


def dfs(u, c):  # 引数には頂点の番号と色を入れる
    ans[u] = c  # 探索済みにする
    for v, w in G[u]:
        if ans[v] != -1:  # 探索していた時はスルー
            continue
        if ans[v] != c and w % 2 == 0:  # 距離が偶数で、未訪問あるいは色が違う時は同じ色にする
            dfs(v, c)
        elif ans[v] != c and w % 2 != 0:  # 距離が奇数で、未訪問あるいは色が違う時、違う色にする。
            dfs(v, 1-c)


n = int(input())
G = [[] for _ in range(n)]  # 頂点の個数分準備
for i in range(n-1):  # 辺の数はn-1
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append([v, w])
    G[v].append([u, w])
ans = [-1] * n
dfs(0, 0)
for a in ans:
    print(a)

Measured memory_bytes: 85212
#include<bits/stdc++.h>
using namespace std ;
long long int a[1200000];
long long int b[1200000];
long long int n,m;
int cmp(int a ,int b){
	return a>b;
}
inline void read(int &x){
   int s = 0, w = 1; char ch = getchar();
   while(ch < '0' || ch > '9'){ if(ch == '-') w = -1; ch = getchar(); }
   while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
   x = s*w;
}
long long int check(long long int t){
	long long int sum=0;
	for(int i=0;i<n;i++){
		if(t/b[i]==0){
			sum+=a[i];
		}
		else {
			if(a[i]>=t/b[i]){
				sum+=a[i]-(t/b[i]);
			}
			else{
				sum+=0;
			}
		}
	}
	if(sum<=m){
		return 1;
	}
	else{
		return 0;
	}
}
int main()
{
	long long int ans=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		ans+=a[i];
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	if(m>=ans){
		printf("0\n");
		return 0;
	}
	sort(a,a+n);
	sort(b,b+n,cmp);
	long long int l=0,r=13000000000000;
	long long int daan=0; 
    while(l<=r) 
    {	
        long long int mid = (l + r) / 2;
        if(check(mid)) {
        daan=mid;
		r = mid-1;}
		 //检查mid是否符合题目要求
        else l = mid+1;
        
    }
    printf("%lld\n",daan);
	return 0;
}


Measured memory_bytes: 5888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();

		System.out.println(Math.min(p+q, Math.min(q+r, r+p)));
	}
}

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

class Program
{
	static void Main(string[] args)
	{
		//読み込む
      	int K = int.Parse(Console.ReadLine());
		int[] array = new int[32]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

		//出力
		Console.WriteLine(array[K-1]);
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define l1 long
#define ld long double
#define lld long long double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x) cout<<"$ "<<x<<" $"<<endl
#define bug(x) cout<<"& "<<x<<" &"<<endl
#define all(v) v.begin(),v.end()
#define lop1(i,j,n) for(int i=j; i<n; ++i)
#define lop2(i,j,n) for(int i=j; i<=n; ++i)
#define lop3(i,n,j) for(int i=n; i>j; --i)
#define lop4(i,n,j) for(int i=n; i>=j; --i)
#define view(v) for(auto i: v) cout<<i<<" "
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
const ll M=1e9+7;
const ld PI=3.1415926536;
//int p[N];
//int find(int k){ return p[k]==k ? k : p[k]=find(p[k]); }
using namespace std;

void solve()
{
    int n, ans=0;
    ld d;
    cin>>n>>d;
    vector<ld> v;
    lop1(i,0,n)
    {
        ld x, y;
        cin>>x>>y;
        v.pub(sqrt((x*x)+(y*y)));
    }
    for(auto i: v) if(i<=d) ans++;
    cout<<ans;
    return;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    fast
    ll t=1;
	//cin>>t;
    while(t--) solve();
	return 0;
}


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

using namespace std;

int main(){

	int a, b;
	cin >> a >> b;

	string sa = to_string(a);
	string sb = to_string(b);

	if(a < b) {
		for(int i = 0; i < b; i++){
			cout << sa;
		}
		cout << endl;
	} else {
	for(int i = 0; i < a; i++){
			cout << sb;
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  bool t[26];
  for(int i = 0; i < 26; i++)
    t[i] = false;

  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    int p = s[i] - 'a';
    if(t[p]){
      cout << "no" << endl;
      return 0;
    }else{
      t[p] = true;
    }
  }
  cout << "yes" << endl;
}


Measured memory_bytes: 256
N = int(input())
abc = []
for _ in range(N):
    x = tuple(map(int, input().split()))
    abc.append(x)
dp = [[0 for _ in range(3)] for _ in range(N)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]
for i in range(1, N):
    dp[i][0] = max(dp[i][0], dp[i-1][1] + abc[i][0], dp[i-1][2] + abc[i][0])
    dp[i][1] = max(dp[i][1], dp[i-1][0] + abc[i][1], dp[i-1][2] + abc[i][1])
    dp[i][2] = max(dp[i][2], dp[i-1][0] + abc[i][2], dp[i-1][1] + abc[i][2])

# print(*dp, sep='\n')
print(max(dp[N-1]))

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

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

using namespace std;

int main(){
	int h,w; scanf("%d%d",&h,&w);
	rep(i,h) rep(j,w) {
		string s; cin>>s;
		if(s=="snuke") return printf("%c%d\n",'A'+j,i+1),0;
	}

	return 0;
}


Measured memory_bytes: 256
#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>;

int main() {
    int a, b;
    cin >> a >> b;
    if (a+b >= 10) cout << "error" << endl;
    else cout << a + b << endl; 
}

Measured memory_bytes: 256
import itertools

def abc165c_many_requirements():
    n, m, q = map(int, input().split())
    all_list = []
    for _ in range(q):
        all_list.append(list(map(int, input().split())))

    pattern = itertools.combinations_with_replacement(range(1, m+1), n)
    best = 0
    for p in pattern:
        cost = 0
        for l in all_list:
            if p[l[1]-1] - p[l[0]-1] == l[2]:
                cost += l[3]
        if cost > best:
            best = cost
    print(best)

abc165c_many_requirements()

Measured memory_bytes: 9116
#include<iostream>
#include<fstream>
#include<string>
#include<vector>

using namespace std;

int main() {
	ifstream ifs;
	ifs.open("data.txt");
	string A;
	vector<char> board;

	cin >> A;
	int size = A.size();

	//cout << "size:" << size << endl;
	
	for (int i = 0; i < size; i++) board.push_back(A[i]);

	int p = 2;
	int res;
	while (1) {
		int get = 0;

		for (int i = 1; i < size - 1; i++) {
			if (board[i - 1] != board[i + 1]) {
				get=1;
				board.erase(board.begin()+i);
				size--;
				break;
			}
		}

		if (get == 0) {
			res = p % 2;
			break;
		}
		else p++;

	}

	if (res == 1)cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();

        long t = (long)Math.sqrt(n);

        long a = 1;

        for (long i=t; 1<=i; i--){
            if (n%i==0){
                a = n/i;
                break;
            }
        }

        System.out.print((n/a) + a -2);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n;
  cin >>n;
  long long int a[n],p=0,l=0,m=0,sum=0,mi=LLONG_MAX;
  for(int i=0;i<n;i++){
    cin >>a[i];
    mi=min(mi,abs(a[i]));
    sum+=abs(a[i]);
    if(a[i]>0)p++;
    else if(a[i]<0)m++;
    else l++;
  }
  if (l>0 || m%2==0)cout << sum <<endl;
  else cout << sum-2*mi<<endl;
}

Measured memory_bytes: 1024
N,K = map(int, input().split())
a = list(map(int, input().split()))

mod = 10 ** 9 + 7

def make_fact(n):#0~nの階乗を求める
    fact = [1]*(n+1)
    for i in range(1, n+1):
        fact[i] = fact[i-1]*i%mod
    return fact
fact = make_fact(N) #＠
def make_fact_inv(n):#0~nの階乗のmodに関する逆元を求める
    fact_inv = [1]*(n+1)
    fact_inv[n] = pow(fact[n], mod-2, mod)#フェルマーの小定理
    for i in range(n, 0, -1):
        fact_inv[i-1] = fact_inv[i]*i%mod
    return fact_inv
fact_inv = make_fact_inv(N)#＠
def comb(n, k):#nCk
    return fact[n]*fact_inv[k]*fact_inv[n-k]%mod

a.sort()

pos = 0
neg = 0

for i in range(N - K + 1):
    pos += a[N - i - 1] * comb(N- i - 1, K - 1)
    pos %= mod
    neg += a[i] * comb(N- i - 1, K - 1)
    neg %= mod

ans = (pos - neg) % mod

print(ans)

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

int N, r, t;
int res[300];
int need[300][300];
int R[200000];
int P[200000];
typedef pair<int, int> Pii;

bool check(int x){
	int sum[300][300] = { 0 };
	int rem[300] = { 0 };
	memcpy(rem, res, sizeof res);

	for(int i = 0; i < x; i++){
		//if(rem[R[i]] == 0) return false;
		rem[R[i]]--;
		sum[P[i]][R[i]]++;
	}
	int fin[300] = { 0 };
	for(int i = 0; i < N; i++){
		int cnt = 0;
		for(int j = 0; j < r; j++){
			if(sum[i][j] == need[i][j]) cnt++;
		}
		if(cnt == r){
			fin[i] = 1;
			for(int j = 0; j < r; j++){
				rem[j] += sum[i][j];
			}
		}
	}
	while(true){
		bool update = false;
		for(int i = 0; i < N; i++){
			if(fin[i]) continue;
			int cnt = 0;
			for(int j = 0; j < r; j++){
				int c = need[i][j] - sum[i][j];
				if(c <= rem[j]) cnt++;
			}
			if(cnt == r){
				fin[i] = 1;
				for(int j = 0; j < r; j++){
					rem[j] += sum[i][j];
				}
				update = true;
			}
		}
		if(!update) break;
	}
	for(int i = 0; i < N; i++){
		if(fin[i] == 0) return false;
	}
	return true;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	while(cin >> N >> r >> t){
		for(int i = 0; i < r; i++){
			cin >> res[i];
		}
		for(int i = 0; i < N; i++){
			for(int j = 0; j < r; j++){
				cin >> need[i][j];
			}
		}
		for(int i = 0; i < t; i++){
			cin >> P[i] >> R[i];
			P[i]--, R[i]--;
		}

		if(check(t)){
			cout << -1 << endl;
			continue;
		}

		int ok = 0, ng = t;
		while(abs(ok - ng) > 1){
			int mid = (ok + ng) / 2;
			if(check(mid)) ok = mid;
			else ng = mid;
		}

		cout << ng << endl;
	}
}

Measured memory_bytes: 5412