akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=998244353;

LL n,n2=1,q,dat[800010],lazy[800010],rem[20][200010],pw[200010],ans;

void build(LL k,LL lb,LL ub)
{
	if(lb==ub)
	{
		dat[k]=1;
		return;
	}
	build(k*2+1,lb,(lb+ub)/2);
	build(k*2+2,(lb+ub)/2+1,ub);
	dat[k]=(dat[k*2+1]*pw[(ub-lb+1)/2]+dat[k*2+2])%MOD;
}

void pushdown(LL k,LL len)
{
	if(lazy[k]==0) return;
	lazy[k*2+1]=lazy[k*2+2]=lazy[k];
	dat[k*2+1]=dat[k*2+2]=rem[lazy[k]][len];
	lazy[k]=0;
}

void upd(LL k,LL lb,LL ub,LL tlb,LL tub,LL val)
{
	if(ub<tlb||tub<lb) return;
	if(tlb<=lb&&ub<=tub)
	{
		dat[k]=rem[val][ub-lb+1];
		lazy[k]=val;
		return;
	}
	pushdown(k,(ub-lb+1)/2);
	upd(k*2+1,lb,(lb+ub)/2,tlb,tub,val);
	upd(k*2+2,(lb+ub)/2+1,ub,tlb,tub,val);
	dat[k]=(dat[k*2+1]*pw[(ub-lb+1)/2]+dat[k*2+2])%MOD;
}

pii query(LL k,LL lb,LL ub,LL tlb,LL tub)
{
	if(ub<tlb||tub<lb) return mpr(0,0);
	if(tlb<=lb&&ub<=tub) return mpr(dat[k],ub-lb+1);
	pushdown(k,(ub-lb+1)/2);
	pii ret=query(k*2+1,lb,(lb+ub)/2,tlb,tub),ret2=query(k*2+2,(lb+ub)/2+1,ub,tlb,tub);
	return mpr((ret.fi*pw[ret2.se]+ret2.fi)%MOD,ret.se+ret2.se);
}

int main()
{
	cin>>n>>q;
	
	repn(i,9) repn(j,n+5) rem[i][j]=(rem[i][j-1]*10+i)%MOD;
	pw[0]=1;
	repn(i,n+5) pw[i]=pw[i-1]*10%MOD;
	
	while(n2<n) n2*=2;
	build(0,0,n2-1);
	ans=rem[1][n];
	LL x,y,z;
	rep(qn,q)
	{
		scanf("%lld%lld%lld",&x,&y,&z);
		x--;
		y--;
		ans=(ans-query(0,0,n2-1,x,y).fi*pw[n-1-y]%MOD+MOD+rem[z][y-x+1]*pw[n-1-y])%MOD;
		upd(0,0,n2-1,x,y,z);
		printf("%lld\n",ans);
	}
	return 0;
}

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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int left = a + b;
  int right = c + d;
  if(left - right > 0) cout << "Left" << endl;
  if(left - right == 0) cout << "Balanced" << endl;
  if(left - right < 0) cout << "Right" << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	a, b, k := nextInt(), nextInt(), nextInt()
	var res []int
	already := map[int]bool{}

	for i := 0; i < k && a+i <= b; i++ {
		res = append(res, a+i)
		already[a+i] = true
	}

	for i := 0; i < k && b-k+i+1 >= a; i++ {
		num := b - k + i + 1
		if !already[num] {
			res = append(res, num)
		}
	}

	for i := 0; i < len(res); i++ {
		fmt.Println(res[i])
	}
}


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

