akhauriyash/Code-Regression huggingface dataset:
from heapq import heappush, heappop
n, m = map(int, input().split())
jobs = {}
for _ in range(n):
  a, b = map(int, input().split())
  if a > m:
    continue
  if a in jobs.keys():
    jobs[a] += [-b]
  else:
    jobs[a] = [-b]
    
profit = 0
days = jobs.keys()
potential_jobs = []

for elappsed_day in range(1, m + 1):
  if elappsed_day in days:
    for job in jobs[elappsed_day]:
      heappush(potential_jobs, job)
  if len(potential_jobs) > 0:
    profit += heappop(potential_jobs)

print(-profit)

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

double dist_origin(long x, long y) {
    return sqrt((x*x)+(y*y));
}
int main() {
    int n, count=0;
    long dist, x, y;
    cin>>n>>dist;
    for(int i=0; i<n; ++i) {
        cin>>x>>y;
        if(dist_origin(x,y)<=dist)
            ++count;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3672
using System;
using System.Linq;

namespace ABC153B
{
    class Program
    {
        static void Main(string[] args)
        {
            var HN = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var H = HN[0];
            var N = HN[1];
            var As = Console.ReadLine().Split().Select(x => int.Parse(x));

            Console.WriteLine(As.Sum() >= H ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 18656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N;
ll a[200005];
ll A[200005];
ll X;

int main(){

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

cin>>N;
rep(i,N) cin>>a[i];
X=a[0];
rep1(i,N) X=a[i]^X;
rep(i,N) A[i]=a[i]^X;
rep(i,N) cout<<A[i]<<" ";
cout<<endl;


}
    


Measured memory_bytes: 6668
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int x = scan.nextInt();
		int y = scan.nextInt();
		scan.close();
		
		for(int i = 0; i <= x; i++) {
			if(2*i + 4*(x-i) == y) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
		
	}

}

Measured memory_bytes: 35764
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	x := r.nextInt()

	f := func(a, b int) int {
		return pow(a, 5, 0) - pow(b, 5, 0)
	}

	m, M := 0, math.MaxInt64
	{
		i := 0
		ran := pow(10, 9, 0)
		for {
			if f(i, i-1) > ran {
				M = i - 1
				break
			}
			i++

		}
	}

	{
		i := 0
		ran := pow(10, 9, 0)
		for {
			if f(i, i-1) > ran {
				m = i
				break
			}
			i--
		}
	}

	ans := ""
	for i := M; i > m; i-- {
		for j := i - 1; j >= m; j-- {
			if f(i, j) == x {
				ans = fmt.Sprint(i, j)
			}
		}
	}
	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k,q;
  cin >> n >> k >> q;
  
  vector<int> vec(n+1);
  
  for(int i=0;i<q;i++){
    int x;
    cin >>x;
    vec.at(x)++;
  }
  
  for(int i=1;i<=n;i++){
    if(vec.at(i)>q-k) cout << "Yes" <<endl;
    else cout <<"No"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1024
from sys import stdin

def multiple(A,st,ed):
    res = 1
    for i in range(st,ed):
        res = res * A[i]

    return res

def main():
    n, k = [int(x) for x in stdin.readline().rstrip().split()]
    A = [int(x) for x in stdin.readline().rstrip().split()]

    st = -1
    for i in range(k+1,n+1):
        st += 1
        if A[i-1] > A[st]:
            print("Yes")
        else:
            print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 31436
a = int(input())
b = int(input())
c = int(input())
y = int(input())
 
ans = 0
 
for ai in range(a+1):
    for bi in range(b+1):
        for ci in range(c+1):
            amount = 500 * ai + 100 * bi + 50 * ci
            if amount == y:
                ans += 1
 
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
    lli n,k;
    cin >> n >> k;
    vector<lli> w(n), d(n);
    for(int i=0; i<n; i++){
        cin >> w[i] >> d[i];
    }
    lli s=0,l=2*1e18;
    while(s<l){
        lli m = (s+l)/2;
        lli count = 0;
        for(int i=0; i<n; i++){
            if(m<w[i]) continue;
            count += (m-w[i])/d[i] +1;
            if(count >= k) break;
        }
        if(count >= k){
            l = m;
        }else{
            s = m+1;
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 1920
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
	int n,t,c;
	scanf("%d", &n);
	vector<int> cakes;
	for(int i = 0;i < n;++i){
		scanf("%d", &t);
		cakes.push_back(t);
	}
	sort(cakes.begin(), cakes.end());
	reverse(cakes.begin(), cakes.end());

	c = 0;
	t = 101;
	for(int i = 0;i < n;++i){
		if(cakes[i] < t){
			++c;
			t = cakes[i];
		}else{
		}
	}

	printf("%d\n", c);

	return 0;
}

Measured memory_bytes: 256
using System;

namespace Murasa
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] tmp = Console.ReadLine().Split(' ');
            int A = int.Parse(tmp[0]);
            int B = int.Parse(tmp[1]);

            int tas = A + B;
            int hik = A - B;
            int kak = A * B;
            Console.WriteLine(Math.Max(tas, (Math.Max(hik, kak))));
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
using namespace std;
int a,b,c,x,d;
 
int main()
{
int wry =78;
    cin>>a>>b>>c>>x;
    for(int i = 0;i <= a;i ++)
    {
        for(int j = 0;j <= b;j ++)
        {
            for(int k = 0;k <= c;k ++)
                if(i * 500 + j * 100 + k * 50 == x)d ++;
        }
    }
    cout<<d<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n,t;
  cin >> n >> t;
  int res = 0;
  int mae = 0;
  for(int i = 0;i < n;i++){
    int num;
    cin >> num;
    res += min(mae + t,num) - mae;
    mae = num;
  }
  res += t;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
def findcount(arr, x, n):
	ans = 0
	for i in range(x, n+1, x):
		ans += arr[i-1]
	# print(ans)
	return ans


n = int(input())
arr = [int(j) for j in input().split()]

ans = [False]*n
for i in range(n, 0, -1):
	x = findcount(ans, i, n)
	if x%2 == arr[i-1]:
		continue
	else:
		ans[i-1] = True

count = 0
temp = []
for x in range(1, n+1):
	if ans[x-1] == True:
		temp += [x]
		count += 1

print(count)
print(*temp)



Measured memory_bytes: 14068
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(string a, string b, string c) {
    int n = cast(int) a.length;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        bool[char] d;
        d[a[i]] = true;
        d[b[i]] = true;
        d[c[i]] = true;

        switch (d.keys.length) {
        case 2:
            ans += 1;
            break;
        case 3:
            ans += 2;
            break;
        default:
            break;
        }

    }
    return ans;
}

void main() {
    readint;
    string a = read!string;
    string b = read!string;
    string c = read!string;
    writeln(calc(a, b, c));
}


Measured memory_bytes: 256
n,m,l = map(int,input().split())
matrix1 =[[0 for i in range(m)] for j in range(n)]
matrix2 =[[0 for i in range(l)] for j in range(m)]
matrix  =[[0 for i in range(l)] for j in range(n)]
for i in range(n):
    a = list(map(int,input().split()))
    for j in range(m):
        matrix1[i][j] = a[j]
for i in range(m):
    a = list(map(int,input().split()))
    for j in range(l):
        matrix2[i][j] = a[j]
for i in range(n):
    for j in range(m):
        for k in range(l):
            matrix[i][k] += matrix1[i][j] * matrix2[j][k]
for i in range(0,n):
    print(' '.join(str(x) for x in matrix[i]))


Measured memory_bytes: 6888
a= int(input())
b= int(input())
c= int(input())
x= int(input())
ans=0
for i in range (a+1):
    for j in range (b+1):
        for k in range (c+1):
            if 500*i+100*j+50*k == x:
                ans = ans + 1
            else:
                pass
print(ans)

Measured memory_bytes: 3060
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF=1<<30;


int main(void) {

    string S; cin>>S;

    for (int i = 0; i < S.length(); i+=2) {
        if(S[i]=='h' && S[i+1]=='i'){
            continue;
        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int A1,A2,A3;
    cin >> A1 >> A2 >> A3;
    int ans = max({A1,A2,A3}) - min({A1,A2,A3});
    cout << ans << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> odd(MAX, 0);
	vector<int> even(MAX, 0);
	int odd1 = 0, odd1id = -1, odd2 = 0, odd2id = -1;
	int even1 = 0, even1id = -1, even2 = 0, even2id = -1;
	for (int i = 0; i < n; i++) {
		int v;
		cin >> v;
		if (i % 2 == 0) {
			odd[v]++;
			if (odd2id == -1 && odd1id != -1 && v != odd1id) {
				odd2 = odd[v];
				odd2id = v;
			}
			else if (odd2id == v)odd2 = odd[v];
			if (odd1 <= odd[v]) {
				if (odd1id != v && odd1id != -1) {
					odd2 = odd1;
					odd2id = odd1id;
				}
				odd1 = odd[v];
				odd1id = v;
			}
		}
		else {
			even[v]++;
			if (even2id == -1 && even1id != -1 && v != odd1id) {
				even2 = even[v];
				even2id = v;
			}
			else if (even2id == v)even2 = even[v];
			if (even1 <= even[v]) {
				if (even1id != v && even1id != -1) {
					even2 = even1;
					even2id = even1id;
				}
				even1 = even[v];
				even1id = v;
			}
		}
	}
	//cout << odd1 << even1 << odd2 << even2 << endl;
	if (odd1id != even1id) {
		cout << n - odd1 - even1 << endl;
	}
	else if (n == odd1 + even1) {
		cout << n / 2 << endl;
	}
	else if (odd1 + even2 > odd2 + even1) {
		cout << n - odd1 - even2 << endl;
	}
	else cout << n - odd2 - even1 << endl;
}


Measured memory_bytes: 1024
x,y,z,k=map(int,input().split())
a=sorted(list(map(int,input().split())),reverse=True)
b=sorted(list(map(int,input().split())),reverse=True)
c=sorted(list(map(int,input().split())),reverse=True)
ans=[]
for ai in a:
  for bi in b:
    ans.append(-ai-bi)
ans.sort()
ans=ans[:k] if len(ans)>=k else ans+[0]*(k-len(ans))
ans1=[]
from heapq import heapify,heappop,heappush
for ci in c:
  for ansi in ans:
    heappush(ans1,ansi-ci)
for i in range(k):
  print(-heappop(ans1))



Measured memory_bytes: 223772
// abc131d.cpp : Megalomania
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  int N; cin>>N;
  map<ll,ll> jb;

  ll a, b;
  for(int i=0;i<N;i++){
    cin>>a>>b;
    jb[b] += a;
  }

  bool f = true;
  a = b = 0;
  for(auto e = jb.begin(); e!=jb.end(); e++){
    a += e->second;
    if(a>e->first){
      f = false;
      break;
    }
  }
  cout<< (f?"Yes":"No") <<endl;

}

Measured memory_bytes: 12800
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()
	minInt:=func(a int, vs ...int) int {
		for i := range vs {
			v := &vs[i]
			if a > *v {
				a = *v
			}
		}
		return a
	}

	ans:=0
	if n%2==0{
		x:=0
		w:=n
		for {
			w/=2
			if w==0{
				break
			}
			x += w
		}
		y:=0
		w=n/2
		for {
			w/=5
			if w==0{
				break
			}
			y += w
		}
		ans=minInt(x, y)
	}
	fmt.Fprintln(stdout, ans)
}


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

int main() {
	int N;
	cin >> N;
	
	vector< string > v(N);
	for (int i=0; i<N; ++i) cin >> v[i];
	
	bool flag = true;
	int a = 0, un = 0;
	for (int i=0; i<N; ++i) {
		if (v[i] == "A") ++a;
		if (v[i] == "Un") ++un;
		flag &= (a >= un);
	}
	
	puts(a == un && flag ? "YES" : "NO");
}


Measured memory_bytes: 3156
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main()
{
  ll n;
  cin>>n;
  vector<ll> a(n),sum(n+1);
  sum.at(0)=0;
  rep(i,n)
  {
    cin>>a.at(i);
    sum.at(i+1)=sum.at(i)+ a.at(i);
  }
  sort(sum.begin(),sum.end());

  ll ans=0,tmp,cnt;
  rep(i,n+1)
  {
    if(i==0)
    {
      tmp=sum.at(0);
      cnt=1;
    }
    else if(i==n)
    {
      if(sum.at(n)==tmp)
      {
        cnt++;
        ans+=cnt*(cnt-1)/2;
      }
    }
    else
    {
      if(sum.at(i)==tmp) cnt++;
      else
      {
        ans+=cnt*(cnt-1)/2;
        tmp=sum.at(i);
        cnt=1;
      }
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define pi 3.141592653589793238462643383279502884197
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n,m;
	cin>>n>>m;
	vector< pair<int,int> > p;
	for(int i=0;i<n;i++){
		int x; cin>>x;
		p.pb(mp(x,1));
	}
	for(int i=0;i<m;i++){
		int b,c;
		cin>>b>>c;
		p.pb(mp(c,b));
	}
	sort( p.begin(), p.end() );
	reverse( p.begin(), p.end() );
	int ans = 0, cnt = 0;
	for(int i=0;i<p.size();i++){
		if( cnt + p[i].second <= n ){
			ans += p[i].first * p[i].second;
			cnt += p[i].second;
		}
		else{
			ans += p[i].first * ( n - cnt );
			cnt = n;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6384
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>
     
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;

int main(){
    ll  n, d;
    cin >> n >> d;
    vector<ll> dst(n);
    rep(i, n){
        ll x, y;
        cin >> x >> y;
        dst[i] = x * x + y * y;
    }
    sort(ALL(dst));
    ll res = 0;
    rep(i, n){
        if(dst[i] <= d * d)res++;
      //cout << dst[i] << endl;
    }
    cout << res << endl;
}





Measured memory_bytes: 4840
#include <stdio.h>

int main(void){
  int x[5];
  
	scanf("%d %d %d %d %d",&x[0],&x[1],&x[2],&x[3],&x[4]); 
  
  
 	int i;
  for(i=0;i<5;i++){
    //scanf("%d", &x);
    if((i+1)!=x[i]){
      printf("%d", i+1);
    }
  }
  

  return 0;
}

Measured memory_bytes: 1692
import math

x = int( input() )
p = 100

for i in range( 10000000000 ):
    p_new = p * 1.01e0
#    print( p_new )
    p_new = math.floor( p_new )
#    print( p_new )
#    print( "\n" )

    if p_new >= x:
        print( i+1 )
        exit()

    p = p_new


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std; 
int main(){
//  freopen("test.in","r",stdin);
//  freopen("test.out","w",stdout);
	int n,q;
	long long k;
	cin>>n>>k>>q;
	int score0[n],score1[n],player[q];
	for(int i=0;i<n;i++){
		score1[i]=0; 
		score0[i]=k;
	}
	memset(player,0,sizeof(player));
	for(int i =0;i<q;i++){
		cin>>player[i];
        score1[player[i]-1]++;
	}
	for(int i=0;i<n;i++){
		score0[i]-=q-score1[i];
		if(score0[i]>0) 	cout<<"Yes"<<endl;
		else 	cout<<"No"<<endl;
	} 
	
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std ;
int main(){
    int n ;
    cin >> n ;
    for(int i=1 ; i*i<=n ; i++){
        if(n%i==0&&n/i<10){
            cout << "Yes" ;
            return 0 ;
        }
    }
    cout << "No" ;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var a, b, c int
  
  fmt.Scanf("%d %d %d", &a, &b, &c)
  
  ans := "Yes"
  if c < a {
    ans = "No"
  }
  if c > b {
    ans = "No"
  }
  
  fmt.Printf("%s", ans)
}

Measured memory_bytes: 1836
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

bool judge(ll X){
    for (ll i = 2; i * i <= X; ++i) if(X % i == 0) return false;
    return true;
}

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

    ll A, B;
    cin >> A >> B;

    map<ll, ll> mp, p;

    for (ll i = 1; i * i <= A; ++i){
        if(A % i == 0) ++mp[i], ++mp[A / i];
    }
    for (ll i = 1; i * i <= B; ++i){
        if(B % i == 0){
            if(mp.count(i)) ++p[i];
            if(mp.count(B/i)) ++p[B/i];
        }
    }

    ll ans = 0;
    for(auto P : p){
        if(judge(P.first)) ++ans;
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 1152
cookie_A, cookie_B, times = gets.split(' ').map(&:to_i)
 
if times > cookie_A
  times -= cookie_A
  cookie_A = 0
  if times > cookie_B
    print "0 0"
    exit
  else
    cookie_B -= times
    print "0 ", cookie_B
  end
else
  cookie_A -= times
  print cookie_A, " ", cookie_B
end

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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する
ll N,A,B;
vector<ll> h;

bool kill(int k){
    ll cnt = 0ll;
    rep(i,0,h.size()){
        if(h[i] - k * B > 0){
            cnt += (h[i] - k * B) / (A - B);
            cnt += ((h[i] - k * B) % (A - B) != 0);
        }
    }
    return cnt <= k;
}

int main() {
    cin >> N >> A >> B;
    rep(i,0,N){
        ll tmp;
        cin >> tmp;
        h.push_back(tmp);
    }
    int ok = (int)1e9;
    int ng = 0;
    while(ok - ng > 1){
        int mid = (ok + ng)/2;
        if(kill(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

double chebyshevDistance(vector<int> &x, vector<int> &y){
	double max = 0;
	vector<int>::iterator yi = y.begin();
	for(vector<int>::iterator xi = x.begin(); xi != x.end(); xi++){
		if(max < abs(*xi - *yi)){
			max = abs(*xi - *yi);
		}
		yi++;
	}
	return max;
}

double minkowskiDistance(vector<int> &x, vector<int> &y, double p){
	if(isinf(p)) return chebyshevDistance(x, y);

	double dPthPow = 0;
	vector<int>::iterator yi = y.begin();
	for(vector<int>::iterator xi = x.begin(); xi != x.end(); xi++){
		dPthPow += pow(abs(*xi - *yi), p);
		yi++;
	}
	return pow(dPthPow, 1 / p);
}

int main(){
	int n;
	cin >> n;
	vector<int> x, y;
	for(int i = 0; i < n; i++){
		int xi;
		cin >> xi;
		x.push_back(xi);
	}
	for(int i = 0; i < n; i++){
		int yi;
		cin >> yi;
		y.push_back(yi);
	}

	printf("%.6lf\n", minkowskiDistance(x, y, 1));
	printf("%.6lf\n", minkowskiDistance(x, y, 2));
	printf("%.6lf\n", minkowskiDistance(x, y, 3));
	printf("%.6lf\n", minkowskiDistance(x, y, 1.0/0.0));

	return 0;
}

Measured memory_bytes: 1304
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        newGraph g=new newGraph();
        for(int i=0;i<n;i++)
            for(int j=0;j<3;j++)
                g.add(i+1+","+j);
        for(int i=0;i<m;i++){
            int v=sc.nextInt();
            int u=sc.nextInt();
            g.add(v+",0");
            g.add(v+",1");
            g.add(v+",2");
            g.add(u+",0");
            g.add(u+",1");
            g.add(u+",2");
            g.unadd(v+",0",u+",1");
            g.unadd(v+",1",u+",2");
            g.unadd(v+",2",u+",0");
        }
        int ans=g.depth(sc.nextInt()+",0",sc.nextInt()+",0");
        System.out.println((ans==-1)?-1:ans/3);
	}
}
class newGraph {
	Map<String, ArrayList<String>> edge;
	Map<String, Integer> vertex;

	public newGraph() {
		edge = new HashMap<String, ArrayList<String>>();
		vertex = new HashMap<String, Integer>();
	}

	public void add(String a) {
		if (!edge.containsKey(a)) {
			ArrayList<String> cont = new ArrayList<>();
			edge.put(a, cont);
			vertex.put(a, 1);
		}
	}


	public void unadd(String a, String b) {
		if (edge.containsKey(a)) {
			edge.get(a).add(b);
			vertex.put(a, vertex.get(a) + 1);
		} else {
			ArrayList<String> cont = new ArrayList<>();
			cont.add(b);
			edge.put(a, cont);
			vertex.put(a, 1);
		}
		if (!edge.containsKey(b)) {
			ArrayList<String> cont = new ArrayList<>();
			edge.put(b, cont);
		}
	}

	public int depth(String a, String b) {
		if (!vertex.containsKey(a) || !vertex.containsKey(b))
			return -1;
		Map<String, Boolean> check = new HashMap<String, Boolean>();
		Queue<String> queue = new ArrayDeque<>();
		check.put(a, false);

		queue.add(a);
		queue.add("xxkiritoxx");
		int depth = 1;
		while (!check.containsKey(b) && queue.size() != 0) {
			//System.out.println(queue.get(0));

			String quevalue=queue.poll();
			if (quevalue.equals("xxkiritoxx")) {
				depth++;
				if (queue.size() != 0)
					queue.add("xxkiritoxx");
			} else {
				ArrayList<String> cont = new ArrayList<>(edge.get(quevalue));
				//System.out.println(cont);
				for (int i = 0; i < cont.size(); i++) {
					if (!check.containsKey(cont.get(i))) {
						queue.add(cont.get(i));
						check.put(cont.get(i), false);
					}
				}
			}
		}
		return check.containsKey(b) ? depth : -1;
	}

}

Measured memory_bytes: 196376
#include <stdio.h>

int main(void){
	int a, b, i, k;
	scanf("%d %d %d", &a, &b, &k);
	for(i = a; i >= 0; i--){
		if(a % i == 0 && b % i == 0){
			k--;
			if(k == 0)break;
		}
	}
	printf("%d\n", i);
	return 0;
}


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

"""
input:
6 9
0 1 1
0 2 3
1 2 1
1 3 7
2 4 1
1 4 3
3 4 1
3 5 1
4 5 6

output:
5
"""

import sys
from operator import attrgetter


class Edge(object):
    __slots__ = ('source', 'target', 'weight')

    def __init__(self):
        self.weight = float('inf')
        self.source, self.target = None, None


class UnionFind(object):
    __slots__ = ('size', 'tree_height_rank', 'ancestors')

    def __init__(self, size):
        self.size = int(size)
        self.tree_height_rank = [0] * self.size
        self.ancestors = [i for i in range(self.size)]

    def _find(self, x):
        if x != self.ancestors[x]:
            self.ancestors[x] = self._find(self.ancestors[x])
        return self.ancestors[x]

    def same(self, x, y):
        return self._find(x) == self._find(y)

    def _link(self, x, y):
        if self.tree_height_rank[x] > self.tree_height_rank[y]:
            self.ancestors[y] = x
        else:
            self.ancestors[x] = y
            if self.tree_height_rank[x] == self.tree_height_rank[y]:
                self.tree_height_rank[y] += 1

    def union(self, x, y):
        self._link(self._find(x), self._find(y))


def generate_edge_table(v_table):
    for index, each in enumerate(v_table):
        source, target, weight = map(int, each)
        edge = init_edge_table[index]
        edge.source = source
        edge.target = target
        edge.weight = weight

    return init_edge_table


def graph_Kruskal():
    total_cost = 0
    # sort edge_table by edge's weight
    edge_table.sort(key=attrgetter('weight'))
    # MST--> E = V + 1
    union_find_case = UnionFind(size=vertices + 1)
    for edge in edge_table:
        if not union_find_case.same(edge.source, edge.target):
            total_cost += edge.weight
            union_find_case.union(edge.source, edge.target)

    return total_cost


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

    init_edge_table = [Edge() for _ in range(edges)]
    edge_table = generate_edge_table(v_info)
    print(graph_Kruskal())

Measured memory_bytes: 32656
#include<bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef pair<ll,ll> PLL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<string> VS;
//template
template<class T> inline bool chmin(T &a, T b) {if (a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) {if (a < b){a = b; return true;} return false;}
//repetition
#define FOR(i,a,b) for(int i=int(a); i<int(b); ++i)
#define FORD(i,a,b) for(int i=int(a); i<int(b); --i)
#define REP(i,N) for(int i=0; i<int(N); ++i)
#define REPS(i,N) for(int i=0; i<=int(N); ++i)
#define REPD(i,N) for(int i=0; i<int(N); --i)
//container util
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//constant
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //配列の最大のrenge
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    int N; cin >> N;
    ll W; cin >> W;
    VL weight(N),value(N); 
    REP(i,N) cin >> weight[i] >> value[i];
    VVL dp(N+1, VL(100100, INF));
    
    dp[0][0] = 0;

    REP(i,N)REPS(sum_v, 100100) {
        if (sum_v - value[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
        chmin(dp[i+1][sum_v], dp[i][sum_v]);
    }

    ll res = 0;
    REP(v,100100) if (dp[N][v] <= W) res = v;
    cout << res << endl;
}

Measured memory_bytes: 83236
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	REP(i, n) cin >> a[i];
	int ans = k + a[0] - a[n - 1];
	REP(i, n - 1) ans = max(ans, a[i + 1] - a[i]);
	cout << k - ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <cmath>
 
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<pair<int,int>> vip;
 
#define pb push_back
#define ZOOM ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define LOOP_IT(s) for(auto it=(s).begin();it!=(s).end();++it)
#define loop for(int i=0;i<n;++i)
 
 
int main(int argc,char* argv[])
{
    ZOOM
 
    double a,b;bool f=0;
    cin>>a>>b;
 
    double x;
    for(x=1;x<=100000;++x)
    {
        double c,d;
        c=static_cast<double>(x*0.08);
        d=static_cast<double>(x*0.1);
        c=floor(c),d=floor(d);
        if(c==a&&d==b)
        {
            f=1;
            break;
        }
    }
    cout<<(f?x:-1);
 
 
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    VI num(n,0);
    VI copy(n,0);
    rep(i,n) {
        cin >> num[i];
        copy[i] = num[i];
    }
    sort(copy.begin(),copy.end());
    int max = copy[n-1];
    int eiennonibante = copy[n-2];
    rep(i,n){
        if(num[i] == max){
            cout << eiennonibante <<endl;
        }else{
            cout << max <<endl;
        }
    }
}

Measured memory_bytes: 4736
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
counter=0
tem=0
for i in range(n):
	at=(a[i]-tem)+a[i+1]
	if b[i]>=at:
		counter+=at
		tem=a[i+1]
	if at>b[i]:
		counter+=b[i]
		if b[i]-(a[i]-tem)>0:
			tem=b[i]-(a[i]-tem)
		else:
			tem=0
print(counter)

Measured memory_bytes: 18624
N, K = [int(x) for x in input().split()]
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
ans = Base_10_to_n(N, K)
print(len(ans))

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

using namespace std;

int main(void) {

    int N;
    cin >> N;

    vector<vector<int>> F(N, vector<int>(10));
    for (int shop_i = 0; shop_i < N; ++shop_i) {
        for(int day = 0; day < 10; ++day) {
            cin >> F[shop_i][day];
        }
    }
    vector<vector<int>> P(N, vector<int>(11));
    for (int shop_i = 0; shop_i < N; ++shop_i) {
        for(int time = 0; time < 11; ++time) {
            cin >> P[shop_i][time];
        }
    }

    int max_rev = -(1 << 30);
    for(int plan = 1; plan < (1 << 10); plan++) {
        int plan_rev = 0;
        for(int i = 0; i < N; ++i) {
            int matched_day = 0;
            for(int time = 0; time < 10; time++) {
                if ((plan>>time&1) && F[i][time]){
                    matched_day++;
                }
            }
            plan_rev+=P[i][matched_day];
        }

        if (max_rev < plan_rev) {
            max_rev = plan_rev;
        }
    }

    cout << max_rev << endl;



    return 0;
}

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

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N;
	vector<string> seen;
	cin >> N;
	rep(i, N) {
		string s;
		cin >> s;
		if (find(seen.begin(), seen.end(), s) == seen.end())
			seen.push_back(s);
	}
	if (seen.size() == 3)
		cout << "Three\n";
	else
		cout << "Four\n";
}


Measured memory_bytes: 256
#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, k;
	cin >> n >> k;
	
	double ans = 0.0;
	
	for(int i=1; i<=n; i++){
		int j = i;
		int cnt = 0;
		while(j < k){
			j *= 2;
			cnt++;
		}
		ans += 1.0 / n * pow(0.5, (double) cnt);
	}
	printf("%.10f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#define ll long long

using namespace std;

int main(){
  ll a, b, x;
  cin >> x;
  int Z = 300, tmp = 1, A, B;
  bool p = false;

  for (int i = 0; i < Z; i++) {
    for (int j = -tmp; j <= tmp; j += tmp*2) {
      for (int k = -tmp; k < tmp; k++) {
        a = pow(j, 5);
        b = pow(k, 5);
        if (a - b == x) {
          A = j;
          B = k;
          p = true;
          break;
        }
      }
    }
    tmp++;
    if (p) {
      break;
    }
  }


  cout << A << " " << B << endl;

  return 0;
}


Measured memory_bytes: 4112
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n;cin >> n;
  string s;
  cin >> s;

  char bef = s[0];
  ll num = 1;

  rep(i,n)
  {
    if(bef == s[i])
    {
      continue;
    }

    bef = s[i];
    num++;
  }

  cout << num << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>

using namespace std;

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

int main(){
	
	int n,m;
	cin >> n >> m;
	
	long long int students[50][2]={};
	long long int checkpoints[50][2]={};
	
	REP(i,n){
		cin >> students[i][0] >> students[i][1];
	}
	REP(i,m){
		cin >> checkpoints[i][0] >> checkpoints[i][1];
	}
	
	int nearest[50];
	
	REP(i,n){
		long long int distance;
		long long int n_distance=10000000000;
		REP(k,m){
			distance = abs(students[i][0]-checkpoints[k][0])+abs(students[i][1]-checkpoints[k][1]);
			if (distance<n_distance){
				nearest[i] = k;
				n_distance = distance;
			}
		}
	}
	
	REP(i,n){
		cout << nearest[i]+1 << endl;
	}
	
	
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] array = new int[n][3];
        for (int i = 0; i < n; i++) {
            array[i][0] = sc.nextInt();
            array[i][1] = sc.nextInt();
            array[i][2] = sc.nextInt();
        }
        

        int idx = 0;
        while (array[idx][2] < 1) {
            idx++;
        }
        int tmpx = array[idx][0];
        int tmpy = array[idx][1];
        int tmph = array[idx][2];
        
        for (int cx = 0; cx <= 100; cx++) {
            for (int cy = 0; cy <= 100; cy++) {
                int high = Math.abs(cx-tmpx) + Math.abs(cy-tmpy) + tmph;
                
                boolean ok = true;
                for (int k = 0; k < n; k++) {
                    int x = array[k][0];
                    int y = array[k][1];
                    int h = array[k][2];
                    
                    int tmp = Math.max(high - Math.abs(x-cx) - Math.abs(y-cy), 0);
                    if (h != tmp) {
                        ok = false;
                        break;
                    }
                }
                
                if (ok) {
                    System.out.println(cx + " " + cy + " " + high);
                    return;
                }
            }
        }
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int a,b,c,d;

	cin>>a>>b;
	if(b<10){
		c=a*10+b;
	}else if(b<100){
		c=a*100+b;
	}else{
		c=a*1000+b;
	}
	if(a<10){
		d=b*10+a;
	}else if(a<100){
		d=b*100+a;
	}else{
		d=b*1000+a;
	}
	int e,f;
	e=sqrt(c);
	f=sqrt(d);
	if(c==e*e||d==f*f){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}



return 0;
}


Measured memory_bytes: 256
# nCr
# 駄目な場合を考える
# - x+yが3の倍数でない
# - min(x,y):max(x,y)が倍より大きい
x, y = map(int, input().split())
if (x + y) % 3 != 0 or (min(x, y) / max(x, y)) > 2.0:
    print(0)
    exit()

# なぜかいつものこれだと99999で違った出力になりWAなる
# def nCr(n, r):
#     res = 1
#     for i in range(1, r + 1):
#         res = res * (n - i + 1) // i
#         res %= 10 ** 9 + 7
#     return res


# x, yがそれぞれ何回ずつ2と1を使うか -> 片方が決まれたば一意に定まる
# 適当な連立方程式
n = (x + y) // 3
p = (n - abs(x - y)) // 2
# print(n, p)
# print(nCr(n, p))


# なんでWAになるんだろうね ググった


def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10 ** 9 + 7  # 出力の制限
N = 10 ** 6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

print(cmb(n, p, mod))


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

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

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

	ll n;
	cin >> n;
	cout << (ll) pow(2, floor(log2(n))+1)-1;

	return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string s;cin >> s;
    int a = stoi(s.substr(0, 2));
    int b = stoi(s.substr(2, 2));
    if((a >= 1 && a <= 12) && (b >= 1 && b <= 12)){
        cout << "AMBIGUOUS" << endl;
    }else{
        if(a >= 1 && a <= 12){
            cout << "MMYY" << endl;
        }else if(b >= 1 && b <= 12){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    a,b,c,d = map(int, input().split())

    turn  = 0
    while True:
        if turn == 0:
            turn = 1
            c -= b
            if c <= 0:
                print("Yes")
                break
        else:
            turn = 0
            a -=d
            if a <= 0:
                print("No")
                break



Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

// B解答例
int main() {
    int h,w; cin >> h >> w;
    string board[50];
    rep(i,h) cin >> board[i];

    // 各方向に対する差分を持った配列を用意
    // 右，上，左，下，右上，左上，左下，右下
    const int dx[8] = {1,0,-1,0,1,-1,-1,1};
    const int dy[8] = {0,1,0,-1,1,1,-1,-1};

    // 各空白マスについて
    rep(i,h) {
        rep(j,w) {
            if (board[i][j] == '#') continue;

            int cnt = 0;
            // 各方向にある爆弾を調べる
            for (int d = 0; d < 8; d++) {
                const int ni = i + dy[d];
                const int nj = j + dx[d];

                if (ni < 0 || h <= ni) continue;
                if (nj < 0 || w <= nj) continue;
                if (board[ni][nj] == '#') cnt++;
            }
            
            // 数値+'0' => 数字
            board[i][j] = char(cnt + '0');
        } 
    }
    rep(i,h) cout << board[i] << endl;
    return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let mut v : Vec<i32> = get_vec();
    v.sort();
    println!("{}", v[0]+v[1]);
}


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

def makegraph(num, N): 
  time = 0
  for i in range(N-1):
    for j in range(N-1):
      if time >= num:
        return
      if i<j:
        print(i+2,j+2)
        time+=1

if K > (N-1)*(N-2)/2:
  print('-1')
else:
  num = (N-1)*(N-2)/2 - K
  print(int(N-1+num))
  for i in range(N-1):
    print(i+2, 1)
  time = 0        
  makegraph(num,N)
  




Measured memory_bytes: 43116