akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

vector<int> x(30);
int m;

inline void add(int i, bool dt = true) {
    if (x[0] == m + 1) return;
    if (x[i] == 0) {
        x[i] = 1;
        rep(j, 0, i) if (x[j] == 0) x[j] = 1;
    } else if (x[i] < m) {
        x[i]++;
        if (dt) rep(j, i + 1, 30) x[j] = 0;
    } else {
        if (i != 0) {
            x[i] = 1;
            if (dt) rep(j, i + 1, 30) x[j] = 0;
            add(i - 1, false);
        } else {
            x[0] = m + 1;
        }
    }
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n - 1) {
        if (a[i] >= a[i + 1]) break;
        if (i == n - 2) {
            cout << 1 << endl;
            return 0;
        }
    }
    rep(i, 1, n) {
        if (30 <= a[i - 1] && a[i - 1] < a[i]) {
            a[i - 1] = -1;
        }
        if (30 <= a[i] && a[i] < a[i - 1]) {
            a[i - 1] = -1;
        }
    }
    rep(i, 0, n) a[i] = min(a[i], 30);
    //debug(a);
    int l = 1, r = n;
    while (r - l > 1) {
        m = (r + l) / 2;
        x = vector<int>(30, 0);
        rep(i, 0, n) {
            if (a[i] != -1)
                add(a[i] - 1);
        }
        if (x[0] <= m)
            r = m;
        else
            l = m;
    }
    cout << r << endl;
    return 0;
}

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

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

    vector<int> A(N);
    rep (i,N) {
        Int a;
        cin >> a;
        if (a >= N) A[i] = N;
        else A[i] = a;
    }

    vector<int> x(N), y(N);

    rep(i,N) {
        x[i] = min(A[i]+i+1, N);
        if (i+1 <= A[i]) y[i] = 0;
        else y[i] = i + 1 - A[i];
    }

    sort(x.begin(),x.end());
    sort(y.begin(),y.end());


    Int ans = 0;
    rep1(i,N-1) {
        ans += (upper_bound(x.begin(),x.end(), i) - lower_bound(x.begin(),x.end(), i)) * (upper_bound(y.begin(),y.end(), i) - lower_bound(y.begin(),y.end(), i));
    }

    cout << ans << endl;
}


Measured memory_bytes: 5636
#include <iostream>

using namespace std;

struct Node
{
    int key;
    Node *parent, *left, *right;
};

Node *NIL;

void initialize()
{
    NIL->parent = NIL->left = NIL->right = NIL;
}

class BST
{
    Node *tree;

public:
    BST() : tree(NIL) {}

    Node *makeNode(Node *parent, int key)
    {
        Node *node = new Node;
        node->key = key;
        node->parent = parent;
        node->left = node->right = NIL;
        return node;
    }

    void insert(int key)
    {
        if (tree == NIL)
        {
            tree = makeNode(NIL, key);
            return;
        }
        Node *node = tree;
        while (true)
        {
            if (node->key < key)
            {
                if (node->right == NIL)
                {
                    node->right = makeNode(node, key);
                    break;
                }
                else
                {
                    node = node->right;
                }
            }
            else
            {
                if (node->left == NIL)
                {
                    node->left = makeNode(node, key);
                    break;
                }
                else
                {
                    node = node->left;
                }
            }
        }
    }

    bool find(int key)
    {
        Node *node = tree;
        while (node != NIL)
        {
            if (node->key == key)
                return true;
            if (node->key < key)
                node = node->right;
            else
                node = node->left;
        }
        return false;
    }

    void inorder(const Node* node){
        if(node == NIL) return;
        inorder(node->left);
        cout << " " << node->key;
        inorder(node->right);
    }

    void preorder(const Node* node){
        if(node == NIL) return;
        cout << " " << node->key;
        preorder(node->left);
        preorder(node->right);
    }

    void print(){
        inorder(tree);
        cout << endl;
        preorder(tree);
        cout << endl;
    }
};

int main()
{
    BST bst;
    int N, key;
    char com[10];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> com;
        if(com[0] == 'i'){
            cin >> key;
            bst.insert(key);
        }
        else if(com[0] == 'f'){
            cin >> key;
            if(bst.find(key)) cout << "yes" << endl;
            else cout << "no" << endl;
        }
        else{
            bst.print();
        }
    }
}


Measured memory_bytes: 21756
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		int cnt = 0;
		int len = S.length;
		for (int i=0; i<S.length; i++) {
			if(S[i]=='S') cnt++;
			else if (cnt>0) {
				cnt--;
				len-=2;
			}
		}
		System.out.println(len);
		sc.close();
	}

}