int main(){
    int n, d[101];
    cin >> n;
    
    for (int i = 0; i < n; i++) cin >> d[i];

    int num[101] = {0};
    for(int i = 0; i < n; i++) num[d[i]]++;

    int ans = 0;

    for (int i = 1; i <= 100; i++)
        if (num[i]) ++ans;

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n;
VI v;

void solve() {
  cin >> n;
  REP(_, n) {
    LL a;
    cin >> a;
    auto itr = lower_bound(ALL(v), a);
    auto target = itr - v.begin() - 1;
    if (target < 0) v.insert(itr, a);
    else if (v[target] < a) v[target] = a;
    else v.insert(itr, a);
    // REP(i, SZ(v)) cout << v[i] << " ";
    // cout << endl;
  }
  cout << SZ(v) << endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>
#include <climits>
#include <cmath>
#include <numeric>

using namespace std;
const int MAX_SIZE = 100000;
int a[MAX_SIZE + 1];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

    int N, Q;
    cin >> N;
    long long summ = 0;
    for(int i = 0; i < N; ++i) {
    	int t;
    	cin >> t;
    	a[t]++;
    	summ += t;
    }

    cin >> Q;

	for(int i = 0; i < Q; ++i) {
		int b, c;
		cin >> b >> c;
		summ += (c - b) * a[b];
		a[c] += a[b];
		a[b] = 0;
		cout << summ << "\n";
	}
	return 0;
}


Measured memory_bytes: 3516
import java.util.*;
import java.math.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){

            int n = Integer.parseInt(sc.next());
            int x = Integer.parseInt(sc.next());

            int sum = 0;
            int count = 1;

            for(int i = 0; i < n; i ++){
                sum += Integer.parseInt(sc.next());
                if(sum <= x) count++;
                else break;
            }

            System.out.println(count);

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
void warshall_floyd(Matrix< T > &g, T INF) {
  for(int k = 0; k < g.size(); k++) {
    for(int i = 0; i < g.size(); i++) {
      for(int j = 0; j < g.size(); j++) {
        if(g[i][k] == INF || g[k][j] == INF) continue;
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}

int main() {
    int h, w;
    cin >> h >> w;
    Matrix< int > g(10, vector< int >(10));
    rep (i, 10) {
        rep (j, 10) {
            cin >> g[i][j];
        }
    }
    warshall_floyd(g, INT_MAX);
    ll ans = 0;
    rep (i, h) {
        rep (j, w) {
            int p;
            cin >> p;
            if (p == -1) {
                continue;
            } else {
                ans += g[p][1];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_N 100002

using namespace std;

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

int main() {
    int N;
    cin >> N;
    
    ll sum = 0;
    ll A[MAX_N];
    A[0] = 0;
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
        sum += abs(A[i] - A[i - 1]);
    }
    A[N + 1] = 0;
    sum += abs(A[N + 1] - A[N]);
    
    for (int i = 1; i <= N; ++i) {
        if ((A[i + 1] - A[i]) * (A[i] - A[i - 1]) >= 0) {
            cout << sum << endl;
        } else {
            ll dist = min(abs(A[i + 1] - A[i]), abs(A[i] - A[i - 1]));
            cout << sum - 2 * dist << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
int main()
{
    int a[100];
    int i,j,t,n,count;
    while(~scanf("%d",&n))
    {
        count=0;
        for(i=0; i<n; i++)
            scanf("%d",&a[i]);
        for(i=0; i<n-1; i++)
        {
            for(j=0; j<n-1-i; j++)
                if(a[j]>a[j+1])
                {
                    t=a[j];
                    a[j]=a[j+1];
                    a[j+1]=t;
                    count++;
                }

        }
        for(i=0; i<n-1; i++)
            printf("%d ",a[i]);
        printf("%d\n",a[i]);
        printf("%d\n",count);
    }
    return 0;
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W;
  cin >> H >> W;
  vector<string> grid(H);
  for (int i = 0; i < H; i++)
    cin >> grid[i];

  vector<vector<int>> L(H, vector<int>(W, 0));
  vector<vector<int>> R(H, vector<int>(W, 0));
  vector<vector<int>> U(H, vector<int>(W, 0));
  vector<vector<int>> D(H, vector<int>(W, 0));

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (grid[i][j] == '#') {
        L[i][j] = 0;
        U[i][j] = 0;
      } else {
        L[i][j] = (j == 0 ? 1 : L[i][j - 1] + 1);
        U[i][j] = (i == 0 ? 1 : U[i - 1][j] + 1);
      }
    }
  }
  for (int i = H - 1; i >= 0; i--) {
    for (int j = W - 1; j >= 0; j--) {
      if (grid[i][j] == '#') {
        R[i][j] = 0;
        D[i][j] = 0;
      } else {
        R[i][j] = (j == W - 1 ? 1 : R[i][j + 1] + 1);
        D[i][j] = (i == H - 1 ? 1 : D[i + 1][j] + 1);
      }
    }
  }

  int res = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      res = max(res, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 67328
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int l[1000000];

int main() {
  int n, x;
  scanf("%d %d", &n, &x);
  ll ret = 0;
  for(int i = 0; i < n; i++) scanf("%d", &l[i]);
  if(l[0] > x) {
    ret += l[0] - x;
    l[0] = x;
  }
  for(int i = 1; i < n; i++) {
    if(l[i-1] + l[i] > x) {
      ret += l[i-1] + l[i] - x;
      l[i] = x - l[i-1];
    }
  }
  printf("%lld\n", ret);
}


Measured memory_bytes: 640
using System;

namespace ABC112_D___Partition
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver());
        }
        static int solver()
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NM[0];
            var M = NM[1];
            if (N == 1) return M;
            for (int i = 2; i <= M / 2; i++)
            {
                if (M % i == 0 && i >= N) return M / i;
            }
            return 1;
        }
    }
}


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

//dp? 深さ優先探索? よくわからんけど、再帰を使えばよい

int n, s;
int ans;

void dfs(int num, int total, int minNum){
	if(num == n){
		if(total == s) ans++;
	}
	else {
		for(int i=minNum+1; i <= 9; i++){
			dfs(num+1, total+i, i);
		}
	}
}

int main(){
	while(cin >> n >> s, n||s){
		ans = 0;
		dfs(0, 0, -1);

		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

N = int(input())
A = [ int(v) for v in input().split() ]

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()


l_list = []
l = 0
for i in range(0, N):
    l = GCD(l, A[i])
    l_list.append( l )

r_list = []
r = 0
for i in range(-1, -(N+1), -1):
    r = GCD(r, A[i])
    r_list.append( r )

n = []    
for i in range(0, N):
    if i-1 < 0:
        l = 0
    else:
        l = l_list[i-1]
    if N-i-2 < 0:
        r = 0
    else:
        r = r_list[N-i-2]
    n.append(GCD(l, r))
print(max(n))

Measured memory_bytes: 14052
#include <bits/stdc++.h>
  using namespace std;
  typedef long long int ll;
  #define mod 1000000007
  #define all(v)  v.begin(),v.end()
  #define pb push_back
  #define size(v)  (int) v.size()
  #define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
  ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
  ll inv(ll a){return power_mod(a,mod-2);}
  ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}




  int main()
  {
      fast;
      ll n,W;
      cin>>n>>W;
      ll w[n+1],v[n+1],sum=0;
      for(int i=1;i<=n;i++)
      {
      	  cin>>w[i]>>v[i];
      	  sum+=v[i];
      }
      ll dp[n+1][sum+1];
      ll ans=0;

      for(int i=0;i<=sum;i++)
      {
      	  dp[0][i]=1e18;                  // with no element no chance for any sum 
      }
      for(int i=0;i<=n;i++) dp[i][0]=0;   // minimum weight required to have cost 0 for each i;
      for(int i=1;i<=n;i++)
      {
      	  for(int j=1;j<=sum;j++)
      	  {   
      	  	  if(j>=v[i])
      	  	  dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]); 
      	  	  else
      	  	  dp[i][j]=dp[i-1][j];   // to take it or not 
      	  }
      	 
      }

      for(int i=0;i<=sum;i++) 
      {
      	 if(dp[n][i]<=W)
      	 {
      	 	ans=i;
      	 }
      }
       
      cout<<ans<<endl; 


        
  }




Measured memory_bytes: 79232
#include "bits/stdc++.h"
using namespace std;

const int N=2e5;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    double r; cin>>r;
    cout<<fixed<<setprecision(6)<<2*3.14159*r<<endl;
    return 0;
}


Measured memory_bytes: 3804
#include<iostream>
#include<vector>
using namespace std;
 
int main()
{
  int n, p;
  string s;
  long long sum = 0;
  
  cin >> n >> p;
  cin >> s;
  
  if (p == 2 || p == 5) {
    for (int i = 0; i < n; i++)
      if((s[i]-'0') % p == 0) sum += i+1;
    cout << sum << endl;
    return 0;
  }
  
  int cof = 1;
  vector<int> mods(n+1);
  for (int i = n-1; i >= 0; i--) {
      int tmp = (s[i]-'0') * cof % p;
      mods[i] = (tmp + mods[i+1]) % p;
      cof *= 10; cof %= p;
  }

  vector<int> count(p);
  for (int i = 0; i <= n; i++) {
      sum += count[mods[i]];
      count[mods[i]]++;
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 1412
N=int(input())
A=[int(input()) for i in range(N)]
B=[0]*N
for i in range(N):
    if A[i]>0:
        if A[i]%2==0:
            B[i]=2
        else:
            B[i]=1
L=[0,2,1,2,0]
dp=[[10**9]*5 for i in range(N+1)]
for k in range(5):
    dp[0][k]=0
for i in range(1,N+1):
    for k in range(5):
        for k1 in range(k+1):
            if 1<=k<=3:
                dp[i][k]=min(dp[i][k],dp[i-1][k1]+abs(L[k]-B[i-1]))
            else:
                dp[i][k]=min(dp[i][k],dp[i-1][k1]+A[i-1])
ans=10**9
#print(B)
#print(dp)
for a in range(5):
    ans=min(ans,dp[N][a])
print(ans)

Measured memory_bytes: 88272
#include<stdio.h>
int main()
{
    char a[4][4];
    int i;
    for(i=0;i<3;i++)
    {
       scanf("%s",a[i]);
    }
    printf("%c",a[0][0]);
    printf("%c",a[1][1]);
    printf("%c",a[2][2]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
N,M = map(int, input().split())
H=list(map(int, input().split()))
A=[]
B=[]
for i in range(M):
    A1,B1=map(int, input().split())
    A.append(A1)
    B.append(B1)
miti={}
for i in range(M):
    if A[i] in miti:
        miti[A[i]].append(H[B[i]-1])            
    else:
        miti[A[i]]=[]
        miti[A[i]].append(H[B[i]-1])
    if B[i] in miti:
        miti[B[i]].append(H[A[i]-1])            
    else:
        miti[B[i]]=[]
        miti[B[i]].append(H[A[i]-1])
count=0
for i in range(N):
    if i+1 in miti:
        for j in range(len(miti[i+1])):
            if H[i]<=miti[i+1][j]:
                count+=1
                break
print(N-count)

Measured memory_bytes: 33116
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
using namespace std;

struct Edge { int to, cost; };
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef pair<int, int> Pii;

int const INF = INT_MAX/2;

Graph G;

int main() {
  
  int V, E, r; cin >> V >> E >> r;
  G.resize(V);
  for(int i=0; i<E; i++) {
    int s, t, d; cin >> s >> t >> d;
    G[s].push_back((Edge){t, d});
  }

  int dist[V]; fill(dist, dist+V, INF);
  dist[r] = 0;
  priority_queue<Pii> pq;
  pq.push(Pii(0, r));
  while(!pq.empty()) {
    const Pii pii = pq.top(); pq.pop();
    const int cost = -pii.first;
    const int now = pii.second;
    if(dist[now] < cost) continue;
    for(int i=0; i<(int)G[now].size(); i++) {
      const Edge& e = G[now][i];
      if(dist[e.to] > cost + e.cost) {
        dist[e.to] = cost + e.cost;
        pq.push(Pii(-dist[e.to], e.to));
      }
    }
  }
  
  for(int i=0; i<V; i++) {
    if(dist[i] == INF) cout << "INF" << endl;
    else cout << dist[i] << endl;
  }
  
  return 0;
}

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

int main() {

  int n, x;
  int ans = 0;

  for(;;) {
    std::cin >> n >> x;
    if( n == 0 && x == 0 ) {
      break;
    }

    ans = 0;
    for(int i = 1; i <= n; ++i) {
      for(int j = i+1; j <= n; ++j) {
	for(int k = j+1; k <= n; ++k) {
	  if( i + j + k == x ) {
	    ans += 1;
	  }
	}
      }
    }
    std::cout << ans << std::endl;
  }
  
  return 0;
}

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

int main()
{
  int n;
  cin >> n;
  cout << n * (n - 1) / 2 - n / 2 << endl;
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (i + j == n + 1 - n % 2) continue;
      cout << i << " " << j << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
const int mod = 1000000007;
int r;
int main(){
  cin >> r;
  cout << pow(r,2) << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;

int main() {
	int N;
	cin >> N;
	int S = 0;
	vector<int> L(N);
	for (int i = 0; i < N; i++) {
		cin >> L[i];
		S += L[i];
	}
	int max = *max_element(L.begin(), L.end());
	if (max < S - max) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int ans[100000];

int main()
{
	string S;
	char preS = 'X';
	int lastIndex = 0;
	int Rcnt = 0, Lcnt = 0;

	cin >> S;

	rep(i, S.length()) {
		if (preS == 'R' && S[i] == 'L') {
			Rcnt--;
			ans[i - 1] = 1 + Rcnt / 2;
			ans[i] = 1 + Rcnt / 2 + Rcnt % 2;

			lastIndex = i;
			Rcnt = 0;
			preS = 'X';
		}
		else if (preS == 'L' && S[i] == 'R') {
			ans[lastIndex - 1] += Lcnt / 2 + Lcnt % 2;
			ans[lastIndex] += Lcnt / 2;
			Lcnt = 0;

			Rcnt++;
			preS = 'R';
			ans[i] = 0;
		}
		else if (S[i] == 'R') {
			Rcnt++;
			preS = 'R';
			ans[i] = 0;
		}
		else if (S[i] == 'L') {
			Lcnt++;
			preS = 'L';
			ans[i] = 0;
			if (i == S.length() - 1) {
				ans[lastIndex - 1] += Lcnt / 2 + Lcnt % 2;
				ans[lastIndex] += Lcnt / 2;
			}
		}

	}

	cout << ans[0];
	rep1(i, 1, S.length() - 1) cout << ' ' << ans[i];
	cout << endl;

	return 0;
}


Measured memory_bytes: 1024
while True:
    n = int(input())
    if n == 0: break
    personel = {}
    for _ in range(n):
        e, p, q = input().split()
        if e in personel.keys():
            personel[e] += int(p) * int(q)
        else:
            personel[e] = int(p) * int(q)
    result = []
    for key, val in personel.items():
        if val >= 1000000:
            result.append(key)
    if not result:
        print('NA')
    else:
        print('\n'.join(result))



Measured memory_bytes: 5716
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

template<typename T>
using v = vector<T>;

int main() {

	int N;
	string s;
	cin >> N >> s;
	int num = 0, minimum = 0;
	rep(i, N) {
		if (s[i] == '(') {
			num++;
		}
		else {
			num--;
		}
		minimum = min(minimum, num);
	}
	if (minimum < 0) {
		rep(i, -minimum) {
			cout << '(';
		}
	}
	cout << s;
	if (num - minimum > 0) {
		rep(i, num - minimum) {
			cout << ')';
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;

int main(){
  int a, b;
  cin >> a >> b;

  if(a*b%2) cout << "Odd" << endl;
  else cout << "Even" << endl;
  
}

Measured memory_bytes: 256
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import product, combinations, permutations
from copy import deepcopy
import sys
import numpy as np
sys.setrecursionlimit(4100000)



if __name__ == '__main__':
    X = int(input())

    if 400<=X<=599:
        print(8)
    elif 600<=X<=799:
        print(7)
    elif 800<=X<=999:
        print(6)
    elif 1000<=X<=1199:
        print(5)
    elif 1200<=X<=1399:
        print(4)
    elif 1400<=X<=1599:
        print(3)
    elif 1600<=X<=1799:
        print(2)
    else:
        print(1)

Measured memory_bytes: 27132
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int preT = 0;
    int preX = 0;
    int preY = 0;

    for(int i=0; i<N; i++){
      int postT = sc.nextInt();
      int postX = sc.nextInt();
      int postY = sc.nextInt();

      int dt = postT - preT;
      int dist = Math.abs(postX - preX) + Math.abs(postY - preY);
      if ((dt < dist) || ((dist - dt) % 2 != 0)) {
        System.out.println("No");
        return;
      }

      preT = postT;
      preX = postX;
      preY = postY;
    }

    System.out.println("Yes");
  }
}


Measured memory_bytes: 88352
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cstdint>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))
#define MOD 1000000007;

typedef long long ll;



template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<1000000007>;

int main() {
    ll n,k; cin >> n >> k;
    if(n<=k) k = n-1;
    vector<mint> fact(2000005);
    fact[0] = 1;
    for (int i = 1; i < fact.size(); ++i) {
        fact[i] = fact[i - 1] * i;
    }
    const auto comb = [&fact](int n, int r) {
        return fact[n] / fact[r] / fact[n - r];
    };
    mint ans=0;
    rep(i,k+1){
        ans = ans + comb(n,i) * comb(n-1,n-i-1);
       // cout << (comb(n,i) * comb(n-1,n-i-1)).a << endl;
    }
    cout << ans.a << endl;
    return 0;
}


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

int main() {
   ll a,b,c,d;
   cin >> a >> b >> c >> d;
   ll ans;
   ans = max(a*c,a*d);
   ans = max(ans,b*c);
   ans = max(ans,b*d);
   cout << ans << endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
using namespace std;
using ll = long long;

int main() {
  string s; cin >> s;
  int n = s.size(); n--;
  ll ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    ll now = s[0] - '0';
    for (int j = 0; j < n; ++j) {
      if ((1 & i >> j)) {
        ans += now;
        now = s[j+1] - '0';
      } else {
        now*=10;
        now += s[j+1] - '0';
      }
    }
    ans += now;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
a = []
while True:
    x = list(map(int, input().split()))
    a.append(x)
    if x[0] == 0 and x[1] == 0:
        break

isize = len(a)-1
for i in range(isize):
    jsize = a[i][0]
    for j in range(jsize):
        ksize = a[i][1]
        for k in range(ksize):
            if j == 0 or j == (jsize-1):
                print('#', end='')
            else:
                if(k == 0 or k == (ksize-1)):
                    print('#', end='')
                else:
                    print('.', end='')
        print(end='\n')
    print(end='\n')


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

int N, P, A[100009], dp[100009];

int main() {
	cin >> N >> P;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= P; i++) {
		bool used[109]; for (int j = 0; j < 109; j++) used[j] = false;
		for (int j = 1; j <= N; j++) {
			if (i >= A[j]) used[dp[i - A[j]]] = true;
		}
		for (int j = 0; j < 109; j++) {
			if (used[j] == false) { dp[i] = j; break; }
		}
	}
	if (dp[P] >= 1) cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>

using namespace std;

struct DATA{
  string str;
  int x;
  int y;
  int z;
};

DATA MakeData(string, int, int, int);
void Search(const DATA, const DATA, set<int>&);
int CaseXY_YZ(const DATA, const DATA);
int CaseXY_XZ(const DATA, const DATA);
int CaseYZ_XY(const DATA, const DATA);
int CaseYZ_XZ(const DATA, const DATA);
int CaseXZ_XY(const DATA, const DATA);
int CaseXZ_YZ(const DATA, const DATA);

int main(){
  int i, j, n, h, x, y, cube;
  string str;
  DATA _data;
  vector<DATA> data;
  set<int> overlap;

  while(1){
    cin >> n >> h;
    if(n == 0 && h == 0) break;

    for(i=0, cube = n*n*n; i<h; ++i){
      cin >> str >> x >> y;

      if(str == "xy") _data = MakeData(str, x, y, 0);
      else if(str == "yz") _data = MakeData(str, 0, x, y);
      else if(str == "xz") _data = MakeData(str, x, 0, y);

      for(j=0; j<data.size(); ++j)
	Search(data[j], _data, overlap);

      cube -= (n - overlap.size());
      data.push_back(_data);
      overlap.clear();
    }

    cout << cube << endl;
    data.clear();
  }
  return 0;
}

DATA MakeData(string str, int x, int y, int z){
  DATA data;
  data.str = str;
  data.x = x;
  data.y = y;
  data.z = z;
  return data;
}

void Search(const DATA data1, const DATA data2, set<int>& overlap){
  if(data1.str == data2.str) return;

  int x;
  if(data1.str == "xy" && data2.str == "yz") x = CaseXY_YZ(data1, data2);
  if(data1.str == "xy" && data2.str == "xz") x = CaseXY_XZ(data1, data2);
  if(data1.str == "yz" && data2.str == "xy") x = CaseYZ_XY(data1, data2);
  if(data1.str == "yz" && data2.str == "xz") x = CaseYZ_XZ(data1, data2);
  if(data1.str == "xz" && data2.str == "xy") x = CaseXZ_XY(data1, data2);
  if(data1.str == "xz" && data2.str == "yz") x = CaseXZ_YZ(data1, data2);

  if(x == 0) return;
  if(overlap.find(x) == overlap.end()) overlap.insert(x);
}

int CaseXY_YZ(const DATA data1, const DATA data2){
  if(data1.y == data2.y) return data1.x;
  else return 0;
}

int CaseXY_XZ(const DATA data1, const DATA data2){
  if(data1.x == data2.x) return data1.y;
  else return 0;
}

int CaseYZ_XY(const DATA data1, const DATA data2){
  if(data1.y == data2.y) return data1.z;
  else return 0;
}

int CaseYZ_XZ(const DATA data1, const DATA data2){
  if(data1.z == data2.z) return data1.y;
  else return 0;
}

int CaseXZ_XY(const DATA data1, const DATA data2){
  if(data1.x == data2.x) return data1.z;
  else return 0;
}

int CaseXZ_YZ(const DATA data1, const DATA data2){
  if(data1.z == data2.z) return data1.x;
  else return 0;
}

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

char str[100];
int main()
{
    scanf("%s", str);
    long long ans = 0;
    long long len = strlen(str) - 1;
    for(long long i = 0;i < (1 << len);++i)
    {
        long long t = 0;
        long long x = 0;
        for(long long j = 0;j <= len;++j)
        {
            if(1 << j & i)
            {
                x = x * 10 + str[j] - '0';
                t += x;
                x = 0;
            }
            else
                x = x * 10 + str[j] - '0';
        }
        t += x;
        ans += t;
    }
    printf("%lld\n", ans);
    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n,t;
  cin >> n >> t;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  int mi=a[0],mav=0;
  for(int i=1;i<n;i++){
    mav=max(mav,a[i]-mi);
    mi=min(mi,a[i]);
  }
  mi=a[0];
  int mic=1,mac=0;
  int ans=0;
  for(int i=1;i<n;i++){
    if(a[i]-mi==mav) mac++;
    if(a[i]==mi) mic++;
    else if(a[i]<mi){
      ans+=min(mic,mac);
      mic=1,mac=0;
      mi=a[i];
    }
  }
  ans+=min(mic,mac);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define dump(x)  cerr << #x << " = " << (x) << endl;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

 

//ここから書き始める
int main(int argc, char const *argv[])
{
	string S;
	LL K;

	cin >> S >> K;

	REP(i,K)
	{
		if(S[i] != '1')
		{
			cout << S[i] << endl;
			return 0;
		}
	}
	cout << '1' << endl;



}


Measured memory_bytes: 256
def main():
    K, A, B = map(int, input().split())
    ans = 0

    if A >= B:
        ans = K + 1
    else:

        if abs(A - B) <= 2:
            ans = K + 1

        else:
            if K >= A - 1 + 2:
                ans += B
                K -= (A + 1)

                if abs(A - B) <= 2:
                    r, m = divmod(K, A)
                    ans += r * B + m
                else:
                    r, m = divmod(K, 2)
                    ans += (B - A) * r + m
            else:
                ans = K + 1

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int func(int a, int b)
{
	if (a < b)
		return func(b, a);
	int r;
	while (r = a % b)
	{
		a = b;
		b = r;
	}
	return b;
}

int main()
{
	int a, b, k;
	cin >> k >> a >> b;
	int c = a / k;
	int l = c * k;
	int r = l + k;
	if ((a <= l && l <= b) 
		|| (a <= r && r <= b))
		printf("OK");
	else
		printf("NG");

	return 0;
}

Measured memory_bytes: 3256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]


n = int(input())

ans = 0
for i in range(1,n+1):
    ans += i
print(ans)




Measured memory_bytes: 9164
//encoding:utf-8
//#include <iostream> //c++
//#include<stack> //スタックに関して　最新のデータから捨てる
//#include<queue> //キューに関して　最古のデータから捨てる
//#include<math.h>
//#include<vector>
//#include<algorithm> //sort とかにいる
#include<bits/stdc++.h>//vector,algorithm,que
#include<time.h> //時間にかんして

#define ll long long
#define MOD 1000000007
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int> x(N);
  for(int i=0;i<N;i++){
    cin>>x[i];
  }
  int ans = 0;
  for(int i=0;i<N;i++){
    ans += min(x[i],abs(x[i]-K))*2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
def examA():
    Alpha = [chr(i) for i in range(97, 97+26)]
    S = SI(); N = len(S)
    ans = -1
    for i in range(N):
        for s in Alpha:
            cur = [s for s in S]
            for l in range(i):
                for k in range(N-1):
                    if cur[k+1]==s:
                        cur[k]=s
 #           print(cur)
            if len(Counter(cur[:N-i]))==1:
                ans = i
                break
        if ans>=0:
            break
    print(ans)
    return

def examB():
    N = I()
    A = LI()
    d = defaultdict(int)
    for a in A:
        d[a] +=1
    l = min(d); r = max(d)
    ans = "Yes"
    if l>=N:
        ans = "No"
    if r-l>1:
        ans = "No"
    if d[l]>l:
        ans = "No"
    if (r-d[l])*2+d[l]>N:
        ans = "No"
    if r==l and (N-l==1 or N//2>=l):
        ans = "Yes"
    print(ans)
    return

def examC():
    H, W, h, w = LI()
    judge = (H%h)+(W%w)
    if judge==0:
        print("No")
        return
    print("Yes")
    now = H//h+W//w
    neg = -(h*w-1)*now-1
    A = [[now]*W for _ in range(H)]
    for i in range(1,1+H//h):
        for j in range(1,1+W//w):
            A[i*h-1][j*w-1] = neg
    for v in A:
        print(" ".join(map(str,v)))
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()


Measured memory_bytes: 6644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int n;
    Int d;
    cin >> n >> d;
    int ans = 0;
    rep(i,n) {
        Int x, y;
        cin >> x >> y;
        ans += x*x + y*y <= d*d;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll gcd(ll p,ll q){for(ll t;q;)t=p%q,p=q,q=t;return p;}

#define bool int
#define T 1
#define F 0
bool prime[40000+10];
void makep(ll n){prime[0]=prime[1]=T;for(int i=2;i*i<=n;i++)if(!prime[i])for(int j=i*i;j<=n;j+=i)prime[j]=T;}

int uniquell(ll*a,ll*ans,int cnt){
	sortup(a,cnt);
	int c=0;
	ans[0]=a[0];
	rep(i,1,cnt)if(a[i]!=ans[c])ans[++c]=a[i];
	return c+1;
}

ll n;
ll f[10010];
ll p[200],cnt;

int main(){
	scanf("%lld",&n);
	for(int i=n;i>=0;i--)scanf("%lld",f+i);
	makep(40000);
	
	//多項式として0
	ll temp=llabs(f[n]);
	for(int i=0;i<n;i++)temp=llabs(gcd(temp,f[i]));
	for(int i=2;i*i<=temp;i++)if(!prime[i]){
		if(temp%i==0){
			p[cnt++]=i;
			while(temp%i==0)temp/=i;
		}
	}
	if(temp!=1)p[cnt++]=temp;

	//mod pで次数のp-1のmodでいい感じに
	for(int i=2;i<n+5;i++)if(!prime[i]&&f[0]%i==0){
		ll fp[10010]={};
		for(int d=0;d<=n;d++)fp[d%(i-1)]+=f[d];
		int ff=1;
		for(int j=0;ff&&j<i;j++)ff&=(fp[j]%i==0);
		if(ff)p[cnt++]=i;
	}

	if(cnt){
		cnt=uniquell(p,p,cnt);
		for(int i=0;i<cnt;i++)printf("%d\n",p[i]);
	}
}

Measured memory_bytes: 512
PROGRAM Colon
      IMPLICIT NONE
      integer,parameter :: p = 8
      real(p),parameter :: pip=3.1415926535897932384626433832795028
      real(p) :: pi = acos(-1d0)
      real(p) :: a,b,h,m
      real(p) :: angleA,angleB,angleSub
      real(p) :: xa,ya,xb,yb
      
    !  print*,pip
    !  print*,pi
      
      read*,a,b,h,m
    !  h = h + m/60d0
      
    !  angleA = h/12d0*2*pi
    !  angleB = m/60d0*2*pi
      
      angleA = (h+m/60)/12*2*pi
      angleB = m/60d0*2*pi
      
      
      xa = a*sin(angleA)
      ya = a*cos(angleA)
      xb = b*sin(angleB)
      yb = b*cos(angleB)
      
      print*, sqrt( (xa-xb)**2 + (ya-yb)**2 )
      
      
      
      END PROGRAM

Measured memory_bytes: 3252
#include<stdio.h>
int main()
{
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    int temp;
    if(A>B)
    {
        temp = A;
        A = B;
        B = temp;
    }
    if(C>=A && C<=B)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int ans = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] == a[i - 1]) {
      a[i] = -1;
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 640
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> 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().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let mut aa = (1..n + 1)
        .map(|i| read::<i64>() - i as i64)
        .collect::<Vec<_>>();
    aa.sort();
    println!("{}", calc(&aa, aa[aa.len() / 2]));

    fn calc(aa: &Vec<i64>, b: i64) -> i64 {
        let mut ans = 0;
        for i in 0..aa.len() {
            ans += (aa[i] - b).abs();
        }
        ans
    }
}


Measured memory_bytes: 6396
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int V, E;
		
		
		String line;
		try{
			line = br.readLine();
			String[] data = line.split(" ");
			V = Integer.parseInt(data[0]);
			E = Integer.parseInt(data[1]);
			
			ArrayList<ArrayList<PairValue>> graph = new ArrayList<ArrayList<PairValue>>();
			
			
			for(int i=0; i<V; i++){
				graph.add(new ArrayList<PairValue>());
			}
			
			for(int i=0; i<E; i++){
				data = br.readLine().split(" ");
				int s = Integer.valueOf(data[0]);
				int t = Integer.valueOf(data[1]);
				int w = Integer.valueOf(data[2]);
				graph.get(s).add(new PairValue(t, w));
				graph.get(t).add(new PairValue(s,w));
				
				
			}
			
			int mst = solve(V,E,graph);
			System.out.println(mst);
			
		}catch(Exception ex){
			ex.printStackTrace();
		}  
	}
	
	private static int solve(int V, int E, ArrayList<ArrayList<PairValue>> graph){
		// create s set mstSet that keeps track of vertices already include in MST
		boolean[] mstSet = new boolean[V];
		
		
		// assign key values to all vertices in the graph, initial all key values as INFINITE
		int[] key = new int[V];
		for(int i=0; i<V; i++){
			key[i] = Integer.MAX_VALUE;
			mstSet[i] = false;
		}
		
		// assign 0 to the first vertex so that it will be picked first
		key[0] = 0;
		
		// while mstSet does not include all vertices
		/**
		 * 1. Pick a vertex u which is not there in the mstSet and has min key value
		 * 2. include u to the mstSet
		 * 3. update key values adjacent vertices of u
		 * **/
		
		int count = 0;
		int sum = 0;
		while(count < V){
			PairValue pair = minKey(key, mstSet);
			int u = pair.index;
			//System.out.println("u: "+u);
			sum += pair.weight;
			mstSet[u] = true;
			
			
			// get all adj nodes
			ArrayList<PairValue> neighbours = graph.get(u);
			for(int v=0; v<neighbours.size(); v++){
				int neighbourVertex = neighbours.get(v).index;
				int w = neighbours.get(v).weight;
				if(!mstSet[neighbourVertex] && key[neighbourVertex] > w){
					key[neighbourVertex] = w;
				}
			}
			
			
			count ++;
		}
		
				
		return sum;
	}
	
	// return min key index;
	private static PairValue minKey(int[] key, boolean[] mstSet){
		int min = Integer.MAX_VALUE;
		int index = -1;
		
		for(int i=0; i<key.length; i++){
			if(min > key[i] && !mstSet[i]){
				min = key[i];
				index = i;
			}
		}
		return new PairValue(index, min);
	}
}



class PairValue{
	int index, weight;
	public PairValue(int a, int b){
		index = a;
		weight = b;
	}
}

Measured memory_bytes: 68324