akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int INF=1e9;
const long double eps=1e-9;
const int maxn=1e2+10;
int d[maxn][maxn],f[maxn][maxn];
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	int i,j,k,l,m,n;
	int a,b;
	a=read();b=read();
	for(i=1;i<=a;i++)
		for(j=1;j<=b;j++)
			d[i][j]=read();
	for(i=1;i<=a;i++)
		for(j=1;j<=b;j++)
			for(k=0;k<=100;k++)
				for(l=0;l<=100;l++)
					f[k][l]=max(f[k][l],d[i][j]-i*k-j*l);
	for(i=1;i<=a;i++)
		for(j=1;j<=b;j++){
			int dis=INF;
			for(k=0;k<=100;k++)
				for(l=0;l<=100;l++)
					dis=min(dis,f[k][l]+i*k+j*l);
			if(dis!=d[i][j]){
				puts("Impossible");
				return 0;
			}
		}
	n=202,m=101*101+200;
	puts("Possible");
	printf("%d %d\n",n,m);
	for(i=1;i<=100;i++)printf("%d %d X\n",i,i+1);
	for(i=102;i<=201;i++)printf("%d %d Y\n",i,i+1);
	for(i=0;i<=100;i++)
		for(j=0;j<=100;j++)
			printf("%d %d %d\n",i+1,202-j,f[i][j]);
	printf("%d %d\n",1,n);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,arr[5];
	cin>>a>>b;
	arr[1]=a+a-1;
	arr[2]=b+b-1;
	arr[3]=a+b;
	arr[4]=0;
	for (int i=1;i<=3;i++) {
		if (arr[i]>arr[4]) {
			arr[4]=arr[i];
		}
	}
	cout<<arr[4]<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int X = in.nextInt();
            int[] x = in.nextIntArray(N);
            long ans = Math.max(X - x[0], x[N - 1] - X);
            for (int i = 0; i < N; i++) {
                if (X != x[i]) {
                    ans = gcd(ans, Math.abs(X - x[i]));
                }
            }
            out.println(ans);
        }

        long gcd(long a, long b) {
            return b == 0 ? a : gcd(b, a % b);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

    }
}



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

if K == 0:
    print(N**2)
    exit()
ans = 0
for b in range(1,N+1):
    p = N//b
    r = N%b
    ans += p*max(0,b-K) + max(0,r-K+1)

print(ans)


Measured memory_bytes: 2940
n,k= map(int, input().split())
p= list(map(int, input().split()))
c= list(map(int, input().split()))


ans=-float('inf')


x=[0]*n
for i in range(n):
    if x[i]==0:
        x[i]=1
        y=p[i]-1
        # 累積和を格納
        aa=[0,c[i]]
        # ２周させる
        life=2
        for j in range(2*n+2):
            x[y]=1
            if life>0:
                aa.append(aa[-1]+c[y])
                y=p[y]-1
                if y==i:
                    life-=1
            else:
                break
        # 各回数での取れるスコアの最大値
        x1=(len(aa)-1)//2

        a=[-float('inf')]*(x1+1)

        for ii in range(len(aa)-1):
            for j in range(ii+1,len(aa)):
                if j-ii<=x1:
                    a[j - ii] = max(a[j - ii], aa[j] - aa[ii])

        v=k//x1
        w=k%x1

        if v==0:
            ans=max(ans,max(a[:k+1]))

        elif v==1:

            ans = max(ans, max(a), v * aa[x1] + max(a[:w + 1]))
        else:
            ans=max(ans,max(a),v * aa[x1] + max(a[:w + 1]),(v-1)*aa[x1]+max(a))





print(ans)