Measured memory_bytes: 15168
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            //1 2 2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3485");
            //872 1012974 1539173474040
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("4664");
            //3498 3498 3498
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        checked {
            List<string> InputList = GetInputList();
            long N = long.Parse(InputList[0]);

            for (long B = 1; B <= 3500; B++) {
                for (long C = 1; C <= 3500; C++) {
                    long wkBunsi = -N * B * C;
                    long wkBunbo = -4 * B * C + N * C + N * B;

                    if (wkBunbo == 0) continue;
                    if (wkBunsi % wkBunbo != 0) continue;
                    long wkA = wkBunsi / wkBunbo;
                    if (wkA <= 0) continue;

                    Console.WriteLine("{0} {1} {2}", wkA, B, C);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;

const ll MOD = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct etree { ll from, to, cost; };
struct people { ll v, k, year; };
bool comp(const etree& e1, const etree& e2) {
	return e1.cost < e2.cost;
}
bool comp2(const people& e1, const people& e2) {
	return e1.year < e2.year;
}
#define ALL(x) (x).begin(),(x).end()


int main() {
	double n, o = 1;
	cin >> n;
	for (ll i = 1;i <= 3500;i++) {
		for (ll j = 1;j <= 3500;j++) {
			ll m = n*i*j, c = 4 * i*j - i*n - j*n;
			if (c > 0) {
				if (m%c == 0) { {
						cout << i << ' ' << j << ' ' << m / c << endl;
						exit(0);
					}
				}
			}
		}
	}
}

Measured memory_bytes: 384
n, k = map(int, input().split())

aa = list(map(int, input().split()))

from itertools import accumulate

aa

for _ in range(k):
    d = [0] * n

    for i, a in enumerate(aa):
        d[max(i-a, 0)] += 1
        end = i+1+a
        if end < n:
            d[end] -= 1

    d = list(accumulate(d))
    if aa == d:
        break
    aa = d


print(' '.join(str(a) for a in aa))

Measured memory_bytes: 184928
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, L;
  cin >> N >> L;
  vl A(N);
  REP(i, N) cin >> A[i];
  ll po = -1;
  REP(i, N - 1) {
    if (A[i] + A[i + 1] >= L) {
      po = i;
      break;
    }
  }
  if (po == -1)
    cout << "Impossible" << endl;
  else {
    cout << "Possible" << endl;
    REP(i, po) cout << (i + 1) << endl;
    for (ll i = N - 2; i >= po; i--)
      cout << (i + 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 1664
from collections import Counter
n = int(input())
a = list(map(int,input().split()))

def combi(n,r):
    if n<r:
        return 0
    ans = 1
    for i in range(r):
        ans*=(n-i)
        ans/=(i+1)
    return ans

b = [0]*n
b[0]=a[0]
for i in range(1,n):
    b[i]=b[i-1]+a[i]
c = Counter(b)
c[0]+=1
k = c.keys()
sum = 0
for i in k:
    sum += combi(c[i],2)
print(int(sum))


Measured memory_bytes: 41664
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

int main(void){
   string s;
   cin >> s;
   sort(s.begin(), s.end());
   if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2])
    cout << "Yes" << endl;
   else
    cout << "No" << endl;
   
    return 0;
}

Measured memory_bytes: 256
n,m=gets.split.map(&:to_i)
requests=m.times.map{gets.split.map(&:to_i)}
requests.sort!{|(a1,b1),(a2,b2)|
  b1==b2 ? a1<=>a2 : b1<=>b2
}

ans=0
destroy=-1
requests.each{|a,b|
  if destroy<a
    ans+=1
    destroy=b-1
  end
}
puts ans

Measured memory_bytes: 10488
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define NR 3010

vector<int> g[NR];
int a[NR];
int n;

bool dfs(int x, int fa) {
	for (int v : g[x]) if (v != fa && a[v] < a[x] && !dfs(v, x)) {
		return true;
		
	}
	return false;
}

int main() {
	scanf("%d", &n);
	iter(i, n) scanf("%d", &a[i]);
	iter(i, n - 1) {
		int x, y;
		scanf("%d%d", &x, &y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	iter(i, n) if (dfs(i, 0)) printf("%d ", i);
	return 0;
}

Measured memory_bytes: 384
import sys
import numpy as np
import numba
from numba import jit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@jit
def main(n, k):
    n = n%k
    return min(n, abs(n-k))


n, k = map(int, readline().split())

print(main(n, k))

Measured memory_bytes: 107676
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;

int N, K;
string S;

string cv;

int main()
{
    ios_base::sync_with_stdio(0);
    
    cin >> N >> K >> S;
    for (int i = N - 1; i >= 0; i--)
        S += S[i];

    cv = S.substr(0, N);
    for (int i = 1; i <= N; i++)
        cv = min (cv, S.substr(i, N));
    if (K == 1)
    {
        cout << cv << "\n";
        return 0;
    }

    K--;
    //cout << cv << endl;
    int na = 1;
    while (na < N && cv[na] == cv[na-1])
        na++;

    int ntot = na;
    for (int i = 0; i < K; i++)
    {
        ntot = min (N, ntot * 2);
        if (ntot == N) break;
    }

    for (int i = 0; i < ntot; i++)
        cout << cv[0];
    for (int i = 0; i < N - ntot; i++)
        cout << cv[i+na];
    cout << "\n";
}

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

using namespace std;

int main() {
  int n, m;

  while (cin >> n >> m, n != 0) {
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] < m / n) {
        ans += a[i];
      } else {
        ans += m / n;
      }
    }
    cout << ans << "\n";
  }

  return 0;
}


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

import sys
import math
from decimal import Decimal, ROUND_DOWN


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]

    return (n, )


def solve(n):

    def s(n):
        return (int(26 ** n) - 1) * 26 // 25

    d = 0
    for i in range(1, 100): 
        if s(i-1) + 1 <= n and n <= s(i):
            d = i
            break

    m = n - s(d- 1) - 1
    ks = []
    while True:
        k = m // 26
        r = m % 26
        ks.append(r)
        if k == 0:
            break
        m = k

    ks.reverse()

    names = 'abcdefghijklmnopqrstuvwxyz'
    result = []
    for k in ks:
        result.append(names[k])

    pad_size = d - len(result)
    result = ["a"] * pad_size + result

    return ''.join(result)
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 77304
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
0 1 2
0 2 1
1 2 1
1 3 1
2 3 2

output:
3
"""

import sys
from collections import deque


def graph_bfs(source, target, parent):
    visited = [False] * v_num
    queue = deque()
    queue.appendleft(source)
    visited[source] = True

    while queue:
        current = queue.popleft()
        for adj, cp in adj_table[current].items():
            if cp and not visited[adj]:
                queue.append(adj)
                visited[adj] = True
                parent[adj] = current

    return True if visited[target] else False


def graph_FordFulkerson(source, sink):
    parent = [-1] * v_num
    max_flow = 0

    while graph_bfs(source, sink, parent):
        path_flow = float('inf')

        bk_1 = sink
        while bk_1 is not source:
            parent_bk_1 = parent[bk_1]
            assert parent_bk_1 != -1
            path_flow = min(path_flow, adj_table[parent_bk_1][bk_1])
            bk_1 = parent[bk_1]

        max_flow += path_flow

        bk_2 = sink
        while bk_2 is not source:
            parent_bk_2 = parent[bk_2]
            assert parent_bk_2 != -1
            # adj_table[parent_bk_2].setdefault(bk_2, 0)
            adj_table[bk_2].setdefault(parent_bk_2, 0)

            # print(bk_2, parent_bk_2, path_flow, bk_1, parent[bk_1], parent, adj_table)
            adj_table[parent_bk_2][bk_2] -= path_flow
            adj_table[bk_2][parent_bk_2] += path_flow
            bk_2 = parent[bk_2]

    return max_flow


def generate_adj_table(_edges):
    for edge in _edges:
        source, target, cp = map(int, edge)
        init_adj_table[source].setdefault(target, cp)

    return init_adj_table


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    v_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    init_adj_table = [dict() for _ in range(v_num)]
    adj_table = generate_adj_table(edges)
    ans = graph_FordFulkerson(source=0, sink=v_num - 1)
    print(ans)

Measured memory_bytes: 8168
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
#include<string>
#include<iomanip>
#include <numeric>
#include <limits>
using namespace std;
 
int main()
{
double a,b,av; cin>>a>>b;
av=(a+b)/2; cout<<ceil(av);
return 0;
}

Measured memory_bytes: 3768
from collections import defaultdict, Counter

N, M = map(int, input().split())
X = list(map(int, input().split()))

d = defaultdict(int) #mod Mで見たときの個数
for x in X:
    d[x % M] += 1


ans = 0 #Mの倍数//2 組の和はすべてMの倍数となる
# ans += d[0] // 2

lst = [0] * M
for m in range(1, M):
    ans += min(d[m], d[M - m])
    lst[m] = d[m] - min(d[m], d[M - m]) #mod Mで見たときに残っている個数

ans //= 2
ans += d[0] // 2
# print (ans)
# print ('lst', lst)
# print ('d', d)

C = Counter(X)
for c in C:
    tmp = min(C[c], lst[c % M]) // 2
    lst[c % M] -= 2 * tmp
    ans += tmp

print (ans)






Measured memory_bytes: 28124
#include<bits/stdc++.h>
#define maxn 200005
#define LL long long
using namespace std;
LL a[maxn],k;
LL cut[maxn];
int n;
LL L=1,R=0;
 
bool check(LL t){
	LL cnt=0;
	for(int i=1;i<=n;i++){
		cut[i]=(a[i]/t)-1+(a[i]%t>0);
		cnt+=cut[i];
	}
	if(cnt<=k)return 1;
	else return 0;
}
 
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)R=max(R,a[i]);
	R++;
	while(L+1<R){
		LL mid=L+R>>1;
	//	cout<<L<<" "<<R<<" "<<mid<<endl;
		if(check(mid))R=mid;else L=mid;
	}
	if(check(L))cout<<L<<endl;
	else cout<<R<<endl;
}

Measured memory_bytes: 6652
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

vector<int> ps, qs;

int main(void) {
  int n;
  cin >> n;
  REP(i, n) {
    int v;
    cin >> v;
    ps.push_back(v);
  }
  REP(i, n) {
    int v;
    cin >> v;
    qs.push_back(v);
  }
  if(ps > qs) {
    ps.swap(qs);
  }
  int res = 0;
  while(ps != qs) {
    ++res;
    next_permutation(ps.begin(), ps.end());
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 888
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    ll N; cin>>N;
    vector<ll>a(N);
    ll sum=0;
    rep(i,N){
        cin>>a[i];
        sum+=a[i];
    }
    ll ans =sum-N;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll a[300][300];
int r[300][300];

int main() {
    int n;
    cin >> n;
    VVL a(n, VL(n));
    REP(i,n) REP(j,n) scanf("%lld", &a[i][j]);

    REP(i,n) REP(j,n) REP(k,n){
        if (i == j || j == k || k == i) continue;
        if (a[i][j] > a[i][k] + a[k][j]){
            cout << -1 << endl;
            return 0;
        }
        if (a[i][j] == a[i][k] + a[k][j]){
            r[i][j] = 1;
        }
    }

    ll ans = 0;
    REP(i,n) REP(j,i){
        if (!r[i][j]) ans += a[i][j];
    }
    cout << ans << endl;

    return 0;
}





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

int par[111111];
int rnk[111111];
int n,m;

int root(int a){
	return par[a]!=a?root(par[a]):a;
}

void unite(int a,int b){
	if(rnk[a]<rnk[b]) swap(a,b);
	par[root(a)] =  root(b);
	rnk[root(b)] += rnk[root(a)];
}

int main(){
	for(int i=0;i<111111;i++)par[i]=i;
	cin>>n>>m;
	while(m--){
		int a,b,c;
		cin>>a>>b>>c;
		if(a) cout<<(root(b)==root(c))<<'\n';
		else if(root(b)!=root(c)) unite(b,c);
	}
}


Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdint>


int64_t const MOD = 1e9+7;
int const MAXN = 2e5;
int N;

template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
  //operator int64_t() const { return v_; }
};
typedef mod_int<MOD> mint;

std::vector<int> G[MAXN];

mint dp1[MAXN], dp2[MAXN];
int nc[MAXN];
void dfs1(int v, int p) {
  int num = 0;
  mint r1;
  for(auto c: G[v]) if(c != p) {
    dfs1(c, v);
    num += nc[c];
    r1 += mint(2).pow(nc[c])-1;
  }
  dp1[v] = r1;
  dp2[v] = mint(2).pow(num)-r1-1;
  nc[v] = num+1;
}

int main() {
  int N; std::cin >> N;
  for(int i = 0; i < N-1; ++i) {
    int A, B; std::cin >> A >> B; --A; --B;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  dfs1(0, -1);
  mint ans = dp2[0];
  for(int i = 1; i < N; ++i) {
    ans += dp2[i] + (mint(2).pow(nc[i] - 1) - 1)*(mint(2).pow(N - nc[i]) - 1);
  }
  ans *= mint(2).pow(N).inv();
  std::cout << ans.v_ << std::endl;
  return 0;
}



Measured memory_bytes: 26240
import java.util.*;
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner s  = new Scanner(System.in);
    double D = s.nextDouble();
    double T =(double) s.nextInt();
    double S = s.nextDouble();
    double t = D/S;
    if(t<T+0.001){
      System.out.println("Yes");
    }
     else{
       System.out.println("No");
     }
    
  }
}
  


Measured memory_bytes: 28816
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007

int main() {
    int n;
    scanf("%d", &n);
    set<string> word;
    bool flag = true;
    string before = "0";
    rep(i,n) {
        string s;
        cin >> s;
        if (word.count(s)) flag = false;
        if (i != 0 && before.at(before.size()-1) != s.at(0)) flag = false;
        before = s;
        word.insert(s);
    }
    if (flag) printf("Yes\n");
    else printf("No\n");
}

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

const int N = 2e5 + 10;
char s[N];
vector<int> a, b;
int main()
{
	int n, k, c;
	scanf("%d%d%d", &n, &k, &c);
	scanf("%s", s + 1);
	int len = strlen(s + 1);
	
	
	for(int i = 1; i <= len; i++) {
		if(s[i] == 'o') {
			a.push_back(i);
			i += c;
		}
		if(a.size() == k) break;
	}
	for(int i = n; i >= 1; i--) {
		if(s[i] == 'o') {
			b.push_back(i);
			i -= c;
		}
		if(b.size() == k) break;
	}
	reverse(b.begin(), b.end());
	
	int la = a.size(), lb = b.size();
	if(la == lb) {
		for(int i = 0; i < la; i++) 
			if(a[i] == b[i]) printf("%d\n", a[i]);
	}
} 

Measured memory_bytes: 3444
// test
#include <bits/stdc++.h>
using namespace std;
const int N=2e3+5;
int n,w[N],b[N],x;
int dp[N][N],cw[N][N],cb[N][N];
int main()
{
  memset(cw,0,sizeof(cw));
  memset(cb,0,sizeof(cb));
  scanf("%d",&n);
  for(int i=1;i<=2*n;i++)
  {
    char op[2];
    scanf("%s%d",op,&x);
    if(op[0]=='W')
      w[x]=i;
    else
      b[x]=i;
  }
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<i;j++)
      if(w[i]<w[j])
        cw[i][0]++;
    for(int j=1;j<=n;j++)
    {
      cw[i][j]=cw[i][j-1];
      if(w[i]<b[j])
        cw[i][j]++; 
    }
  } 
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<i;j++)  
      if(b[i]<b[j])
        cb[0][i]++;
    for(int j=1;j<=n;j++)
    {
      cb[j][i]=cb[j-1][i];
      if(b[i]<w[j])
        cb[j][i]++;
    }
  }
  int c1=0,c2=0;
  for(int i=1;i<=n;i++)
  {
    c1+=cw[i][0],c2+=cb[0][i];
    dp[i][0]=c1,dp[0][i]=c2;
  }
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      dp[i][j]=min(dp[i-1][j]+cw[i][j],dp[i][j-1]+cb[i][j]);  
  cout<<dp[n][n]<<'\n';
  return 0;
}

Measured memory_bytes: 47360
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, p;
    string s;
    cin >> n >> p >> s;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        a[i] = s[i] - '0';
    long long ans = 0;
    if(10 % p == 0) {
        for(int i = 0 ; i < n ; i++)
            if(a[i] % p == 0)
                ans += i + 1;
        cout << ans << '\n';
        return 0;
    }
    reverse(a.begin(), a.end());
    vector<int> csum(n + 1, 0);
    int pw = 1;
    for(int i = 0; i < n; i++) {
        csum[i + 1] += (csum[i] + a[i] * pw % p) % p;
        pw = (pw * 10) % p;
    }
    
    map<int, long long> mp;
    for(int i = 0; i < n + 1; i++)
        mp[csum[i]]++;
    for(auto &iter : mp)
        ans += iter.second * (iter.second - 1) /2;
    // vector<int> cnt(p);
    // for(int i = 0; i < n + 1; i++) {
    //     ans += cnt[csum[i]];
    //     cnt[csum[i]]++;
    // }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 2564
N = int(input())
AB = [tuple(map(int, input().split())) for i in range(N)]
AB = sorted(AB, key=lambda x: -x[1])
deadline = float('inf')
for a, b in AB:
    deadline = min(deadline, b) - a
    if deadline < 0:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 39632
import re
n = input()
if re.fullmatch(r'.*keyence',n) != None or re.fullmatch(r'keyence.*',n) != None or re.fullmatch(r'k.*eyence',n) != None or re.fullmatch(r'ke.*yence',n) != None or re.fullmatch(r'key.*ence',n) != None or re.fullmatch(r'keye.*nce',n) != None or re.fullmatch(r'keyen.*ce',n) != None or re.fullmatch(r'keyenc.*e',n) != None:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3188
#include <stdio.h>

#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long llong;

const llong MOD = 1000000007;

llong powmod(llong x, llong n) {
  llong ans = 1;
  while (n) {
    if (n & 1)
      ans = ans * x % MOD;
    n >>= 1;
    x = (x * x) % MOD;
  }
  return ans;
}

void DSumOfLargeNumbers(std::istream& in, std::ostream& out) {
  llong n, k;
  in >> n >> k;

  // llong exp100 = powmod(10, 100);
  // out << exp100 << endl;
  // 226732710

  llong sum = 0;
  for (llong i = k; i <= n + 1; ++i) {
    llong summin = (i - 1) * i / 2;
    llong summax = (n - i + 1 + n) * i / 2;
    sum += (summax - summin) + 1;
    sum %= MOD;
  }
  out << sum << endl;
}

int main(int argc, char** argv) { DSumOfLargeNumbers(cin, cout); return 0; }


Measured memory_bytes: 3200
#include<stdio.h>
int main()
{
	int a,b,c,d,min,max;
	scanf("%d %d %d %d",&a,&b,&c,&d); 
	if(a>=d||b<=c)
	{
	printf("0\n");
	goto exit;
    }
	if(a<c)
	min=c;
	else
	{
	min=a;
	}
	if(b<d)
	 max=b;
	else
	{
	max=d;
	}
	printf("%d\n",max-min);
	exit:
	return 0;
}

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

using namespace std;

#define ll long long

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

	vector<pair<int, int>> g;
	for (int i = 1; i < n; i++) { // 完全グラフを作る
		for (int j = i + 1; j <= n; j++) {
			pair<int, int> p;
			p.first = i;
			p.second = j;
			g.push_back(p);
		}
	}

	if (k > n * (n - 1) / 2 - (n - 1)) {
		cout << "-1" << endl;
		return 0;
	}


	int m = n * (n - 1) / 2 - k; // 辺の本数
	cout << m << endl;
	for (int i = 0; i < m; i++) {
		cout << g[i].first << " " << g[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#define ll long long
#define pb push_back

int main(){
char s;
std::cin >> s;
if(s>=65 && s<=90)
   std::cout << 'A' << std::endl;
else
  std::cout << 'a' << std::endl;   
   
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
return 0;	
}


Measured memory_bytes: 3628
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <vector>


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

  int n;
  std::cin >> n;
  std::vector<int> ts(n);
  for (auto&& t : ts) {
    std::cin >> t;
  }
  int sumTime = std::accumulate(ts.begin(), ts.end(), 0);
  int m;
  std::cin >> m;
  for (int i = 0; i < m; i++) {
    int p, x;
    std::cin >> p >> x;
    std::cout << (sumTime - ts[p - 1] + x) << std::endl;
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,m[101],p[101][100],k,l[100],i,j,b,a,cnt[101],max,who,flag;
  while(1){
    max=0;
    cin >> n;
    if(n==0) break;
    for(i=1;i<=n;i++){
      cin >> m[i];
      for(j=0;j<m[i];j++){
	cin >> p[i][j];
      }
    }
    cin >> k;
    for(i=0;i<k;i++){
      cin >> l[i];
    }
    for(i=1;i<=n;i++){
      for(j=0;j<m[i];j++){
	for(b=1;b<m[i];b++){
	  if(p[i][b]<p[i][b-1]) swap(p[i][b],p[i][b-1]);
	}
      }
    }
    for(i=0;i<=k;i++){
      for(j=1;j<k;j++){
	if(l[j]<l[j-1])  swap(l[j],l[j-1]);
      }
    }
    for(i=1;i<=n;i++){
      cnt[i]=0;
      for(j=0;j<m[i];j++){
	for(a=0;a<k;a++){
	  if(l[a]==p[i][j]){
	    cnt[i]++;
	  }
	}
      }
      if(cnt[i]>max) max=cnt[i];
    }
    who=0;
    flag=0;
    for(i=1;i<=n;i++){
	if(flag==0&&cnt[i]==max){
	  who=i;
	  flag=1;
	}
	else if(flag==1&&cnt[i]==max){
	  flag=2;
	  break;
	}
      if(flag==2) break;
    }
    if(max<k) cout << -1 << endl;
    else if(flag==1) cout << who << endl;
    else if(flag==2) cout << -1 << endl;
  }
  return 0;
}

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

int main () {
    int N;
    int num[4];

    cin >> N;
    num[0] = N / 1000;
    num[1] = N / 100 % 10;
    num[2] = N / 10 % 100 % 10;
    num[3] = N % 1000 % 100 % 10;

    if (num[0] == num[2]) {
        if (num[0] == num[1]) {
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else if(num[1] == num[2]) {
        if (num[1] == num[3]) {
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
def solve():
  ans = 0
  N = int(input())
  A = [0]*N
  B = [0]*N
  for i in range(N):
    A[i],B[i] = map(int, input().split())
  for i in range(N-1,-1,-1):
    A[i] += ans
    if A[i]%B[i]>0:
      ans += B[i]-A[i]%B[i]
  return ans
print(solve())

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

lmax = [0] * (N + 1)
rmax = [0] * (N + 1)

for i in range(0, N - 1):
    lmax[i + 1] = max(lmax[i], A[i])

for i in range(N - 1, 0, -1):
    rmax[i] = max(rmax[i + 1], A[i])
for i in range(N):
    print(max(lmax[i], rmax[i + 1]))


Measured memory_bytes: 15656
S = input()
S = S[::-1]
while S:
    if S.startswith('maerd'):
        S = S[5:]
    elif S.startswith('remaerd'):
        S = S[7:]
    elif S.startswith('esare'):
        S = S[5:]
    elif S.startswith('resare'):
        S = S[6:]
    else:
        print('NO')
        break
else:
    print('YES')


Measured memory_bytes: 3188
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
/*
  for A以上B未満でI探索 for (int I = A; i <= B; i++)

  string s = to_string(i);　iをstringでsに変換

  char　小文字のほうが32大--------------------大文字と小文字の境=93

  大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

  int i = sqrt (n) で、ｎの平方根(9に対する3)をiに入れる

  pow(a,b) → aのb乗を求める

  s1.erase(n) 文字列s1の、n文字目以降削除
  */
int a=0, b=0, c = 0;
string s = "";

int main(void) {
	//vector,set,map,stack,queue,deque,priority_queue

	llint x, y;
	cin >> x >> y;
	int cnt = 0;
	llint ans = x;
	while (true) {
		if (ans > y)break;
		else {
			cnt++;
			ans *= 2;
		}
	}
	cout << cnt << rt;
	please AC;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

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

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, M;
  cin >> N >> M;
  unordered_map<ll, usll> A;
  REP(i, 0, M) {
    ll a, b;
    cin >> a >> b;
    auto const& find_a = A.find(a);
    if (find_a != A.end()) {
      if (find_a->second.find(b) == find_a->second.end()) {
        find_a->second.emplace(b);
      }
    } else {
      usll u;
      u.emplace(b);
      A[a] = u;
    }
    auto const& find_b = A.find(b);
    if (find_b != A.end()) {
      if (find_b->second.find(b) == find_b->second.end()) {
        find_b->second.emplace(a);
      }
    } else {
      usll u;
      u.emplace(a);
      A[b] = u;
    }
  }

  auto const& from_one = A.find(1);
  for (auto const& a : from_one->second) {
    auto const& from = A.find(a);
    if (from != A.end()) {
      for (auto const& b : from->second) {
        if (b == N) {
          cout << "POSSIBLE" << endl;
          return 0;
        }
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 38672
from itertools import combinations_with_replacement 

N, M, Q = map(int, input().split())

Qset = []

for i in range(Q):
    a = list(map(int, input().split()))
    Qset.append(a)

ans = 0
for num in combinations_with_replacement(range(1, M+1), N):
    ans_temp = 0
    for j in Qset:
        if j[2] == num[j[1]-1] - num[j[0]-1]:
            ans_temp += j[3]

    ans = max(ans, ans_temp)

print(ans)

Measured memory_bytes: 9204
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	Adj := make([][]int, n)
	for i := range Adj {
		Adj[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		scanner.Scan()
		u, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		k, _ := strconv.Atoi(scanner.Text())
		if k == 0 {
			continue
		}
		for i := 0; i < k; i++ {
			scanner.Scan()
			v, _ := strconv.Atoi(scanner.Text())
			Adj[u-1][v-1] = 1
		}
	}
	for i := range Adj {
		for j := range Adj[i] {
			if j == n-1 {
				fmt.Printf("%d\n", Adj[i][j])
				continue
			}
			fmt.Printf("%d ", Adj[i][j])
		}
	}
}


Measured memory_bytes: 1164
using System;
using System.Collections.Generic;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());

            //var prop = Console.ReadLine().Split(' ')
            //  .Select(x => int.Parse(x)).ToList();
            //long u = gcd(18, 18);
            long sum = 0;
            int flg = 0;
            for (int i = 0; i < K; i++)
            {
                for (int m = 0; m < K; m++)
                {
                    for (int n = 0; n < K; n++)
                    {
                        
                        long h=gcd(i+1,gcd(n+1,m+1));
                        if (h % 2==0 )
                        {
                            flg++;
                        }
                        sum += h;
                    }
                }
            }
            Console.WriteLine(sum);


        }
        static long gcd(long a, long b)
        {
            long A = Math.Max(a, b);
            long B = Math.Min(a, b);
            long D ;
            while (true)
            {
                D = B;
                B = A % B;
                A = D;
                if (B == 0)
                    break;
            }
            return D;
        }
    }
}


Measured memory_bytes: 17708
#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, sum = 0, tmp = 101;
    bool flag = false;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        sum += a;
        if (a % 10 != 0){
            tmp = min(tmp, a);
            flag = true;
        }
    }
    if (sum % 10 != 0) cout << sum << endl;
    else if (flag) cout << sum - tmp << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val D, N = sc.nextInt()
  val s: Stream[Long] = math.pow(100, D).toLong #:: s.map { n => n + math.pow(100, D).toLong }  
  println(s.filter(x => x.toDouble / 100 != math.pow(100, D)).take(N).last)
}


Measured memory_bytes: 55416
import math
N,D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]

ans = 0
for i in range(N):
    if math.sqrt((X[i][0])**2+(X[i][1])**2) <= D:
        ans += 1
        
print(ans)

Measured memory_bytes: 45456
import java.util.Scanner;

public class Main {



	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String in = sc.nextLine();
		String[] inArray = in.split(" ");
		int h = Integer.parseInt(inArray[0]);
		int w = Integer.parseInt(inArray[1]);

		String header = createHeader(w);

		System.out.println(header);

		for (int i = 0; i < h ; i++) {
			String inStr = sc.nextLine();
			System.out.println(createLine(inStr));
		}

		System.out.println(header);



		sc.close();
	}

	private static String createHeader(int w) {
		StringBuffer buf = new StringBuffer();
		buf.append("#");
		for (int i = 0 ; i <= w ;i++) {
			buf.append("#");
		}
		return buf.toString();
	}

	private static String createLine(String in) {
		StringBuffer buf = new StringBuffer();
		buf.append("#");
		buf.append(in);
		buf.append("#");
		return buf.toString();
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &s)
{
	s = 0;char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) s = ((s+(s<<2))<<1)+ch-'0',ch = getchar();
}
int n,p[260000],f[510][510],sx[4] = {0,0,1,-1},sy[4] = {1,-1,0,0};
long long Ans;
bool vis[510][510];
queue < pair<int,int> > Q;
inline void Change(int cx,int cy)
{
	for(int i = 0,nx,ny;i<4;++i)
	{
		nx = cx + sx[i],ny = cy + sy[i];
		if(nx > n || ny > n || nx < 1 || ny < 1) continue;
		if(f[cx][cy] < f[nx][ny]) f[nx][ny] = f[cx][cy],Q.push(make_pair(nx,ny));
	}
	while(!Q.empty())
	{
		int x = Q.front().first,y = Q.front().second;Q.pop();
		for(int i = 0,nx,ny;i<4;++i)
		{
			nx = x + sx[i],ny = y + sy[i];
			if(nx > n || ny > n || nx < 1 || ny < 1) continue;
			if(f[nx][ny] > f[x][y] + vis[x][y]) f[nx][ny] = f[x][y] + vis[x][y],Q.push(make_pair(nx,ny));
		}
	}
	// for(int i = 1;i<=n;++i,puts("")) for(int j = 1;j<=n;++j) cout << f[i][j] << " ";
}
int main()
{
	read(n),memset(f,0x3f3f3f3f,sizeof(f)),memset(vis,1,sizeof(vis));
	for(int i = 1;i<=n;++i) for(int j = 1;j<=n;++j) read(p[(i-1)*n+j]);
	for(int i = 1;i<=n;++i)
		f[1][i] = f[i][1] = f[i][n] = f[n][i] = 0,Q.push(make_pair(i,1)),Q.push(make_pair(1,i)),Q.push(make_pair(n,i)),Q.push(make_pair(i,n));
	while(!Q.empty())
	{
		int x = Q.front().first,y = Q.front().second;Q.pop();
		for(int i = 0,nx,ny;i<4;++i)
		{
			nx = x + sx[i],ny = y + sy[i];
			if(nx > n || ny > n || nx < 1 || ny < 1) continue;
			if(f[nx][ny] > f[x][y] + 1) f[nx][ny] = f[x][y] + 1,Q.push(make_pair(nx,ny));
		}
	}
	// for(int i = 1;i<=n;++i,puts("")) for(int j = 1;j<=n;++j) cout << f[i][j] << " ";
	for(int i = 1,P;i<=n*n;++i)
		P = p[i],vis[(P-1)/n+1][(P-1)%n+1] = 0,Ans += f[(P-1)/n+1][(P-1)%n+1],Change((P-1)/n+1,(P-1)%n+1);
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 5908
import sys
input = sys.stdin.readline


def main():
    S = input().strip()
    Q = int(input())
    Query = [list(input().split()) for _ in range(Q)]
    reverse = 1
    head = ""
    tail = ""
    for T in Query:
        if T[0] == "1":
            if reverse == 1:
                reverse = 2
            else:
                reverse = 1
        elif T[0] == "2":
            if int(T[1]) == reverse:
                head = T[2] + head
            else:
                tail = tail + T[2]
    S = head + S + tail
    print(S) if reverse == 1 else print(S[::-1])


if __name__ == '__main__':
    main()


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

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

main = do
    n <- getInt
    hs <- getIntList
    let dh = zipWith (-) hs (tail hs)
    if n == 1
        then print 0
        else print . maximum . map sum . group $ map pm dh

pm x | x >= 0 = 1
     | otherwise = 0

Measured memory_bytes: 12668
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;

bool read(ref string str){
	str=readln.chomp();
	if(str==null)return false;
	return true;
}

void main(){
	string str;
	while(read(str)){
		string[] s=str.split(" ");
		auto n1=s[0].to!int();
		auto n2=s[1].to!int();
		writeln(log10(n1+n2).to!int+1);
	}
}

Measured memory_bytes: 2440
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      String s = sc.next();
      if(a>=3200){
        System.out.println(s);
      }else{
        System.out.println("red");
      }
    }
}

Measured memory_bytes: 35784
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	m := make(map[int]int)
	for i := 0; i < N; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		m[a]++
	}
	cnt := 0
	if len(m) > K {
		va := make([]int, len(m))
		for _, v := range m {
			va = append(va, v)
		}
		sort.Ints(va)
		for i := 0; i < len(va)-K; i++ {
			cnt += va[i]
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 22400
# -*- coding: utf-8 -*-
#AGC014A
import sys
#import collections

#n= int(input())

tmp = input().split()
q,h,s,d = list(map(lambda a: int(a), tmp))

n= int(input())

k=min(4*q,min(2*h,s))

#print(k)
if(2*k<d):
	print(n*k)
else:
	tmp = n%2*k
	print((n-n%2)*d//2+tmp)



Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
using namespace std;
using namespace boost;
using Graph = adjacency_list<listS, vecS, directedS, no_property, property<edge_weight_t, int>>;
using Edge = pair<int, int>;
using Vertex = boost::graph_traits<Graph>::vertex_descriptor;
int main() {
  int N, M, u, v, S, T;
  cin >> N >> M;
  vector<Edge> edge;
  for (int i = 0; i < M; i++) {
    cin >> u >> v;
    u--; v--;
    edge.push_back(make_pair(u, N+v));
    edge.push_back(make_pair(N+u, 2*N+v));
    edge.push_back(make_pair(2*N+u, v));
  }
  vector<int> weight(edge.size(), 1);
  Graph graph(edge.begin(), edge.end(), weight.begin(), 3 * N);
  cin >> S >> T;
  S--; T--;
  vector<Vertex> parents(num_vertices(graph));
  dijkstra_shortest_paths(graph, S, predecessor_map(&parents[0]));
  if (parents[T] == T) cout << -1 << endl;
  else {
    int cnt = 0;
    for (Vertex v = T; v != S; v = parents[v]) cnt++;
    cout << cnt / 3 << endl;
  }
}

Measured memory_bytes: 41836