akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define LL long long
#define db double

using namespace std;
const int N=2e5+10,mod=1e9+7,inf=1<<30;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}
int fpow(int a,int b){int an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;}return an;}
int ginv(int a){return fpow(a,mod-2);}
vector<int> e[N];
int n,a[N],v1[N],ti,cr[N],st[N],tp,f[N],g[N],b[N],h[N],fac[N],iac[N];
int C(int a,int b){return b<0||a<b?0:1ll*fac[a]*iac[b]%mod*iac[a-b]%mod;}
bool mk[N];
void dfs(int x)
{
    int nn=e[x].size();
    for(int i=0;i<nn;++i)
    {
	int y=e[x][i];
	dfs(y),f[x]=f[x]?-inf:f[y]+1;
    }
}

int main()
{
    fac[0]=1;
    for(int i=1;i<=N-5;++i) fac[i]=1ll*fac[i-1]*i%mod;
    iac[N-5]=ginv(fac[N-5]);
    for(int i=N-5;i;--i) iac[i-1]=1ll*iac[i]*i%mod;
    n=rd();
    for(int i=1;i<=n;++i) a[i]=rd();
    for(int i=1;i<=n;++i)
	if(!v1[i])
	{
	    ++ti;
	    int x=i;
	    tp=0;
	    while(!v1[x]) v1[x]=ti,st[++tp]=x,x=a[x];
	    if(cr[x]) {mk[x]=1;continue;}
	    if(v1[x]<ti) continue;
	    int cn=0;
	    for(int j=tp;;--j)
	    {
		++cn;
		if(st[j]==x) break;
	    }
	    for(int j=tp;;--j)
	    {
		cr[st[j]]=cn;
		if(st[j]==x) break;
	    }
	    mk[x]=tp>cn;
	}
    ++ti;
    for(int i=1;i<=n;++i)
	if(cr[i]&&v1[i]<ti)
	{
	    int x=i;
	    for(int j=1;j<=cr[i]*2;++j) v1[x]=ti,mk[a[x]]|=mk[x],x=a[x];
	}
    for(int i=1;i<=n;++i)
	if(!cr[i]) e[a[i]].push_back(i);
    int ans=1;
    for(int i=1;i<=n;++i)
	if(cr[i])
	{
	    if(mk[i])
	    {
		int x=i;
		tp=0;
		for(int j=1;j<=cr[i];++j) st[++tp]=x,x=a[x];
		for(int j=1;j<=cr[i];++j) dfs(st[j]);
		for(int j=1;j<=cr[i];++j)
		    if(f[st[j]]<0||f[st[j]]>cr[i]){puts("0");return 0;}
		for(int j=1;j<=cr[i];++j) g[j]=g[j-1]+(bool)f[st[j]];
		for(int j=1;j<=cr[i];++j) g[j+cr[i]]=g[j-1+cr[i]]+(bool)f[st[j]];
		for(int j=cr[i]+1;j<=cr[i]+cr[i];++j)
		{
		    int y=st[j-cr[i]];
		    if(!f[y]) continue;
		    if(cr[i]>1&&g[j-1]-g[j-f[y]]){puts("0");return 0;}
		    ans=1ll*ans*(2-(bool)(g[j-1]-g[j-f[y]-1]))%mod;
		}
	    }
	    else ++b[cr[i]];
	    int x=i,lm=cr[i];
	    for(int j=1;j<=lm;++j) cr[x]=0,x=a[x];
	}
    h[0]=h[1]=1;
    for(int i=2;i<=n;++i) h[i]=1ll*h[i-1]*(2*i-1)%mod;
    for(int i=1;i<=n;++i)
    {
	if(!b[i]) continue;
	int sm=0,dx=1+(i>1&&(i&1));
	for(int j=0;j+j<=b[i];++j)
	    ad(sm,1ll*C(b[i],j+j)*h[j]%mod*fpow(i,j)%mod*fpow(dx,b[i]-j-j)%mod);
	ans=1ll*ans*sm%mod;
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

int main ()
{
    int r,d,x;
    cin >> r >> d >> x;
    int arr[11];
    arr[0]=x;
    for(int i = 1 ; i < 11 ; i++)
    {
        arr[i]=arr[i-1]*r-d;
        cout << arr[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())

l= list(map(int,input().split()))
l.sort()
con=0

if n<=2:
    print('0')
else:
    for i in range(n-2):
        for e in range(1,n-1):
            for o in range(2,n):
                if o<=e or o<=i or e<=i or l[i]==l[e] or l[e]==l[o] or l[i]==l[o]:
                    con+=0
 
                elif l[i]+l[e]>l[o] and l[e]+l[o]>l[i] and l[o]+l[i]>l[e]:
                    con+=1
                                         
    print(con)

Measured memory_bytes: 9216
import sys
from collections import deque


class MaxFlow:
    class Edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, node_size, inf):
        self._node = node_size
        self._inf = inf
        self._level = [-1]*self._node
        self._iter = [0]*self._node
        self._graph = [[] for _ in range(self._node)]

    def add_edge(self, from_, to, cap):
        self._graph[from_].append(self.Edge(to, cap, len(self._graph[to])))
        self._graph[to].append(self.Edge(from_, 0, len(self._graph[from_])-1))

    def bfs(self, start):
        self._level = [-1]*self._node
        que = deque()
        self._level[start] = 0
        que.append(start)
        while que:
            cur_vertex = que.popleft()
            for e in self._graph[cur_vertex]:
                if self._level[e.to] < 0 < e.cap:
                    self._level[e.to] = self._level[cur_vertex] + 1
                    que.append(e.to)

    def dfs(self, cur_vertex, end_vertex, flow):
        if cur_vertex == end_vertex:
            return flow
        for e in self._graph[cur_vertex][self._iter[cur_vertex]:len(self._graph[cur_vertex])]:
            if e.cap > 0 and self._level[cur_vertex] < self._level[e.to]:
                flowed = self.dfs(e.to, end_vertex, min(flow, e.cap))
                if flowed > 0:
                    e.cap -= flowed
                    self._graph[e.to][e.rev].cap += flowed
                    return flowed
        return 0

    def solve(self, source, sink):
        flow = 0
        while True:
            self.bfs(source)
            if self._level[sink] < 0:
                return flow
            self._iter = [0]*self._node
            while True:
                f = self.dfs(source, sink, self._inf)
                if f == 0:
                    break
                flow += f


def main():
    n, m = map(int, sys.stdin.readline().split())
    mf = MaxFlow(n, 10 ** 10)
    for _ in range(m):
        u, v, c = map(int, sys.stdin.readline().split())
        mf.add_edge(u, v, c)
    print(mf.solve(0, n - 1))

if __name__ == '__main__':
    main()



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

#define lli long long int
#define endl "\n"
#define debug(n) cout<<n<<endl
#define debug2(a, b) cout<<a<<" "<<b<<endl;
#define forn(i, in, fin) for(int i = in; i<fin; i++)
#define all(v) v.begin(), v.end()
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

const lli MOD = 1e9 + 7;

vector< string > matrix;
lli n, m;
vector< vector<lli> > dp;

lli f(lli i, lli j)
{
    if(i>=n || j>=m) return 0;
    if(i==n-1 && j == m-1) return 1;
    if(matrix[i][j] == '#' ) return 0;
    if(dp[i][j] != -1) return dp[i][j];

    return dp[i][j] = (f(i+1, j) + f(i, j+1))%MOD;
}


int main()
{
    fastIO();
    cin>>n>>m;
    matrix.resize(n);
    dp.assign(n, vector<lli> (m,-1));
    forn(i,0,n)
    {
        cin>>matrix[i];
    }
    cout<<f(0,0)<<endl;
    return 0;
}

Measured memory_bytes: 9216
from collections import defaultdict
d = defaultdict(list)
for i in range(3):
    a,b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)

a = sorted([len(d[i]) for i in range(1,5)])
if a == [1,1,2,2]:
    print("YES")
else:print("NO")
# print(a)

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

int main(){
  const int INF=1e9;
  typedef pair<int,int> P;
  int N,M;
  int out=0;
  cin>>N>>M;
  int l,r,d;
  std::vector<queue<P>> que(N);
  for(int i=0;i<M;i++){
    cin>>l>>r>>d;
    l--;r--;
    que[l].push(P(r,d));
    que[r].push(P(l,d*(-1)));
  }
  queue<int> ank;
  int i;
  int c=0;
  std::vector<int> uu(N,INF);
  while(out==0){
    for(i=0;que[i].size()==0;){
      if(i<N-1)i++;
      else {
        c=1;
        break;
      }
    }
    if(c)break;
    uu[i]=0;
    ank.push(i);
    while(ank.size()){
      int k=ank.front();
      ank.pop();
      while(que[k].size()){
        P w=que[k].front();
        que[k].pop();
        if(uu[w.first]==INF){
          uu[w.first]=uu[k]+w.second;
          ank.push(w.first);
        }
        else{
          if(uu[w.first]!=uu[k]+w.second)out++;
        }
      }
    }
  }
  if(out)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 68608
#from collections import deque
from bisect import bisect_left
N=int(input())
A=[int(i) for i in input().split()]
A=[0]+A
for i in range(N):
    A[i+1]+=A[i]

num=10**14
for i in range(2,N-1):
    ans=[]
    x=(A[i]+A[0])/2
    j=bisect_left(A,x)
    #print(j,x)
    if A[j]-x>x-A[j-1]:
        j-=1
    ans+=[A[j]-A[0],A[i]-A[j]]
    y=(A[N]+A[i])/2
    k=bisect_left(A,y)
    #print(k,y)
    if A[k]-y>y-A[k-1]:
        k-=1
    ans+=[A[N]-A[k],A[k]-A[i]]
    #print(ans)
    t=max(ans)-min(ans)
    num=min(num,t)
print(num)

Measured memory_bytes: 25072
#include<stdio.h>
double a[4],b[4];
main(){
  int temp;
  while(scanf("%lf %lf %lf %lf",&a[0],&a[1],&a[2],&a[3])!=EOF){
    scanf("%lf %lf %lf %lf",&b[0],&b[1],&b[2],&b[3]);
    if(a[0]>=a[2]){
      temp=a[0];
      a[0]=a[2];
      a[2]=temp;
    }
    if(a[1]>=a[3]){
      temp=a[1];
      a[1]=a[3];
      a[3]=temp;
    }
    if(b[0]>=b[2]){
      temp=b[0];
      b[0]=b[2];
      b[2]=temp;
    }
    if(b[1]>=b[3]){
      temp=b[1];
      b[1]=b[3];
      b[3]=temp;
    }
    if((a[0]<=b[0] && b[0]<=a[2])||(b[0]<=a[0] && a[2]<=b[2])||(a[0]<=b[2] && b[2]<=a[2])){
      if((a[1]<=b[1] && b[1]<=a[3])||(b[1]<=a[1] && a[3]<=b[3])||(a[1]<=b[3] && b[3]<=a[3])){
	puts("YES");
	continue;
      }
    }
    puts("NO");
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,sa;
	double D = 0;
	cin>>n;
	int x[n];
	int y[n];
	for(int i = 0;i<n;i++){
		cin>>x[i];
	}
	for(int i = 0;i<n;i++){
		cin>>y[i];
	}
	for(int i = 0;i<n;i++){
		if(x[i]>y[i])sa = x[i] - y[i];
		else  sa = y[i] -x[i];
		D += sa;
	}
	printf("%.4f\n",D);
	sa = 0;
	D = 0;
	for(int i = 0;i<n;i++){
		if(x[i]>y[i])sa = x[i] - y[i];
		else  sa = y[i] -x[i];
		D += sa*sa;
	}
	printf("%.10f\n",sqrt(D));
	D = 0;
	sa = 0;
	for(int i = 0;i<n;i++){
		if(x[i]>y[i])sa = x[i] - y[i];
		else  sa = y[i] -x[i];
		D += sa*sa*sa;
	}
	printf("%.10f\n",cbrt(D));
	D = 0;
	sa = 0;
	float max = 0;
	for(int i = 0;i<n;i++){
		if(x[i]>y[i])sa = x[i] - y[i];
		else  sa = y[i] -x[i];
		if(max<sa)max = sa;
	}
	printf("%.4f",max);
	return 0;
}


Measured memory_bytes: 3348
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y;
    cin >> x >> y;
    ll nw = x;
    int ans = 0;
    while(nw <= y){
        nw *= 2;
        ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	Scanner scan = new Scanner(System.in);
	
	public static void main(String args[]){
		Main app = new Main();
		int n = app.scan.nextInt();
		for(int i=0;i<n;i++){
			System.out.println(app.baseball());
		}
	}
	
	public int baseball(){
		int point = 0;
		int[] runner = new int[3];
		int out = 0;
		
		while(true){
			String str = scan.next();
			if(str.equals("HIT")){
				if(runner[2]==1)
					point++;
				runner[2] = runner[1];
				runner[1] = runner[0];
				runner[0] = 1;
			}else if(str.equals("OUT")){
				out++;
			}else if(str.equals("HOMERUN")){
				point++;
				for(int i=0;i<3;i++){
					if(runner[i]==1)
						point++;
					runner[i] = 0;
				}
			}
			if(out==3)
				break;
		}
		
		return point;
	}
}

Measured memory_bytes: 17200
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod=1e9+7;

const int N=1<<17;
ll st[2*N];

void add(int i, ll v){
	for (i+=N;i;i/=2) {
		st[i]+=v;
		st[i]%=mod;
	}
}

ll sum(int a, int b){
	a+=N;
	b+=N;
	ll s=0;
	while (a<=b){
		if (a%2) s+=st[a++];
		if (!(b%2)) s+=st[b--];
		a/=2;
		b/=2;
		s%=mod;
	}
	return s;
}

ll s[101010];
ll vv[101010];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	ll a,b;
	cin>>n>>a>>b;
	if (a>b) swap(a, b);
	for (int i=1;i<=n;i++){
		cin>>s[i];
		if (i>=3&&s[i]-s[i-2]<a){
			cout<<0<<endl;
			return 0;
		}
	}
	int lp=0;
	int hp=0;
	add(0, 1);
	for (int i=1;i<=n;i++){
		if (i-2>=1&&(s[i-1]-s[i-2])<a){
			lp=i-2;
		}
		while (s[i]-s[hp+1]>=b){
			hp++;
		}
		ll tv=sum(lp, hp);
		add(i, tv);
	}
	if (n-1>=1&&s[n]-s[n-1]<a){
		lp=n-1;
	}
	cout<<sum(lp, n)<<endl;
}

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

int const MAX = 1005;
long long x[MAX], y[MAX], z[MAX];

long long f(long long a[], long long b[], long long c[], int n, int m, int i, int j, int k) {
	long long t[MAX];
	for (int l = 1; l <= n; l++) {
		t[l] = i * a[l] + j * b[l] + k * c[l];
	}
	sort(t + 1, t + n + 1);
	long long ans = 0;
	for (int l = 1; l <= m; l++) {
		ans += t[n + 1 - l];
	}
	return ans;
}

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> y[i] >> z[i];
	}
	long long ans = 0;
	for (int i = -1; i <= 1; i+=2) {
		for (int j = -1; j <= 1; j+=2) {
			for (int k = -1; k <= 1; k+=2) {
				ans = max(ans, f(x, y, z, n, m, i, j, k));
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#define MAX 3000
using namespace std;

int C[6]={1,5,10,50,100,500};
int T[MAX+1];
void douteki();

int main(){
  int n;
 

  while(1){
    cin >> n;
    if(n == 0)break; 
    douteki();
    cout << T[1000-n] << endl;
  }



}

void douteki(){
  for(int j=0;j<=MAX;j++)T[j]=10000;
  T[0]=0;
  for(int i=0;i<6;i++){
    for(int j=C[i];j<=MAX;j++){
      T[j]=min(T[j],T[j-C[i]]+1);
    }
  }

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
ll gcd(ll a, ll b){
    if(b == 0)return a;
    return gcd(b,a%b);
}
int main(){ 
  ll a, b;
  cin >> a >> b;
  ll d = gcd(a, b);
  cout << (a*b) / d << endl;
  return 0;
} 

Measured memory_bytes: 256
H, W = map(int, input().split())
mas = []
cut_h = []
cut_w = []

for i in range(H):
	mas.append(list(map(str, input())))
	
for i in range(H):
	flg = 1
	for j in range(W):
		if mas[i][j] == "#":
			flg = 0
			break
	if flg:
		cut_h.append(i)
		
for i in range(W):
	flg = 1
	for j in range(H):
		if mas[j][i] == "#":
			flg = 0
			break
	if flg:
		cut_w.append(i)
		
for i in range(H):
	flg = 1
	for j in range(W):
		if i in cut_h:
			flg = 0
			continue
		if j in cut_w: continue
		print(mas[i][j], end = "")
	if flg:
		print()

Measured memory_bytes: 44396
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
V = lr()
C = lr()
total = 0
for i in range(N):
    result = V[i] - C[i]
    if result > 0:
        total += result

print(total)


Measured memory_bytes: 3060
#include <stdio.h>

static const int MAXNUMOFINPUT = 36;

typedef struct {
    char suit;
    int value;
} CARD;

int bubbleSort(CARD C[], int N);
int selectionSort(CARD C[], int N);
int isStable(CARD C1[], CARD C2[], int N);
int printArray(CARD C[], int N);

int main()
{
    int i;
    int N;
    CARD C1[MAXNUMOFINPUT];
    CARD C2[MAXNUMOFINPUT];

    scanf("%d\n", &N);
    for (i = 0; i < N; i++)
    {
        scanf("%c%d", &C1[i].suit, &C1[i].value);
        getchar();
        C2[i] = C1[i];
    }

    bubbleSort(C1, N);
    selectionSort(C2, N);
    printArray(C1, N);
    printf("Stable\n");
    printArray(C2, N);
    printf("%s\n", isStable(C1, C2, N) ? "Stable" : "Not stable");

    return 0;
}

int bubbleSort(CARD C[], int N)
{
    int i, j;
    CARD tmp;

    for (i = 0; i < N; i++)
    {
        for (j = N - 1; j > i; j--)
        {
            if(C[j].value < C[j - 1].value)
            {
                tmp = C[j];
                C[j] = C[j - 1];
                C[j - 1] = tmp;
            }
        }
    }

    return 0;
}

int selectionSort(CARD C[], int N)
{
    int i, j;
    int minj;
    CARD tmp;

    for (i = 0; i < N; i++)
    {
        minj = i;

        for (j = i; j < N; j++)
        {
            if(C[j].value < C[minj].value)
            {
                minj = j;
            }
        }

        tmp = C[i];
        C[i] = C[minj];
        C[minj] = tmp;
    }

    return 0;
}

int isStable(CARD C1[], CARD C2[], int N)
{
    int i;

    for (i = 0; i < N; i++)
    {
        if(C1[i].suit != C2[i].suit)
        {
            return 0;
        }
    }

    return 1;
}

int printArray(CARD C[], int N)
{
    int i;

    for (i = 0; i < N; i++)
    {
        printf("%c%d", C[i].suit, C[i].value);
        if (i < N - 1)
        {
            printf(" ");
        }
    }

    printf("\n");

    return 0;
}



Measured memory_bytes: 2112
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    vi v;
    for(int i=100; i>0; i--){
        if(a % i == 0 && b % i ==0){
            v.pb(i);
        }
    }
    int ans = v.at(k-1);
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int n, W;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> W;
    vii wv[4];
    ll ans = 0, tmp = 0;
    rep(i, 0, n) {
      int w, v;
      cin >> w >> v;
      if (i == 0) tmp = w;
      wv[w - tmp].pb(v);
    }
    rep(i, 0, 4) {
      sort(ALL(wv[i]), greater<int>());
      wv[i].insert(wv[i].begin(), 0); 
      rep(j, 0, wv[i].size()) wv[i][j+1] += wv[i][j];
    }
  
    rep(i, 0, wv[0].size()) rep(j, 0, wv[1].size()) rep(k, 0, wv[2].size()) rep(l, 0, wv[3].size()) {
      ll w = 0, v = 0;
      w += i * tmp;
      v += wv[0][i];

      w += j * (tmp + 1);
      v += wv[1][j];

      w += k * (tmp + 2);
      v += wv[2][k];

      w += l * (tmp + 3);
      v += wv[3][l];

      if (w <= W) ans = max(ans, v);
    }
    cout << ans << endl;
    return 0;
}



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

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

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
        A[i]--;
        A[i] %= K;
    }

    vector<int> sum(N+1);
    rep(i, N) sum[i+1] = (sum[i] + A[i]) % K;

    map<int, int> cnt;
    deque<int> dq;
    ll ans = 0;
    rep(i, N+1) {
        ans += cnt[sum[i]];
        cnt[sum[i]]++;
        dq.push_back(sum[i]);
        while (K <= dq.size()) {
            cnt[dq.front()]--;
            dq.pop_front();
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 12032
#include<iostream>
#include<ctype.h>
#include<map>
#include<string>

using namespace std;

int main() {
	map<char, string> m;
	cin >> m['a'] >> m['b'] >> m['c'];
	
	char now = 'a';
	while (true) {
		if (!m[now].size()) {
			cout << (char)toupper(now) << endl;
			return 0;
		}
		char tmp = m[now][0];
		m[now].erase(m[now].begin());
		now = tmp;
	}

}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n,m;

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
	n=read();m=read();
	int ans=0;
	rep(i,1,n)
	{
		rep(j,10,m)
		{
			int x=j%10,y=j/10;
			if ((x>=2) && (y>=2) && (x*y==i)) ans++;
		}
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
// AOJ 2044: Lying about Your Age
// 2017.11.04 bal4u@uu

#include <stdio.h>
#include <string.h>
#define TM 0
#if TM
#include <time.h>
#endif

#define INF 11001001
int tbl[201][17];
char buf[20], *bp;

int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int cmp(int *a, int *b) { return *b - *a; }

int main()
{
	int a, b, c, i, j, t, ans;

#if TM
	clock_t start, end;
	start = clock();
#endif
	for (j = 1; j <= 200; j++) for (i = 2; i <= 16; i++) {
		for (t = j, a = 0, c = 1; t; t /= i) {
			if ((b = t % i) > 9) { a = INF; break; }
			a += c*b, c *= 10;
		}
		tbl[j][i] = a;
	}

	while (scanf("%d%d%d", &a, &b, &c) && a >= 0) {
		ans = INF;
		for (i = 2; i <= 16; i++) if (tbl[a][i] == b) { ans = b; break; }
		if (ans == b) for (j = a+1; j <= c; j++) {
			for (t = INF, i = 2; i <= 16; i++) if (tbl[j][i] >= ans) {
				if (tbl[j][i] < t) t = tbl[j][i];
			}
			if (t == INF) break;
			ans = t;
		}
		if (ans < INF) printf("%d\n", ans);
		else puts("-1");
	}
#if TM
	end = clock();
	printf("time %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 1700
#include<bits/stdc++.h>
using namespace std;
int n,m,u[5010],v[5010],w[5010],p,vis[5010],c[5010];
long long d[5010];
void bfs() {
	queue<int> q;
	q.push(n);vis[n]=1;
	while(!q.empty()) {
		int s=q.front();q.pop();
		for(int i=1;i<=m;++i) if(v[i]==s&&!vis[u[i]]) {
			q.push(u[i]);
			vis[u[i]]=1;
		}
	}
}
int main()
{
	scanf("%d%d%d",&n,&m,&p);
	for(int i=1;i<=m;++i) scanf("%d%d%d",&u[i],&v[i],&w[i]),w[i]=-(w[i]-p);
	bfs();
	for(int i=1;i<=n;++i) d[i]=1e15;
	d[1]=0;c[1]=1;
	for(int i=1;i<n;++i) {
		bool f=false;
		for(int j=1;j<=m;++j)
			if(d[u[j]]+w[j]<d[v[j]]&&c[u[j]]) {
				d[v[j]]=d[u[j]]+w[j];c[v[j]]=1;
				f=true;
			}
		if(!f) break;
//		cout<<1;
	}
	for(int j=1;j<=m;++j)
		if(d[u[j]]+w[j]<d[v[j]]&&c[u[j]]&&vis[u[j]]) {
			printf("-1");
			return 0;
		}
//	if(d[n]==1e10) {
//		printf("-1");
//		return 0;
//	}
//	cout<<1;
	if(d[n]>0) d[n]=0;
	printf("%lld",-d[n]);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define INF 10000000
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
    int n;
    cin>>n;
    int a[n];
    double ans=0;
    rep(i,n) cin>>a[i];
    rep(i,n) ans+=(double)1/a[i];
    printf("%.12lf\n",(double)1/ans);
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

int largestRectangleInHistogram(const vector<int> &h) {
  int n = h.size();
  deque<int> s; // stack
  vector<int> l(n), r(n);
  rep(i, n) {
    while (s.size() && h[s.back()] >= h[i]) s.pop_back();
    l[i] = s.size() ? (s.back() + 1) : 0;
    s.emplace_back(i);
  }
  s.clear();
  for (int i = n - 1; i >= 0; i--) {
    while (s.size() && h[s.back()] >= h[i]) s.pop_back();
    r[i] = s.size() ? s.back() : n;
    s.emplace_back(i);
  }
  int maxi = 0;
  rep(i, n) cmax(maxi, h[i] * (r[i] - l[i]));
  return maxi;
}

// 0: available, 1: unavailable, return: size of square
int largestRectangle(const vector<vector<int>> &v) {
  int h = v.size(), w = v[0].size();
  vector<vector<int>> dp(h, vector<int>(w));
  rep(j, w) {
    dp[0][j] = v[0][j] == 0;
    loop(i, 1, h) dp[i][j] = v[i][j] == 0 ? dp[i - 1][j] + 1 : 0;
  }
  int maxi = 0;
  rep(i, h) cmax(maxi, largestRectangleInHistogram(dp[i]));
  return maxi;
}

main {
  int h, w;
  cin >> h >> w;
  auto v = vectors(h, w, 0LL);
  cin >> v;
  cout << largestRectangle(v) << endl;
}



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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if (U == S)
    cout << A - 1 << ' ' << B << endl;
  else
    cout << A << ' ' << B - 1 << endl;
}

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

#define ll long long int
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,a,b) for(ll i=a-1;i>=b;i--)
#define vi vector<ll>
#define pii pair<int,int>
#define vii vector< pair<int,int> >
#define pb push_back
#define inf 1000000000000
#define hell 1000000007

using namespace std;

void solve()
{
    ll a,b;
    cin>>a>>b;
    cout<<max((ll)0,a-2*b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}


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


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

if(x==3 || x==5 || x==7)
{
	 cout << "YES" << endl;
}
else
{
	cout << "NO" << endl;
}

	return 0;
}











Measured memory_bytes: 3464
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int GCD(int a,int b)
{
  return b?GCD(b,a%b):a;
}
bool have[1000100];
int x[1000100];
signed main()
{
//	cout<<LCM(1000000,999999)<<endl;
  int N;
  cin>>N;
  for(int i=0;i<N;i++)
    cin>>x[i];
  int GGCCDD=x[0];
  for(int i=0;i<N;i++)
    GGCCDD=GCD(GGCCDD,x[i]);
  if(GGCCDD>1)
    puts("not coprime");
  else
  {
    bool pcop=true;
    int not1=0;
    for(int i=0;i<N;i++)
    	if(x[i]==1)
    		not1++;
	memset(have,false,sizeof(have));
    for(int i=N-1;i>=0;i--)
    {
    	int tmp=x[i];
    	//int mx=1;
    	for(int j=2;j<=sqrt(x[i]);j++)
    		if(tmp%j==0)
    		{
    			if(have[j])
    			{
    			//	cout<<i<<" "<<j<<endl;
    				pcop=false;
    				break;
				}
				have[j]=true;
				while(tmp%j==0)
                  tmp/=j;
				//mx=max(mx,j);
			}
		if(tmp>1)
		{
			if(have[tmp])
			{
			//	cout<<i<<" "<<tmp<<endl;
				pcop=false;
				break;
			}
			have[tmp]=true;
		}
	}
    if(pcop)
      puts("pairwise coprime");
    else	puts("setwise coprime");
  }
  return 0;
}


Measured memory_bytes: 12328
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<queue>
#include<vector>
#include<tuple>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
bool comparator(P a, P b) {
	return a.first / a.second < b.first / b.second;
}

int main() {
	int n, x, t;
	cin >> n >> x >> t;
	ll ans = (n/x)*t;
	if (n % x != 0) {
		ans += t;
	}
	cout << ans << endl;
}


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

const int MAX_N = 500;
const int inf = 1LL << 60;

int a[MAX_N];
int dp[MAX_N][MAX_N];

signed main(void){ 
  
  int N; cin >> N;
  
  for(int i = 0; i < N; i++){ cin >> a[i];}
 
  for(int i = 1; i < N; i++){ //幅を先に決める
    
    for(int j = 0; j < N; j++){ //左端を決める
      
      if( i+j >= N ){ continue;}  //今[j,j+i]を考えている
      
      int res = inf;
      int sum = 0;

      for(int k = j; k < j+i; k++){ 
        // [j,k]と[k+1,j+i]に分けて考える
        sum += a[k];
        res = min(res,dp[j][k]+dp[k+1][j+i]);
      }
      
      sum += a[i+j];
      
      dp[j][j+i] = res+sum;
      
    }
  }
  
  cout << dp[0][N-1] << endl;
  
  return 0;
} 

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n; ll k; cin >> n >> k;
    ll kk = k; int mx = 0;
    while(kk){
        kk /= 2;
        mx++;
    }
    
    vll a(n);
    vll b(mx, 0);
    rep(i, n){
        cin >> a[i];
        ll aa = a[i];
        rep(j, mx){
            if(aa & 1) b[j]++;
            aa /= 2;
        }
    }
    
    ll x = 0;
    rep3rev(j, mx - 1, 0){
        // cout << b[j] << " ";
        if(b[j] <= n/2) {
            if(x + (1LL << j) <= k) x += (1LL << j);
        }
    }
    // cout << endl << x << endl;
    
    ll tot = 0;
    rep(i, n) tot += (x ^ a[i]);
    cout << tot << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3936
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

int f(int x) {
  return (x > 60) + (x > 80) + (x > 100) + (x > 120) + (x > 140) + (x > 160);
}

int g(int x) {
  return (x > 2) + (x > 5) + (x > 10) + (x > 15) + (x > 20) + (x > 25);
}

void solve() {
  int n;
  while (cin >> n, n) {
    int c = 0;
    rep(i, n) {
      int x, y, h, w;
      cin >> x >> y >> h >> w;
      int r = max(f(x + y + h), g(w));
      if (r <= 5) c += r * 200 + 600;
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 3000
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb(a) push_back(a)
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;



using namespace std;
int n;
int a2;
int a4;
int a1;


int main(){
  cin >> n;
  REP(i,n){
    int k;
    cin >> k;
    if(k%4==0) a4++;
    else if(k%2==0) a2++;
    else a1 ++;
  }
  if(a2==0 && a1==a4+1) cout << "Yes" << endl;
  else if(a1>a4) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import math
th = math.pi/3

def koch(p2, n, points):
	p1 = points[-1]
	x, y = p2[0]-p1[0], p2[1]-p1[1]
	s = [p1[0]+x/3, p1[1]+y/3]
	t = [p1[0]+x*2/3, p1[1]+y*2/3]
	s0t = [t[0]-s[0], t[1]-s[1]]
	s0u = [math.cos(th)*s0t[0] - math.sin(th)*s0t[1],
	       math.sin(th)*s0t[0] + math.cos(th)*s0t[1]]
	u = [s[0]+s0u[0], s[1]+s0u[1]]
	
	if n == 0:
		points.append(p2)
	else:
		koch(s, n-1, points)
		koch(u, n-1, points)
		koch(t, n-1, points)
		koch(p2, n-1, points)


if __name__ == '__main__':
	n = int(input())
	p1 = [0.0, 0.0]
	p2 = [100.0, 0.0]
	points = [p1]
	koch(p2, n, points)
	[print(*p) for p in points]

Measured memory_bytes: 8608
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;



int main() {
   

    ll h,w,n;
    cin >> h >> w >> n;
    ll g = max(h,w);
    if(n%g == 0){
        cout << n/g << endl;
    }else{
        cout << n/g + 1 << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    ll x=max(a*c,a*d),y=max(c*b,b*d);
    cout<<max(x,y)<<endl;
} 

Measured memory_bytes: 3632
use proconio::{fastout, input};
use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
        n: usize,
        mut c: [usize; n],
    }

    c.sort();
    c.reverse();

    let mut edges = VecDeque::new();
    edges.push_back(0usize);

    let mut ans = 0;
    for i in 0..n {
        ans += match edges.pop_front() {
            Some(t) => t,
            None => 0,
        };
        if i == 0 {
            edges.push_back(c[i])
        } else {
            edges.push_back(c[i]);
            edges.push_back(c[i]);
        }
    }

    println!("{}", ans);
}


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

int main() {
  int64_t N,D;
  cin>>N>>D;
  int count;
  count=0;
  int64_t X,Y;
  
  for(int i=0; i<N; i++){
    cin>>X>>Y;
    if( X * X + Y * Y <= D*D  ){
      count++;
    }
  }
  cout<<count<<endl;
  
}


Measured memory_bytes: 3616
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
  
    ll a,b,n,i;
    cin>>a>>b>>n;
    ll x = min(n,b-1LL);
    ll ans = (a*x)/b;
    cout<<ans;
}

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

const int N=500005;
int n;
long long ans;

int main()
{
	scanf("%d",&n),ans=n;
	for(int i=1;i<n;i++)
	{
		ans+=1ll*i*(n-i+1);
		int x,y;
		scanf("%d%d",&x,&y);
		if(x>y) swap(x,y);
		ans-=1ll*x*(n-y+1);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3852
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = Long.parseLong(sc.next());
		if(n%2==0) {
			System.out.println(f5(n/2));
		}else {
			System.out.println(0);
		}
	}

	public static long f5(long n) {
		if(n<5) {
			return 0;
		}else{
			return n/5+f5(n/5);
		}
	}
}




Measured memory_bytes: 22740
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 60;
const int N = (int)3e5 + 7;
const int MAXN = (int)3e6 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e17;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

int n, m, k, fact[N];

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return 1LL * a * b % MOD;
}

int bin_pow(int a, int p) {
	int res = 1;
	while (p) {
		if (p & 1)
			res = mul(res, a);
		a = mul(a, a);
		p >>= 1;
	}
	return res;
}

int dev(int a, int b) {
	return mul(a, bin_pow(b, MOD - 2));
}

int c(int n, int k) {
	int dw = mul(fact[k], fact[n - k]);
	return dev(fact[n], dw);
}

void solve() {
	cin >> n >> m >> k;
	fact[0] = 1;
	for (int i = 1; i < N; i++)
		fact[i] = mul(fact[i - 1], i);
	int ans = 0;
	for (int i = 0; i <= k; i++) {
		int pl = mul(mul(c(n - 1, i), bin_pow(m - 1, n - i - 1)), m);
		ans = add(ans, pl);
	}
	cout << ans;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 4776
(defun solve (N)
  (do* ((i 1 (1+ i))
        (x (read) (read))
        (y (read) (read))
        (u (+ x y) (+ x y))
        (v (- x y) (- x y))
        (minu u (min u minu))
        (maxu u (max maxu u))
        (minv v (min minv v))
        (maxv v (max maxv v)))
    ((= i N) (princ (max (- maxu minu) (- maxv minv ))))))

(solve (read))

Measured memory_bytes: 77060
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


K, A, B = list(map(int, sys.stdin.buffer.readline().split()))

count = 1

# A になるまで増やす
count += min(K, A - 1)
K -= min(K, A - 1)

if K % 2 == 1:
    count += 1
    K -= 1

# いっぱい増える方法をいっぱいやる
if - A + B > 2:
    count += (- A + B) * K // 2
else:
    count += K
print(count)


Measured memory_bytes: 13672
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5+10;
int tot=0,he[N],ne[N*2],t[N*2],ans[N],d[N],r[N];
void link(int x,int y)
{
	tot++;
	ne[tot]=he[x];
	he[x]=tot;
	t[tot]=y;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=1;i<n+m;i++) 
	{
		int x,y;
		scanf("%d%d",&x,&y);
		r[y]++;
		link(x,y);
	}
	int k=0;
	for (int i=1;i<=n;i++) if (!r[i])
	{
		ans[i]=0;
		k++;
		d[k]=i;
	}
	int i=0;
	while (i<k)
	{
		i++;
		for (int j=he[d[i]];j;j=ne[j]) 
		{
			r[t[j]]--;
			if (r[t[j]]==0)
			{
				k++;
				d[k]=t[j];
				ans[t[j]]=d[i];
			}
		}
	}
	for (int i=1;i<=n;i++) printf("%d\n",ans[i]);
}

Measured memory_bytes: 3072
'use strict'
function main(inp) {
  inp = inp.trim().split('\n')
  const N = Number(inp.shift())
  inp = inp[0].split(' ').map(n => Number(n));

  let ans = 0
  for (let i = 0; i < N; i++) {
    ans += 1 / inp[i];
  }

  console.log(1 / ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
 
 
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
//ここから編集

void solve(){
  
  int M; cin >> M;

  ll sumc = 0;
  ll sumd = 0;
  REP(i,M){
    ll d, c;cin >> d >> c;
    sumc += c;
    
    sumd += d*c;
  }
  ll ans = sumc-1 + (sumd-1)/9;
  cout << ans << endl;

}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
    
  solve();

  return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::string buf;
	int n, q;
	std::vector<std::vector<long> > vec;
	

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	std::getline(ifs, buf);
#else
	std::getline(std::cin, buf);
#endif
	{
		std::istringstream stream(buf);

		stream >> n >> q;
	}
	vec.resize(n);

	for(int i = 0; i < q; i++){
#if INPUT_FROM_FILE
		std::getline(ifs, buf);
#else
		std::getline(std::cin, buf);
#endif
		if(buf[0] == '0'){
			std::istringstream stream(buf);
			int tmp, t, x;

			stream >> tmp >> t >> x;
			vec[t].push_back(x);
		}
		else if(buf[0] == '1'){
			std::istringstream stream(buf);
			int tmp, t;

			stream >> tmp >> t;

			if(vec[t].empty()){
				std::cout << std::endl;
			}
			else{
				std::cout << vec[t][0];
				for(int i = 1; i < vec[t].size(); i++){
					std::cout << " " << vec[t][i];
				}
				std::cout << std::endl;
			}

		}
		else{
			std::istringstream stream(buf);
			int tmp, t;

			stream >> tmp >> t;

			vec[t].clear();
		}
	}


	return 0;
}


Measured memory_bytes: 8956
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[k] < l[i] + l[j] and l[i]!=l[j] and l[j]!=l[k]:
                ans += 1
print(ans)

Measured memory_bytes: 68068