Measured memory_bytes: 75120
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

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

        int N;
        int[] A1i;
        int[] A2i;
        Set<Integer> searched = new HashSet<>();
        Queue<Integer> queue = new LinkedList<>();
        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            A1i = new int[N];
            A2i = new int[N];
            for (int i = 0; i < N; i++) {
                A1i[i] = sc.nextInt();
            }
            for (int i = 0; i < N; i++) {
                A2i[i] = sc.nextInt();
            }
        }
        int[] Sum1 = new int[N];
        int sum1 = 0;
        for (int i = 0; i < N; i++) {
            sum1 += A1i[i];
            Sum1[i] = sum1;
        }
        int[] Sum2 = new int[N];
        int sum2 = 0;
        for (int i = N - 1; i >= 0; i--) {
            sum2 += A2i[i];
            Sum2[i] = sum2;
        }
        int result = 0;
        for (int i = 0; i < N; i++) {
            if (result < Sum1[i] + Sum2[i]) {
                result = Sum1[i] + Sum2[i];
            }
        }
        System.out.println(result);

    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  rep(i, s.size()) s.at(i) -= '0';
  ll sum = 0;
  rep(i, (1 << (s.size()-1))){
    ll add = 0, sa = s.at(0);
    rep(jj, s.size()-1){
      int j = jj + 1;
      if((i & (1 << jj)) == 0){
        sa *= 10;
        sa += s.at(j);
      }else{
        add += sa;
        sa = s.at(j);
      }
      // cerr << i << " " << j << " " << jj << " " << add << " " << sa << endl;
    }
    add += sa;
    // cerr << add << endl;
    sum += add;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let Y: usize = read();
    let Y = Y / 1000;
    for ten_count in 0..N + 1 {
        for five_count in 0..N + 1 {
            if ten_count + five_count > N {
                continue;
            }
            let one_count = N - ten_count - five_count;
            if ten_count * 10 + five_count * 5 + one_count == Y {
                println!("{} {} {}", ten_count, five_count, one_count);
                return;
            }
        }
    }
    println!("-1 -1 -1");
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long ans = 0;
        long sum = x;
        while(sum <= y) {
            sum *= 2;
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35832
#include <bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	#define PI 				acos(-1)
	#define mp				make_pair
	#define pb				push_back
	#define all(a)			(a).begin(), (a).end()
	#define sz(a)			a.size()
	#define srt(a)			sort(all(a))
	#define mem(a, h)		memset(a, (h), sizeof(a))
	#define f 				first
	#define s 				second
	#define MOD1			998244353
	#define fore(i, b, e)	for(int i = b; i < e; i++)
	#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
	int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

	using namespace std;
	using namespace __gnu_pbds;

	typedef long long 		ll;
	typedef unsigned long long 		ull;
	typedef pair<int, int>  ii;
	typedef vector<int>     vi;
	typedef vector<ii>      vii;
	typedef vector<ll>      vll;
	typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
	const int tam = 100010;
	const int MOD = 1e9+7;
	const double EPS = 1e-9;

	int main()
	{
		ios::sync_with_stdio(0); cin.tie(0);
		//freopen("qwe.txt", "r", stdin);
		//freopen("asd.txt", "w", stdout);
		int n, a, b, c, x = 0, y = 0;
		cin>>n;
		int t = 0;
		while(n--)
		{
			cin>>c>>a>>b;
			c = c - t;
			t += c;
			int d = abs(a - x) + abs(b - y);
			//cout<<d<<' '<<c<<'\n';
			if(!(d <= c && (d + c) % 2 == 0))
			{
				cout<<"No\n";
				exit(0);
			}
			x = a, y = b;
		}
		cout<<"Yes\n";
		return 0;
	}

	// read the question correctly (is y a vowel? what are the exact constraints?)
	// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 256
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;
typedef long long ll;
const int MAXN = 100010;

int n, a, b, h[MAXN];

bool check( ll x ) {
	ll more = a-b, cnt = 0;
	for( int i = 0; i < n; ++i ) {
		ll left = h[i] - b*x;
		if( left <= 0 ) continue;
		cnt += left/more;
		if( left % more ) ++cnt;
	}
	return cnt <= x;
}

void solve() {
	int low = 0, high = 1e9;
	while( low < high ) {
		int mid = (low + high)/2;
		if( check(mid) ) high = mid;
		else low = mid+1;
	}
	printf( "%d\n", low );
}

int main() {
	scanf( "%d%d%d", &n, &a, &b );
	for( int i = 0; i < n; ++i ) scanf( "%d", h+i );
	solve();
	return 0;
}


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

using namespace std;

int main(void)
{
    int N, K;
    cin >> N >> K;

    bool having[100];
    for(int i = 0; i < N; i++){
        having[i] = false;
    }
    for(int i = 0; i < K; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a;
            having[a-1] = true;
        }
    }

    int count = 0;
    for(int i = 0; i< N; i++){
        if(having[i] == false){
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3540
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1005;
typedef long long ll;
int n,K;
int a[N];
ll v[N*N];
ll nv[N*N];
int main(){
    scanf("%d%d",&n,&K);
    for(int i=0;i<n;++i)scanf("%d",&a[i]);
    int sz=0;
    for(int i=0;i<n;++i){
        ll sum=0;
        for(int j=i;j<n;++j){
            sum+=a[j];
            v[sz++]=sum;
        }
    }
    ll ans=0;
    for(ll i=(1LL<<60);i;i>>=1){
        int nsz=0;
        for(int j=0;j<sz;++j){
            if((i&v[j])==i){
                nv[nsz++]=v[j];
            }
        }
        if(nsz<K)continue;
        ans|=i;
        memcpy(v,nv,sizeof nv);
        sz=nsz;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 10752
#include<stdio.h>
#define MAX 500

static const int INFTY = (1<<21);

main(){
  int n,i,j,e,sum,u,v,minv;
  int A[MAX][MAX];
  int B[MAX],C[MAX],D[MAX];

  scanf("%d",&n);

  for ( i=0 ; i<n ; i++ ){
    for ( j=0 ; j<n ; j++ ){
      scanf("%d",&e);
      A[i][j] = (e==-1)?INFTY:e;
    }
  }

  for ( i=0 ; i<n ; i++ ) {
    B[i] = INFTY;
    C[i] = -1;
    D[i] = 0;
  }

  B[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for ( i=0 ; i<n ; i++ ){
      if ( minv > B[i] && !D[i] ){
	u = i;
	minv = B[i];
      }
    }
    if ( u == -1 ) break;
    D[u] = 1;
    for ( v=0 ; v<n ; v++ ){
      if ( !D[v] && A[u][v] != INFTY ){
	if ( B[v] > A[u][v] ){
	  B[v] =  A[u][v];
	  C[v] = u;	
	}
      }
    }
  }

  sum = 0;

  for ( i=0 ; i<n ; i++ ){
    if ( C[i] != -1 )
      sum += A[i][C[i]];
  }

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

  return 0;
}



Measured memory_bytes: 2088
import math
n=int(input())
b=1
a=list(map(int,input().split()))
x=1000000000000000000
for i in range(n):
    if(a[i]==0):
        print(0)
        exit(0);

for i in range(n):
    b=b*a[i]
    if(b>x):
        print(-1)
        exit(0)

print(b);


Measured memory_bytes: 22576
#include<iostream>
//#include<numeric>
#include<algorithm>

using namespace std;

int main() {
    int K;
    int sum = 0;
    cin >> K;
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            for (int k = 1; k <= K; k++) {
                int temp = __gcd(i, j);
                sum += __gcd(temp, k);
            }
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3636
A = list(map(lambda x: int(x),input().split()))
N = A[0]
K = A[1]

start = range(1,N+1)
ex = 0.0
for i in start:
    score = i
    p = 1.0
    cointoss = 0.0
    while K>score:
        score *= 2
        cointoss +=1
    a  =repr(p * 0.5 ** cointoss)
    #print(a)
    ex += float(a)

print(repr(ex/float(N)))
    

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

int main(){
    string s, t;
    cin >> s >> t;

    int len_s = s.length();
    int len_t = t.length();

    char inc_s[len_s];
    char inc_t[len_t];

    for(int i = 0; i < len_s; i++){
        inc_s[i] = s[i];
    }
    for(int i = 0; i < len_t; i++){
        inc_t[i] = t[i];
    }

    sort(inc_s, inc_s + len_s);
    sort(inc_t, inc_t + len_t, greater<int>());

    string s_after, t_after;

    for(int i = 0; i < len_s; i++){
        s_after += inc_s[i];
    }
    for(int i = 0; i < len_t; i++){
        t_after += inc_t[i];
    }

    if(s_after < t_after){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    static int n;//nÔÚÌf
    static int[] p;
    static int MAX = 1000000;
    static int count;

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

	//GgXelXÌâ¿
	//zñð1000000pÓµÄAYªfÈç1A»êÈOÍ0ði[
	p = new int[MAX];
	for(int i=2; i<p.length; i++)p[i] = 1;
	for(int i=2; i<Math.sqrt(MAX)+1; i++){
	    for(int j=i*2; j<MAX; j+=i){
		p[j] = 0;
	    }
	}

	int a = sc.nextInt();//
	int d = sc.nextInt();//ö·
	n = sc.nextInt();

	while(a!=0 && d!=0 && n!=0){
	    count=0;

	    System.out.println(solve(a,d));

	    a = sc.nextInt();
	    d = sc.nextInt();
	    n = sc.nextInt();
	}
    }

    public static int solve(int a, int d){
	for(;;){
	    if(p[a]==1)count++;//aªfÈç   
	    if(count==n)break;//nÔÚÌfªÜÁ½ç
	    a += d;
	}
	return a;
    }
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,i,j,k,x,a[1005],f[1005],g[1005][5005],sum,flag;
int top,nex[1005],to[1005],fir[1005];
void lj(int u,int v){
	top++;
	nex[top]=fir[u];
	fir[u]=top;
	to[top]=v;
}
void ss(int v){
	if(flag==1)
		return;
	for(int top1=fir[v];top1;top1=nex[top1])
		ss(to[top1]);
	g[0][0]=1;
	j=0;
	sum=0;
	for(int top1=fir[v];top1;top1=nex[top1]){
		j++;
		for(i=0;i<=a[v];i++){
			if(i>=a[to[top1]])
				g[j][i]|=g[j-1][i-a[to[top1]]];
			if(i>=f[to[top1]])
				g[j][i]|=g[j-1][i-f[to[top1]]];
		}
		sum+=a[to[top1]]+f[to[top1]];
	}
	for(i=a[v];i>=0;i--)
		if(g[j][i]==1){
			f[v]=sum-i;
			for(i=0;i<=j;i++)
				for(k=0;k<=a[v];k++)
					g[i][k]=0;
			return;
		}
	flag=1;
	return;
}
int main(){
    //freopen("mate.in","r",stdin);
    //freopen("teleport.in","w",stdout);
    n=read();
    for(i=2;i<=n;i++){
    	x=read();
    	lj(x,i);
    }
	for(i=1;i<=n;i++)
		a[i]=read();
	ss(1);
	if(flag==1)
		printf("IMPOSSIBLE\n");
	else
		printf("POSSIBLE\n");
	return 0;
}

Measured memory_bytes: 17280
import java.util.*;
import java.io.*;
public class Main {
    static int[][] A;
    public static void main(String[] args) throws Exception {
        InputStreamReader r = new InputStreamReader(System.in);
        int N = nextInt(r);
        A = new int[N][N];
        for (int i = 0; i < N; i++) {
            int Ai = nextInt(r);
            for (int j = 0; j < Ai; j++) {
                int x = nextInt(r);
                int y = nextInt(r);
                A[i][x-1] = y == 1 ? 1 : -1;
            }
        }

        int ans = 0;
        int pow = pow(N);
        for (int i = 0; i < pow; i++) {
            int[] d = set(N, i);
            boolean[] f = new boolean[2]; // [0]:ok, [1]:update
            do {
                f = check(N, d);
            } while (f[0] && f[1]);
            if (f[0]) {
                int c = 0;
                for (int j = 0; j < N; j++) {
                    if (d[j] == 1) {
                        c++;
                    }
                }
                ans = Math.max(ans, c);
            }
        }
        System.out.println(ans);
    }

    public static int nextInt(InputStreamReader r) throws Exception {
        String str = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            str += (char)c;
        }
        return Integer.parseInt(str);
    }

    public static int pow(int N) {
        return N == 0 ? 1 : 2 * pow(N-1);
    }

    public static int[] set(int N, int i) {
        int[] res = new int[N];
        for (int j = 0; j < N; j++) {
            res[j] = i % 2 == 1 ? 1 : 0;
            i = i / 2;
        }
        return res;
    }

    public static boolean[] check(int N, int[] d) {
        boolean[] res = new boolean[2];
        res[0] = true;
        for (int j = 0; j < N; j++) {
            if (d[j] == 1) {
                for (int k = 0; k < N; k++) {
                    if (A[j][k] == 1) {
                        if (d[k] == -1) {
                            res[0] = false;
                            return res;
                        }
                        if (d[k] == 0) {
                            d[k] = A[j][k];
                            res[1] = true;
                        }
                    }
                    if (A[j][k] == -1) {
                        if (d[k] == 1) {
                            res[0] = false;
                            return res;
                        }
                        if (d[k] == 0) {
                            d[k] = A[j][k];
                            res[1] = true;
                        }
                    }
                }
            }
        }
        return res;
    }
}


Measured memory_bytes: 27332
a,b,c,x,y = map(int,input().split())
z = 0
p = 0

if a + b < c * 2:
    p = a * x + b * y
else:
    if x > y:
        x -= y
        z = y * 2
        y = 0
        if a > c * 2:
            z += x * 2
            x = 0

    else:
        y -= x
        z = x * 2
        x = 0
        if b > c * 2:
            z += y * 2
            y = 0

print(x * a + y * b + z * c)


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

int mas[10];

int used[10];

int isOK(){
	int *num = used + 6;
	num[2] = used[0] + used[2] + used[5];
	num[1] = num[2]/10 + used[1] + used[4];
	num[2] %= 10;
	num[0] = num[1]/10 + used[3];
	num[1] %= 10;
	
	if(num[0] >= 10){
		return 0;
	}

	int u[10] = {};
	for(int i = 0;i < 10;i++){
		if(mas[i] != -1 && mas[i] != used[i]){
			return 0;
		}
		if(u[used[i]]) return 0;
		u[used[i]] = 1;
	}

	return 1;
}

int dfs(int num){
	if(num == 6){
		return isOK();
	}
	
	int ans = 0;
	for(int i = 1;i <= 9;i++){
		used[num] = i;
		ans += dfs(num+1);
	}

	return ans;
}

int main(){
	for(int i = 0;i < 9;i++) cin >> mas[i];

	cout << dfs(0) << endl;
	return 0;
}


Measured memory_bytes: 3096
h, w = (int(_) for _ in input().split())

s = [input() for i in range(h)]

for i in range(len(s)):
    t = list(s[i])
    t.insert(0,'#')
    t.append('#')
    s[i] = ''.join(t)


print('#'*(w+2))
for i in range(len(s)):
    print(s[i])
print('#'*(w+2))

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

#define   M             100005
#define   ll            long long
#define   PI            atan(1.0)*4
#define   mst(x,v)      memset(x,v,sizeof(x))
#define   inf           (int)1e9

typedef   pair<int,int> P;

ll a[M],b[M];


int main() {

	ll n,temp;
	ll pst=0,ngt=0;
	scanf("%lld",&n);
	
	for(int i=0;i<n;i++) scanf("%lld",&a[i]);
	for(int i=0;i<n;i++) scanf("%lld",&b[i]);
	
	ll f=0;
	
	for(int i=0;i<n;i++) {
		temp=b[i]-a[i];
		
		if(temp>0) f+=temp/2;
		if(temp<0) f+=temp;
	}
	
	
	if(f>=0)    puts("Yes");
	else        puts("No"); 
//	printf("%d\n",f);
}




Measured memory_bytes: 512
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	int k, x;

	cin >> k >> x;

	if (500 * k >= x) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;


int main(){

	ll a,b;
	cin >> a >> b;

	ll p = __gcd(a,b);

	int ans = 1;

	
	for(int i=2;(ll)i*i<=p;i++){
		if(p%i==0){
			ans++;
			while(p%i==0){
				p/=i;
			}
		}
	}
	if(p>1) ans++;

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int m[500][500];
int dp[500][500];

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

int solve(int r,int c){
  rep(i,r+2)rep(j,c)dp[i][j]=0;
  rep(j,c)if(m[0][j] == 0)dp[0][j]=1;

  rep(i,r){
    rep(j,c){
      if (m[i][j] == 0 && i != r-1){
	rep(k,3){
	  int nex = j+dx[k];
	  if (nex<0||nex>=c)continue;
	  if (m[i+1][nex] == 0)dp[i+1][nex]+=dp[i][j];
	  else if (m[i+1][nex] == 2 && k == 1)dp[i+1][nex]+=dp[i][j];
	}
      }else if (m[i][j] == 2 && m[i+2][j] != 1){
	dp[i+2][j]+=dp[i][j];
      }
    }
  }
  
  int ans = 0;
  rep(j,c)ans+=dp[r][j]+dp[r-1][j];//+dp[r+1][j];
  return ans;
}

main(){
  int c,r;
  while(cin>>c>>r && r){
    rep(i,r)rep(j,c)cin>>m[i][j];
    rep(j,c)m[r][j]=m[r+1][j]=0;
    cout << solve(r,c) << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int main(void) {
	int a,b; cin >> a >> b;
	if(a<b) rep(i,b) cout << a;
	else rep(i,a) cout << b;
	cout << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main()
{
    int h,w;
    cin >> h >> w;
    vector<vector<int>> g(10,vector<int>(10,-1));
    rep(i,10)rep(j,10)cin >> g[i][j];
    vector<vector<int>> f(h,vector<int>(w,0));
    rep(i,h)rep(j,w)cin >> f[i][j];
    rep(k,10)rep(i,10)rep(j,10){
        g[i][j] = min(g[i][j],g[i][k]+g[k][j]);
    }
    int ans = 0;
    rep(i,h)rep(j,w){
        if(f[i][j] == -1)continue;
        ans += g[f[i][j]][1];
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 384
s = input()

n = len(s)-1
ans = 0

for i in range(2**n):
    formula = s[0]
    for j in range(n):
        if (i >> j) & 1:
            formula += "+"
        formula += s[j+1]
    f = list(map(int, formula.split("+")))
    ans += sum(f)

print(ans)


Measured memory_bytes: 41708
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;++i)
template<class T, class U>inline bool chmax(T &a, U const &b) { if(a<b){ a=b;return 1; } return 0; }
template<class T, class U>inline bool chmin(T &a, U const &b) { if(b<a){ a=b;return 1; } return 0; }

long long gcd(long long a, long long b) {
  return b ? gcd(b, a % b): a;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) { cin >> a[i]; }

  vector<int> left(n + 1, 0), right(n + 1, 0);
  rep(i, n) {
    left[i + 1] = gcd(a[i], left[i]);
    right[n - i - 1] = gcd(a[n - i - 1], right[n - i]);
  }

  long long ans = 0;
  rep(i, n) { chmax(ans, gcd(left[i], right[i + 1])); }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,ans=0;
    map<ll,ll> mp;
    cin >> n;
    vll a(n);
    rep(i,n){
        cin >> a[i];
        mp[a[i]]++;
    }
    sort(all(a));
    for(ll i=a[0];i<=a[n-1];i++){
        ans=max(ans,mp[i-1]+mp[i]+mp[i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll A,B;
  cin >> A >> B;
  cout << lcm(A,B) << endl;

}


Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <limits>
#include <type_traits>

using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;
 
int main() {
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
	
}

Measured memory_bytes: 256
#include <cstdio>
int sum[101];
bool toll[101];
int main(int argc, const char * argv[]) {
   
    int n,m,x;
    
    
    scanf("%d %d %d",&n,&m,&x);
    
    for(int i=0,tmp;i<m;i++){
        scanf("%d",&tmp);
        toll[tmp]=true;
    }
    
    for(int i=1;i<n;i++) sum[i] = sum[i-1] + toll[i];
    
    int left = sum[x];
    int right = sum[n-1]-sum[x];
    
    if(left>right) printf("%d\n",right);
    else printf("%d\n",left);
    
    return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a<b){
        for(int i=0;i<b;i++){
            cout << a;
        }
    }else{
        for(int i=0;i<a;i++){
            cout << b;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N; cin >> N;
	rep(x,100000){
		if(x * 108 / 100 == N){
			cout << x << endl;
			return 0;
		}
	}
	cout << ":(" << endl;

}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

mod = 1000000007

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
s = ns()
t = ns()

ans = n * 2

c = 0
for i in range(n):
	if s[i] == t[c]:
		c += 1
	else:
		c = 0
		if s[i] == t[c]:
			c += 1

ans -= c
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int ans = K;
    for(int i = 1; i < N; i++) {
      ans *= (K - 1);
    }
    System.out.println(ans);
  }
}

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

int main(){
    char A[3];
    for (int i=0; i<3; i++) cin >>A[i];
    
    for (int i=0; i<3; i++){
        if (A[i]=='1'){
            A[i]='9';
        }else{
            A[i]='1';
        }
    }
    for (int i=0; i<3; i++) cout << A[i];
    
}

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;
  cin >> n;

  vector<int> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());

  cout << vec[(n/2)] - vec[(n/2)-1] << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <iomanip>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-10;
const int inf=1e9;
typedef pair<int,int> P;

class Point
{
public:
  double x,y;
  Point(double x,double y): x(x),y(y){}
  Point operator + (const Point &p)
  {
    return Point(x+p.x,y+p.y);
  }
  Point operator - (const Point &p)
  {
    return Point(x-p.x,y-p.y);
  }
  Point operator * (double k)
  {
    return Point(x*k,y*k);
  }
  Point operator / (double k)
  {
    return Point(x/k,y/k);
  }
  bool operator < (const Point &p) const
  {
    return x!=p.x ? x<p.x : y<p.y;
  }
  bool operator == (const Point &p) const
  {
    return fabs(x-p.x)<eps && fabs(y-p.y) < eps;
  }
};
typedef Point Vector;
double dot(Vector a,Vector b)
{
  return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b)
{
  return a.x*b.y - a.y*b.x;
}
double norm(Point a)
{
  return a.x*a.x + a.y*a.y;
}
double abs(Vector a)
{
  return sqrt(norm(a));
}
struct Segment
{
  Point p1,p2;
  Segment(Point p1,Point p2): p1(p1),p2(p2){}
};
typedef Segment Line;

class Circle
{
public:
  Point c;
  double r;
  Circle(Point c,double r):  c(c),r(r){}
};

typedef vector<Point> Polygon;


bool isorthogonal(Vector a,Vector b)
{
  return fabs(dot(a,b)-0.0)<eps;
}

bool isparallel(Vector a,Vector b)
{
  return fabs(cross(a,b)-0.0)<eps;
}
Point project(Segment s,Point p)
{
  Vector base=s.p2-s.p1;
  double r=dot(p-s.p1,base) / norm(base);
  return  s.p1 + base*r;
}
Point reflect(Segment s,Point p)
{
  return p+ (project(s,p)-p)*2.0;
}
int main(int argc,char const* argv[])
{
  int q;
  double p1x,p1y,p2x,p2y;
  cin >> p1x >> p1y >> p2x >> p2y;
  Point p1=Point(p1x,p1y);
  Point p2=Point(p2x,p2y);
  Segment s=Segment(p1,p2);
  cin >> q;
  for(int i=0;i<q;i++)
    {
      int x,y;
      cin >> x >> y;
      Point p=Point(x,y);
      Point ref=reflect(s,p);
      cout << fixed << setprecision(9) << ref.x << ' ' << ref.y << endl;
    }
}



Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
vector<int> v;
int main()
{
    int n,ans;
    cin>>n;
    for(register int i=1;i<=n;++i)
    {
        int x;
        cin>>x;
        if(m[x]==0)
			v.push_back(x);
        m[x]++;
    }
    for(register int i=0;i<v.size();++i)
        if(m[v[i]]>=v[i])
            ans+=m[v[i]]-v[i];
        else
            ans+=m[v[i]];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5112
import java.util.Scanner

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val d = sc.nextInt()
    val e = sc.nextInt()
    val k = sc.nextInt()
    val anntenas = listOf(e, d, c, b, a)
    val result = take(anntenas, k)
    println(result)
}


private fun take(list: List<Int>, k: Int): String {
    val first = list.firstOrNull() ?: return "Yay!"
    val dropList = list.drop(1)
    dropList.forEach {
        if (first - it > k) {
            return ":("
        }
    }
    return take(dropList, k)
}

Measured memory_bytes: 35660
#include <string>
#include <vector>
#include <iostream>

using namespace std;


string get_format(string s) {
	vector<char> v;
	string f;

	for (int i = 0; i < s.size(); i++) {
		int j;
		for (j = 0; j < v.size(); j++) {
			if (s[i] == v[j]) {
				//大文字で表す
				f.push_back('A' + j);
				break;
			}
		}
		if (j == v.size()) {
			v.push_back(s[i]);
			f.push_back( 'A' + j);
		}
	}
	return f;
}

int main()
{

	string s, t;

	cin >> s >> t;

	string sf = get_format(s);
	string tf = get_format(t);

	if (sf == tf) cout << "Yes";
	else cout << "No";


	return 0;
}


Measured memory_bytes: 1480
#include <stdio.h>
#include <stdlib.h>
int	max(int a, int b)
{
	return ((a > b) ? a : b);
}
int	main(void)
{
	int	N;
	int	*A;
	long long	res = 0;
	int	m = 0;
	int	i;

	scanf("%d", &N);
	A = malloc(sizeof(int) * N);
	for (i = 0; i < N; i++)
		scanf("%d", &A[i]);
	for (i = 0; i < N; i++)
	{
		m = max(m, A[i]);
		res += m - A[i];
	}
	printf("%lld\n", res);
	free(A);
	return (0);
}

Measured memory_bytes: 2220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n;   cin >> n;
    vector<ll> w(n), a(n+1, 0);
    rep(i, n)    cin >> w[i], a[i+1] = a[i]+w[i];
    ll res=LINF;
    FOR(i, 1, n){
        res = min(res, abs(a[i]-(a.back()-a[i])));
    }
    cout << res << endl;
}


Measured memory_bytes: 3636
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll n,a[3010],dp[3010][3010];

int main()
{Tie
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i],dp[i][0]=(n&1?1:-1)*a[i];
	for(int i=1;i<n;i++)
		for(int j=0;j+i<n;j++)
		{
			if((i+(n&1?0:1))&1)
				dp[j][i]=min(dp[j][i-1]-a[j+i],dp[j+1][i-1]-a[j]);
			else
				dp[j][i]=max(dp[j][i-1]+a[j+i],dp[j+1][i-1]+a[j]);
		}
	cout <<dp[0][n-1]<<'\n'; 
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	#define endl "\n"
	#define space " "
	#define ll long long int
	#define vl vector<ll>
	#define vvl vector < vll >
	#define pii pair<int,int>
	#define pll pair<ll,ll>
	#define vpl vector < pll >
	#define mod 1000000007
	#define pi 3.1415926535897932384626433
	#define inf 1000000000000000001;
	#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y) 
	#define mem(a,val) memset(a,val,sizeof(a))
	#define pb push_back
	#define f first
	#define s second
	
	void solve()
	{
		ll n,d; cin>>n>>d;
		ll c=0;
		for (int i = 0; i < n; ++i)
		{
			/* code */
			ll x,y; cin>>x>>y;
			double p =  sqrt((x*x)+(y*y));
			if(p<=d) c++;
		}
		cout<<c<<endl;
	}

	signed main()
	{

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

	ll T=1;
	// cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
	}


Measured memory_bytes: 3640
#include<stdio.h>

 void bubbleSort(int[],int);

 int main(){
   int A[100];
   int i,n;
   scanf("%d",&n);
   if(n>=1&&n<=100){

     for(i=0;i<n;i++){
       scanf("%d",&A[i]);
     }
   bubbleSort(A,n);
   }
 }

void bubbleSort(int A[],int n){
  int num;
  int count=0;
  int j,i,k;

  for(i=0;i<n-1;i++){
    for(j=n-1;j>=i+1;j--){  
      if(A[j]<A[j-1]){
        num=A[j-1];
        A[j-1]=A[j];
        A[j]=num;
        count++; 
      }
    }
  }
  for(k=0;k<n;k++){
    printf("%d",A[k]);
     if(k<n-1)printf(" ");
    }
    printf("\n");
  printf("%d\n",count);
}



Measured memory_bytes: 2108
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int n,m;
  cin>>n>>m;
  int i;
  int path[10][10]={};
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    path[a][b]++;
    path[b][a]++;
  }
 
  vi v;
  rep(i,n)v.push_back(i);
 
  int ans=0;
  do{
    if(v[0]!=0)break;
    rep(i,n-1)
      if(path[v[i]][v[i+1]]==0)break;
    if(i==n-1)ans++;
  }while(next_permutation(all(v)));
 
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int  A,B,C,X,Y;
  cin  >> A >> B >> C >> X >> Y;
  int t=10000000000;
  int a,b;
  for(int i=0; i<=100000; i++){
    a=X-i;
    b=Y-i;
    if(a<0){a=0;}
    if(b<0){b=0;}
    if(A*a+B*b+C*2*i<=t){t=A*a+B*b+C*2*i;}
  }
  cout << t <<endl;
}


Measured memory_bytes: 256
import bisect
N = int(input())
A = sorted(list(map(int, input().split())))

ans = 0
for k in range(N-1,1,-1):
    if A[k]==int(A[k]):
        b = 1
        while b <= A[k]:
            b *= 2
        p = bisect.bisect_left(A,b-A[k])
        if p != k and A[p]+A[k] == b:
            ans += 1
            A[k] += 0.9
            A[p] -= 0.9
print(ans)


Measured memory_bytes: 95620
#include <iostream>
#include <set>
#include <utility>
#include <algorithm>
using namespace std;
pair<int,pair<int,int>> p[200010];
set<pair<int,int>> s;
int ans[200010];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,n,q;
	cin >> n >> q;
	for(i=0;i<n;i++){
		int l,r,x;
		cin >> l >> r >> x;
		p[i] = {x,{l,r}};
	}
	sort(p,p + n);
	for(i=0;i<q;i++){
		int d; cin >> d;
		s.insert({d,i}); ans[i] = -1;
	}
	for(i=0;i<n;i++){
		int x = p[i].first;
		int l = p[i].second.first - x,r = p[i].second.second - x;
		auto it = s.lower_bound({l,-1});
		while(it!=s.end()){
			if(it->first>=r) break;
			ans[it->second] = x;
			s.erase(it++);
		}
	}
	for(i=0;i<q;i++){
		cout << ans[i] << "\n";
	}
}

Measured memory_bytes: 14464
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
どれをA,B,Cにするか
*/

ll n,a[3],l[10];

ll f(ll s,ll t){
	if(t==3)return 0;
	ll ans=1e9;
	vector<ll> v;//使えるやつ
	rep(i,n){
		if(!(s>>i & 1)){//使われてない
			v.push_back(i);
		}
	}
	// cout<<v.size()<<endl;
	if(v.size()==0)return 1e9;
	rep(s2,1<<v.size()){
		if(s2==0)continue;
		ll s3=s,sum=0,cnt=0;
		rep(j,v.size()){
			if(s2>>j & 1){//使う
				s3|=(1<<v[j]);
				sum+=l[v[j]];
				cnt++;
			}
		}
		ans=min(ans,abs(a[t]-sum)+10*(cnt-1)+f(s3,t+1));
	}
	return ans;
}

int main(void){
	cin>>n;
	rep(i,3)cin>>a[i];
	rep(i,n)cin>>l[i];
	// cout<<((1<<n)-1)<<endl;
	cout<<f(0,0)<<endl;
	return 0;
}

Measured memory_bytes: 888
N=int(input())
a=list(map(int,input().split()))
a=[bin(a[i])[-1:1:-1] for i in range(N)]
ans=0
x=[-1]*20
tmp=-1
for i in range(N):
    for j in range(len(a[i])):
        if a[i][j]=="1":
            tmp=max(tmp,x[j])
            x[j]=i
    ans+=i-tmp

print(ans)

Measured memory_bytes: 26656
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct point
{
	long long name; long long dist;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};

ll a[100005];

int main() {
	ll n;
	cin >> n;
	REP(i, 1, n) {
		cin >> a[i];
	}
	ll ans = 0;
	ll cur = 0;
	REP(i, 1, n) {
		if (cur == 0) {
			ans += a[i] / 2;
			if (a[i] % 2 == 1) {
				cur = 1;
			}
		}
		else {
			if (a[i] == 0) {
				cur = 0;
			}
			else {
				a[i]--;
				ans++;
				ans += a[i] / 2;
				cur = 0;
				if (a[i] % 2 == 1) {
					cur = 1;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
  var n, a, b int
  fmt.Scanf("%d %d %d", &n, &a, &b)
  x := n / (a+b)
  y := n % (a+b)
  //fmt.Println(x, y)
  if y > a {
    fmt.Println(x * a + a)
  } else {
    fmt.Println(x * a + y)
  }
}


Measured memory_bytes: 512