akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define mod 1000000007
#define next nxt
 
int n,x[N],y[N],z[N],next[N],p[N],h[N],q[N],f[N],g[N],s[N],cnt,cmt,cir;
long long fac[N],inv[N],ans;
vector<int> v[N];
 
long long C(int x,int y){
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
 
void travel(int x,int pre){
	h[x]=true;q[++cnt]=x;
	for (int t=p[x];t;cmt++,t=next[t])
		if (!h[y[t]]) travel(y[t],t);
		else if (t/2!=pre/2) cir=t;
}
 
void build(int x,int pre){
	for (int t=p[x];t;t=next[t])
		if (t/2!=pre/2){
			if (y[t]<g[x]) v[x].push_back(y[t]),f[y[t]]=true;
			if (t/2!=cir/2) g[y[t]]=x,build(y[t],t);
		}
}
 
long long solve(int x){
	s[x]=0;long long ans=1;
	for (int i=0;i<(int)v[x].size();i++){
		ans=ans*solve(v[x][i])%mod;
		s[x]+=s[v[x][i]];
		ans=ans*C(s[x],s[v[x][i]])%mod;
	}
	s[x]++;return ans;
}
 
int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
 
int main(){
	n=read();
	for (int i=1;i<=2*n;i++){
		x[2*i]=y[2*i+1]=read();
		y[2*i]=x[2*i+1]=n+read();
		z[2*i]=z[2*i+1]=x[2*i]+y[2*i];
		next[2*i]=p[x[2*i]];p[x[2*i]]=2*i;
		next[2*i+1]=p[x[2*i+1]];p[x[2*i+1]]=2*i+1;
	}
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for (int i=2;i<N;i++) fac[i]=fac[i-1]*i%mod;
	for (int i=2;i<N;i++) inv[i]=-(mod/i)*inv[mod%i]%mod;
	for (int i=2;i<N;i++) inv[i]=inv[i-1]*inv[i]%mod;
	ans=fac[2*n];
	for (int i=1;i<=2*n;i++)
		if (!h[i]){
			cnt=cmt=0;travel(i,0);
			if (cmt!=cnt*2) {printf("0\n");return 0;}
			
			v[0].clear();
			for (int i=1;i<=cnt;i++)
				v[q[i]].clear(),g[q[i]]=0,f[q[i]]=false;
			g[x[cir]]=y[cir];build(x[cir],cir);
			for (int i=1;i<=cnt;i++)
				if (!f[q[i]]) v[0].push_back(q[i]);
			long long tmp=solve(0);
			
			v[0].clear();
			for (int i=1;i<=cnt;i++)
				v[q[i]].clear(),g[q[i]]=0,f[q[i]]=false;
			g[y[cir]]=x[cir];build(y[cir],cir);
			for (int i=1;i<=cnt;i++)
				if (!f[q[i]]) v[0].push_back(q[i]);
			tmp+=solve(0);
			
			ans=ans*tmp%mod*inv[cnt]%mod;
		}
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 79992
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        String X = scanner.next();
        if(X.equals("ARC")){
            System.out.println("ABC");
        }else{
            System.out.println("ARC");
        }
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  int i, j;
  for (i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  int max1=0, max2=0;;
  for (i = 0; i < N; i++) {
    if (max1 < A.at(i)) {
      max2 = max1;
      max1 = A.at(i);
      j = i;
    } else if (max2 < A.at(i)) {
      max2 = A.at(i);
    }
  }

  for (i = 0; i < N; i++) {
    if (j == i) {
      cout << max2 << endl;
    } else {
      cout << max1 << endl;
    }
  }

 

  return 0;
}


Measured memory_bytes: 2432
package main

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

const MaxBuf = 200100
var buf []byte
var sc = bufio.NewScanner(os.Stdin)

func init() {
   sc.Split(bufio.ScanWords)
   sc.Buffer(buf,MaxBuf)
}

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

func readInt64() int64 {
   sc.Scan()
   r,_ := strconv.ParseInt(sc.Text(),10,64)
   return r
}

func readInt() int {
   sc.Scan()
   r,_ := strconv.Atoi(sc.Text())
   return r
}

func main() {
	n := readInt()
	a := readInt()
	n %= 500
	if a >= n {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <iostream>

using namespace std;

int main()
{
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    long long output;
    if (a > k) {
        output = k;
    }
    else if (a + b >= k) {
        output = a;
    }
    else if(a+b+c>=k){
        output = a - (k - b - a);
    }
    else {
        output = a - c;
    }

    cout << output;
    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
using namespace std;

int a[10];

int main() {
    int n;
    //scanf("%d", &n);
    for(int i = 1; i <= 5; i++) {
        int b;
        scanf("%d", &b);
        if(b == 0) n = i;
    }
    printf("%d\n", n);

	return 0;
}


Measured memory_bytes: 3828
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		int correct = 0;
		int penalty = 0;
		for(int i=0; i<m; i++) {
			int p = in.nextInt();
			String s = in.nextLine().trim();
			//System.out.println(s);
			if(map.containsKey(p)) {
				if(map.get(p)==-1) continue;
				if(s.equals("AC")) {
					correct += 1;
					penalty += map.get(p);
					map.put(p, -1);
					//System.out.println(correct + " A " + penalty);
				}else {
					map.put(p, map.get(p)+1);
					//System.out.println(correct + " B " + penalty);
				}
			}else{
				if(s.equals("AC")) {
					correct += 1;
					map.put(p, -1);
					//System.out.println(correct + " C " + penalty);
				}else {
					map.put(p, 1);
					//System.out.println(correct + " D " + penalty);
				}
			}
		}
		System.out.println(correct + " " + penalty);
	}
}


Measured memory_bytes: 155724
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

string S;

int main() {
    cin >> S;
    if (S[0] == '7' || S[1] == '7' || S[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main() {
  string a,b,c;
  cin>>a>>b>>c;
  int x=a.size();
  int y=b.size();
  string ans="YES";
  if(a[x-1]!=b[0] || b[y-1]!=c[0]) ans="NO";
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
using namespace std;

int main(void) {
	char moji[17];
	char pass[17] = "CODEFESTIVAL2016";
	int count = 0;
	cin >> moji;
	FOR(i, 0, 15) {
		if (moji[i] != pass[i]) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
struct edge{
  int to,cost;
};
typedef pair<int,int> P;
int V,m;
vector<edge> G[1000000];
int d[1000000];
void dijkstra(int);
int x;
int main(){
  cin >> V >> m;
  edge a;
  for(int i=0;i<m;i++){
    cin >> x >> a.to  >> a.cost;
    G[x].push_back(a);
  } 
  dijkstra(1);
  return 0;
}

void dijkstra(int s){
  priority_queue<P ,vector<P>,greater<P> >que;//get min
  fill(d,d+V+1,1e9+1);//syoki ->INF
  d[s]=0;
  d[V]=-1;
  que.push(P(0,s));//pair push(cost,point)
  //
  while(!que.empty()){
    //find min
    P p=que.top();
    que.pop();
    int v=p.second;
    if(d[v]<p.first)continue;
    //reload 
    for(int i=0;i<G[v].size();i++){
      edge e=G[v][i];
      if(e.cost<d[v])continue;
      if((e.to!=V&&d[e.to]>e.cost)||(e.to==V&&d[e.to]<=e.cost)){
	d[e.to]=e.cost;
	que.push(P(d[e.to],e.to));
      }
    }
  }
  cout << d[V]<< endl;
}

Measured memory_bytes: 30636
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <stdint.h>
using namespace std;

int main() {
  int K;
  cin >> K;
  std::vector<int64_t> A(K);
  for (int i = 0; i < K; ++i)
    cin >> A[i];
  std::reverse(std::begin(A), std::end(A));

  int64_t min = 2, max = 2;
  for (int i = 0; i < K; ++i) {
    int64_t a = A[i];
    int64_t nmin = a * (min / a);
    if ((min % a) > 0) nmin += a;
    int64_t nmax = a * (max / a) + (a - 1);
    if (nmin > nmax) {
      cout << -1 << endl;
      return 0;
    }
    min = nmin;
    max = nmax;
  }

  std::reverse(std::begin(A), std::end(A));
  int64_t mx = max, mi = min;
  for (int i = 0; i < K; ++i) {
    mx -= mx % A[i];
    mi -= mi % A[i];
  }
  if (mx != 2 || mi != 2)
    return 1;

  cout << min << " " << max << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;
string i;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin >>a>>b;
  if(a==1) a=14;
  if(b==1) b=14;
  if(a>b) cout <<"Alice\n";
  if(a<b) cout <<"Bob\n";
  if(a==b) cout <<"Draw\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    int t;
    cin >> t;
    vector<int> vec;
    for(int i=0; i<t; i++){
        int a;
        cin >> a;
        vec.push_back(a);
    }
    vector<int> vec2(t);
    for(int i =0; i<t; i++){
      vec2[vec[i]-1]=i+1;
    }
    for(int i=0; i<t; i++){
        cout << vec2[i]<<" ";
    }
}

Measured memory_bytes: 4264
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  ll n; cin >> n;
  ll ans = INF;
  for (ll i = 1; i*i <= n; i++) {
    if(n%i == 0) chmin(ans, i+n/i-2);
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

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


/* ACL */

//using namespace atcoder;



int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    rep(i,N-1){
        ans += N/(i+1);
        if(N % (i+1)==0){
            ans --;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
int u[N], p[N];
vector<int> g[N];
map<int, int> a, b;
void dfs(int v){
	u[v] = 1;
	a[v] = 1;
	b[p[v]] = 1;
	for(int to : g[v]) if(!u[to]) dfs(to);	
}
void solve()
{
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; ++i) cin >> p[i + 1];
	for(int i = 0; i < m; ++i){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	for(int i = 1; i <= n; ++i) if(!u[i]) {
		dfs(i);
		vector<int> q;
		for(auto it : a){
			if(b.count(it.F)) {
				b.erase(it.F);
				p[it.F] = it.F;
			}
			else q.pb(it.F);
		}
		for(auto it : q){
			p[it] = (*b.begin()).F;
			b.erase(b.begin());
		}
		a.clear();
		b.clear();
	}
	int cnt = 0;
	for(int i = 1; i <= n; ++i) cnt += (i == p[i]);
	cout << cnt << '\n'; 
}


 // a b c a b c a b c a b c
 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	//cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

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

class UnionFind {
  vector<long long> parent;

 public:
  UnionFind(long N) {
    parent = vector<long long>(N + 1, -1);
  }

  long root(long N) {
    if (parent[N] < 0) return N;
    return parent[N] = root(parent[N]);
  }

  long long size(long N) {
    return (-1) * parent[root(N)];
  }

  long long connect(long A, long B) {
    long long pair;
    A = root(A);
    B = root(B);
    if (A == B) return 0;
    if (size(A) < size(B)) swap(A, B);
    pair = size(A) * size(B);
    parent[A] += parent[B];
    parent[B] = A;
    return pair;
  }
};

int main() {
  long N, M;
  cin >> N >> M;
  vector<long long> A(M, 0), B(M, 0), incon(M, 0);
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
  }
  incon[0] = N * (N - 1) / 2;
  UnionFind uf(N);
  for (int i = 1; i < M; i++) {
    incon[i] = incon[i - 1] - uf.connect(A[M - i], B[M - i]);
  }
  for (int i = 0; i < M; i++) {
    cout << incon[M - i - 1] << endl;
  }
  return 0;
}

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

int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ret = 0;
    for(int i = 0; i <= a; ++i) {
        for(int j = 0; j <= b; ++j) {
            for(int k = 0; k <= c; ++k) {
                if(500*i + 100*j + 50*k == x)
                    ret++;
            }
        }
    }
    cout << ret << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  std::vector<int> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  std::sort(a.begin(), a.end());
  int neg_index = -1, ans = 0;
  while (neg_index + 1 < n && a[neg_index + 1] <= 0) { neg_index++; }
  for (int i = 0; i < n; i++) {
    ans += abs(a[i]);
  }
  if (neg_index>= 0 && neg_index < n - 1) {
    cout << ans << endl;
    int temp = a[neg_index];
    for (int i = neg_index + 1; i < n - 1; i++) {
      cout << temp << " " << a[i] << endl;
      temp -= a[i];
    }
    cout << a[n - 1] << " " << temp << endl;
    temp = a[n - 1] - temp;
    for (int i = 0; i < neg_index; i++) {
      cout << temp << " " << a[i] << endl;
      temp -= a[i];
    }
  } else if (neg_index == -1) {
    ans -= 2 * a[0];
    cout << ans << endl;
    int temp = a[0];
    for (int i = 1; i < n - 1; i++) {
      cout << temp << " " << a[i] << endl;
      temp -= a[i];
    }
    cout << a[n - 1] << " " << temp << endl;
  } else {
    ans += 2 * a[n - 1];
    cout << ans << endl;
    int temp = a[n - 1];
    for (int i = n - 2; i >= 0; i--) {
      cout << temp << " " << a[i] << endl;
      temp -= a[i];
    }
  }
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> s(N+1);
  for(int i=0;i<N;i++){
    cin >> s.at(i);
  }
  s.at(N) = "{";
  int M;
  cin >> M;
  vector<string> t(M);
  for(int i=0;i<M;i++){
    cin >> t.at(i);
  }
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  
  int c1 = 1, c2 = 0;
  for(int i=1;i<N+1;i++){
    if(s.at(i-1) == s.at(i)){
      c1++;
    }
    else{
      for(int j=0;j<M;j++){
        if(t.at(j) == s.at(i-1)){
          c1--;
        }
      }
      c2 = max(c2,c1);
      c1 = 1;
    }
  }
  
   cout << c2 << endl;    
  
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    int a[3001] = {0};
    ll ans = 0;
    cin >> n;
    for(int i=0;i<n;++i)
    {
        int tmp;
        cin >> tmp;
        ans += tmp - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }


int a = 0, b = 0, c, d, n, k = 0, ans = 0;
string s, t;


int main()
{
	cin >> n;
	vector<ll> x(n); rep(i, n)cin >> x[i];
	ll high = 0;
	bool z = true;
	rep(i, n )
	{
		high = max(high, x[i]);
		if (high - x[i] > 1)
			z = false;
	}
	Cout(Yes(z));

	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    int n, m;
    cin >> n >> m;

    // even
    int even = n * (n-1) / 2;
    // odd
    int odd = m * (m-1) / 2;

    cout << even + odd << endl;

    return 0;    
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())
mina=0
minb=0
minc=0

if a%2==1:
    mina=b*c
else:
    mina=0
if b%2==1:
    minb=c*a
else:
    minb=0
if c%2==1:
    minc=a*b
else:
    minc=0

print(min(mina,minb,minc))

Measured memory_bytes: 9092
#include <iostream>

using namespace std;

int main(){
    int count = 2;
    int coin = 0;
    int A, B;
    cin >> A >> B;
    while (count != 0){
        if (A >= B){
            coin += A;
            A--;
        }else{
            coin += B;
            B--;
        }
        count--;
    }
    cout << coin;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
	char s[1000001];
	scanf("%s", s);
	int i;
	for (i = 0; i < strlen(s);) {
		printf("%c", s[i]);
		i += 2;
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	if(a < b){
		printf("a < b\n");
	}else if(a > b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}	
	return 0;
}

Measured memory_bytes: 1008
intListString :: [Int] -> String
intListString [] = ""
intListString (x:xs) = show x ++ " " ++ intListString xs

main = do
    [s,t] <- words <$> getLine
    [a,b] <- map read <$> (words <$> getLine) :: IO [Int]
    u <- getLine
    if s == u
        then putStrLn $ intListString [a-1,b]
        else putStrLn $ intListString [a,b-1]



Measured memory_bytes: 3820
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int m;
    cin >> m;
    vl d(m), c(m);
    map<int, ll> cnt;
    for (int i = 0; i < m; ++i) {
        cin >> d[i] >> c[i];
        cnt[d[i]] += c[i];
    }

    auto check = [&]() {
        ll sum = 0;
        for (auto &p : cnt) {
            sum += p.second;
        }
        return sum <= 100;
    };

    vl x   = {2, 10, 5, 4, 3, 2, 2, 2, 2, 2};
    vl y   = {-1, 0, 0, 2, 2, 0, 2, 4, 6, 8};
    ll ret = 0;

    if (cnt[0] > 1) {
        ret += cnt[0] - 1;
        cnt[0] = 1;
    }

    while (!check()) {
        for (int i = 0; i <= 9; ++i) {
            if (cnt[i] >= x[i]) {
                ll cntc = cnt[i];
                ret += cntc / x[i] * x[i];
                cnt[y[i] + 1] += cntc / x[i];
                cnt[i] -= cntc / x[i] * x[i];
            }
        }
    }

    deque<ll> left;
    for (auto &p : cnt) {
        for (int j = 0; j < p.second; ++j) {
            left.push_front(p.first);
        }
    }
    while (left.size() > 1) {
        int v1 = left.front();
        left.pop_front();
        int v2 = left.front();
        left.pop_front();
        ret++;
        int v3 = v1 + v2;
        if (v3 <= 9) {
            left.push_back(v3);
        } else {
            left.push_back(v3 % 10);
            left.push_back(1);
        }
    }
    cout << ret << "\n";

    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>

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

int main() {
    int k, n; std::cin >> n >> k;
    std::vector<int> p(n);
    rep(i, n) std::cin >> p[i];
    int ans=0;
    std::sort(p.begin(), p.end());
    rep(i, k) ans += p[i];
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

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

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

void solve(){
    int n;cin >> n;
    vector<int>a(n);
    for(int i = 0;i<n;i++) cin >> a[i];
    int ans = 1;
    int mini = a[0];
    for(int i = 1;i<n;i++)
    if(a[i]<mini){
        ans++;
        mini = a[i];
    }
    cout << ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3980
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

#include<iomanip>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<double> x(N);
    vector<double> y(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
    vector<int> per;
    for (int i = 0; i < N; i++) per.push_back(i);
    double sum = 0;
    do {

        for (int i = 0; i < N - 1; i++) {
            sum += sqrt((x[per[i]] - x[per[i + 1]]) * (x[per[i]] - x[per[i + 1]]) + (y[per[i]] - y[per[i + 1]]) * (y[per[i]] - y[per[i + 1]]));
        }
    } while (next_permutation(per.begin(), per.end()));

    double pro = 1;
    for (int i = 1; i <= N; i++) pro *= i;
    cout << setprecision(10) << sum / pro << endl;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,T,t; cin>>n>>T;
	int ret=T, prev=0;
	for (int i=0; i<n; i++) {
		cin>>t;
		if(prev+T>=t) ret+=t-prev;
		else ret+=T;
		prev=t;
	}

	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)
k = []
s = []
m.times do |i|
  s[i] = gets.chomp.split.map(&:to_i)
  k[i] = s[i].shift
  k[i].times do |j|
    s[i][j] -= 1
  end
end
p = gets.chomp.split.map(&:to_i)

ans = 0
[0, 1].repeated_permutation(n) do |b|
  cnt = 1
  m.times do |i|
    judge = 0
    k[i].times do |j|
      judge += b[s[i][j]]
    end
    if judge % 2 != p[i]
      cnt = 0
      break
    end
  end
  if cnt == 1
    ans += 1
  end
end
puts ans


Measured memory_bytes: 1916
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long A = long.Parse(Console.ReadLine());
            long B = long.Parse(Console.ReadLine());
            long C = long.Parse(Console.ReadLine());
            long X = long.Parse(Console.ReadLine());
            int cnt = 0;
            for(int i = 0; i <= A; i++)
            {
                for(int j = 0; j <= B; j++)
                {
                    for(int z = 0; z <= C; z++)
                    {
                        if (i * 500 + j * 100+z*50==X)
                        {
                            cnt++;
                        }
                    }
                }
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


Measured memory_bytes: 27512
/* When Talent doesn't work, Hard work beats Talent*/

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(20);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define sp " "
#define int long long
#define double long double
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI=3.141592653589793;
const int L=1e18;

void solve()
{
	int n;
	cin >> n;
	string s;
	cin>>s;
	int w=0, r=0;
	r=count(s.begin(),s.end(),'R');
	for(int i=0;i<r;i++) if(s[i]=='W') w++;
	cout << w << nl ;
}

int32_t main()
{
	FastIO;
	Fast_D;
	solve();
	return 0;
}


Measured memory_bytes: 3768
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
	int n,k,ans=0,a1=0;
	cin>>n;
	vector<pair<int,int>>a(100000);
	vector<pair<int,int>>b(100000);
	for(int i=0;i<n;i++){
		cin>>k;
		if(i%2==0){
			a[k-1].first++;
			a[k-1].second=k-1;
		}
		else{
			b[k-1].first++;
			b[k-1].second=k-1;
		}
	}
	sort(a.begin(),a.end(),greater<>());
	sort(b.begin(),b.end(),greater<>());
	a1=a[0].first+b[0].first;
	if(a[0].second==b[0].second){
		if(a[0].first>b[0].first){
			a1=a1-b[0].first+b[1].first;
		}
		else if(a[0].first<b[0].first){
			a1=a1-a[0].first+a[1].first;
		}
		else{
			a1=a1/2+max(a[1].first,b[1].first);
		}
	}
	cout<<n-a1<<endl;
	return 0;
}

Measured memory_bytes: 1920
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 10005, mod = 1e9 + 7;

char a[N];
int d;

int f[N][105][2];

int go(int pos, int rem, bool small) {
    int& res = f[pos][rem][small];
    if(res == -1) {
        res = 0;
        if(a[pos] == 0) {
            res = (rem == 0);
        } else {
            rep(dig, '0', int('9' + 1)) {
                if(dig > a[pos] && small == 0) {
                    break;
                }
                res += go(pos + 1, (rem + dig - '0') % d, small || (dig < a[pos]));
                if(res >= mod) {
                    res -= mod;
                }
            }
        }
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> a;
    cin >> d;
    memset(f, -1, sizeof(f));
    int res = go(0, 0, 0);
    res--;
    if(res < 0) {
        res += mod;
    }
    cout << res << endl;
}

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

int main() {
    string A;
    cin >> A;
    long long n = A.size();
    map<char, long long> cnt;
    for(int i=0; i<n; ++i) ++cnt[A[i]];

    long long res = 1;
    for(auto itr = cnt.begin(); itr != cnt.end(); ++itr) {
        n -= itr->second;
        res += itr->second * n;
    }
    cout << res << endl;
}

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

int main(){
  
  int A, B; cin >> A >> B;
  int count = 0;
  for(int i = A; i <= B; i++){
    string s;
    s = to_string(i);
    if(s[0] == s[4] && s[1] == s[3]){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector <int> ar(n);
	for(int &x: ar) cin >> x;
	if(n == 1){
		cout << ar[0];
		return 0;
	}
	sort(ALL(ar));
	double res = (ar[0]+ar[1])/2.0;
	
	for(int i=2; i<n; i++)
		res = (res + (double)ar[i])	/ 2.0;
	printf("%.10f", res);
	return 0;
}

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

int main() {
    int n;
    while (cin >> n) {
        map<int, int> cnt;
        vector<int> a(n);
        rep(i, n) cin >> a[i];
        vector<int> ans;
        rep(i, n) {
            int l = a[i], r = a[n - i - 1];
            cnt[l]++;
            cnt[r]--;
            if (cnt[l] == 0) cnt.erase(l);
            if (cnt[r] == 0) cnt.erase(r);
            if (cnt.size() == 0) {
                ans.push_back(i);
            }
        }
        rep(i, ans.size()) {
            cout << ans[i] + 1;
            if (i + 1 == ans.size()) {
                cout << endl;
            } else {
                cout << ' ';
            }
        }
    }
}



Measured memory_bytes: 4088
n,a,b = map(int,input().split())

mod = 10**9+7
total = pow(2,n,mod) - 1 # 制約なしの全パターン_n**2-1※'-1'は0本の花束

# n個からr個を選択した時のパターン総数
# n! / (r! * (n-r)!) → nが大き過ぎて出来ない →変形→ n*(n-1)*･･･(n-r+1) ↓関数化
def nCr(n, r, mod):
    numerator=1 #分子
    for i in range(n-r+1, n+1):
        numerator = (numerator*i) % mod

    denominator=1 #分母
    for j in range(1,r+1):
        denominator = (denominator*j) % mod
    # 割るとよくない → 逆元を掛ける
    # フェルマーの小定理_modが素数なら1/aの逆元は a**(mod-2)
    return (numerator * pow(denominator,mod-2,mod)) % mod
    
ans = (total - nCr(n,a,mod) - nCr(n,b,mod)) % mod
print(ans)

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

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

    sort(begin(a), end(a));
    sort(begin(b), end(b));
    sort(begin(c), end(c));

    vector<ll> kb(N), cb(N);
    for (int i = 0; i < N; i++) {
        kb[i] = end(c) - lower_bound(begin(c), end(c), b[i] + 1);
    }
    for (int i = N-1; i >= 0; i--) {
        cb[i] = kb[i] + (i < N-1 ? cb[i+1] : 0);
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        int at = lower_bound(begin(b), end(b), a[i] + 1) - begin(b);
        ans += at < N ? cb[at] : 0;
    }

    cout << ans << endl;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  string S;
  cin >> S;
  ll K;
  cin >> K;

  string S_cp = S;
  S_cp.pb('.');

  vector<ll> num;
  ll temp = 1;
  rep(i, sz(S)) {
    if (S_cp[i + 1] == S_cp[i])
      temp++;
    else {
      num.pb(temp);
      temp = 1;
    }
  }

  ll ans = 0;

  if (sz(num) == 1) {
    ans = (sz(S) * K) / 2;
  } else if (S[0] != S[sz(S) - 1]) {
    rep(i, sz(num)) {
      ans += K * (num[i] / 2);
    }
  } else {
    ans += num[0] / 2;
    repp(i, 1, sz(num) - 2) {
      ans += K * (num[i] / 2);
    }
    ans += (K - 1) * ((num[0] + num[sz(num) - 1]) / 2);
    ans += num[sz(num) - 1] / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD (1e9 +7)
 
using namespace std;
 


 
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); 
    
    long long n, k;
    cin >> n >> k;
    long long a[n+1] ;
    long long visited[1000000] = {0};
    for(int i = 1; i <= n; i++) cin >> a[i];
    long long  l, i;
    long long idx[n+1] = {0};
    vector <long long> v;
    for(i = 1;  k;  k--){
        if(visited[i]){
            
            l = idx[i];
            break;
        }
        else{
            idx[i] = v.size();
            v.push_back(i);
            visited[i]++;
            i = a[i];
        }
    }
    vector<long long> v2;
    v2.assign(v.begin()+l, v.end());
    int sz = v2.size();
    if(k == 0) cout << i;
    else cout << v2[k%sz];
    



    return 0;
}

Measured memory_bytes: 16704
#include <bits/stdc++.h>
using namespace std;
int main () {
  int H, N;
  cin >> H >> N;
  vector<long> HP(H + 1, 100000000000000);
  HP.at(0) = 0;
  long A, B;
  for(int i = 0; i < N; i++){
    cin >> A >> B;
    for(int i = 0; i < H; i++){
      if(i + A > H)HP.at(H) = min(HP.at(H), HP.at(i) + B);
      else HP.at(i + A) = min(HP.at(i + A), HP.at(i) + B);
    }
  }
  cout << HP.at(H) << endl;
  return 0;
}


Measured memory_bytes: 384
n, m = map(int, input().split())
a = [tuple(map(int, input().split())) for i in range(n)]
b = [0] + [tuple(map(int, input().split())) for i in range(m)]

def d(a, b):
  return abs(a[0]-b[0]) + abs(a[1]-b[1])

for i in range(n):
    c = 1
    t = d(a[i], b[1])
    for j in range(2, m+1):
        if d(a[i], b[j]) < t:
            c = j
            t = d(a[i], b[j])
    print(c)

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    int A, B;
    cin >> A >> B;

    if( A >= 10 || B >= 10 ){
        cout << -1 << endl;
    }else{
       cout << A*B << endl;
    }
}


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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define dbg(x)                       cout << #x << " is " << x << endl;
#define endl                           '\n'

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	cin>>n;
	ll a[n],dp[n];
	rep(i,0,n) cin>>a[i];
	dp[0]=0;
	dp[1]=abs(a[0]-a[1]);
	rep(i,2,n)
		dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
	ret(dp[n-1])	
	
	return 0;
}

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

using namespace std;

typedef long long ll;

#define FOR(a, b, i) for(ll i=a; i<b; i++)
#define RFOR(a, b, i) for(ll i=a; i>=b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1e9+7
#define newline cout<<"\n"


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

    ll n, W; cin>>n>>W;

    vector<ll> dp(W+1, 0);

    FOR(0, n, i)
    {
        ll w, v; cin>>w>>v;
        RFOR(W-w, 0, weight_already)
        {
            dp[weight_already+w] = max(dp[weight_already+w], dp[weight_already]+v);
        }
    }    

    cout<<dp[W];
    newline;


    return 0;
}

Measured memory_bytes: 1024
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

void dfs(int i, std::vector<std::vector<int> >& to, std::vector<int>& dp)
{
	for(auto v:to[i]) {
		if(dp[v]==0) dfs(v,to,dp);
		dp[i] = std::max(dp[i],dp[v]+1);
	}
	return;
}

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<std::vector<int> > to(n,std::vector<int>());
	std::vector<int> dp(n,0);
	rep(i,m) {
		int a,b;
		std::cin >> a >> b;
		a--;b--;
		to[a].emplace_back(b);
	}
	rep(i,n) if(dp[i]==0) dfs(i,to,dp);
	int max = 0;
	rep(i,n) max = std::max(dp[i],max);
	print(max);
	return 0;
}


Measured memory_bytes: 9216
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	int n, d;
	cin >> n >> d;
	vector<long long> x(n);
	vector<long long> y(n);

	for (int i = 0;i < n;i++) {
		cin >> x[i] >> y[i];
	}

	int ans = 0;

	for (int i = 0;i < n;i++) {
		if (sqrt(pow(x[i], 2) + pow(y[i], 2)) <= d) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6484
n = int(input())
x1 = int(n / 1.08)
x2 = int(n / 1.08) + 1
n1 = int(x1 * 1.08)
n2 = int(x2 * 1.08)
if n == n1:
    print(x1)
elif n == n2:
    print(x2)
else:
    print(":(")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;



int main() {
  ll h,w;
  cin >> h >> w;
  ll p=w/2,o=w/2+w%2,e=h/2,r=h/2+h%2;
  if (h!=1 && w!=1) cout << p*e+o*r << endl;
  else cout << 1 << endl;
}


Measured memory_bytes: 256
from collections import Counter
from collections import deque
from functools import reduce
from operator import mul
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def COMBINATION(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    o = reduce(mul, range(n, n - r, -1))
    u = reduce(mul, range(1, r + 1))
    return o // u
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

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

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  # 経路圧縮
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


a, b = MI()
print(a if a <= b else a-1)


Measured memory_bytes: 65772
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)


typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


/*************************************************************************/
//多次元配列の確保及び初期化用マクロ
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}
/*************************************************************************/


#define ARRAY_MAX 100005
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int main() {

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

	vector<ll> s, t;
	s.push_back(0LL);
	s.push_back(0LL);
	s.push_back(0LL);
	t.push_back(0LL);
	t.push_back(0LL);
	t.push_back(0LL);
	t.push_back(0LL);

	for (ll i = 0; i < a; i++)
	{
		ll tmp;
		cin >> tmp;
		s.push_back(tmp);
	}

	for (ll i = 0; i < b; i++)
	{
		ll tmp;
		cin >> tmp;
		t.push_back(tmp);
	}
	s.push_back(1e14);
	s.push_back(1e14);
	s.push_back(1e14);
	t.push_back(1e14);
	t.push_back(1e14);
	t.push_back(1e14);


	sort(s.begin(), s.end());
	sort(t.begin(), t.end());

	for (ll i = 0; i < q; i++)
	{
		ll mini = 1e17;
		ll query;
		cin >> query;

		auto tmp1 = lower_bound(s.begin(), s.end(), query);
		auto tmp2 = lower_bound(t.begin(), t.end(), query);

		vector<ll> v1, v2;
			   
		v1.push_back(*tmp1);
		v1.push_back(*(tmp1-1));
		v1.push_back(*(tmp1+1));

		v2.push_back(*tmp2);
		v2.push_back(*(tmp2 - 1));
		v2.push_back(*(tmp2 + 1));

		ll cnt = 0;

		for (auto itr1 : v1) 
		{
			if (itr1 == 0LL || itr1 == 1e14)
			{
				continue;
			}
			for (auto itr2 : v2)
			{
				if (itr2 == 0LL || itr2 == 1e14)
				{
					continue;
				}
							   
				ll dis1 = abs(itr1 - query) + abs(itr1 - itr2);
				ll dis2 = abs(itr2 - query) + abs(itr2 - itr1);
				mini = min(mini, min(dis1, dis2));
			}
		}
		cout << mini << endl;
		v1.shrink_to_fit();
		v2.shrink_to_fit();
	}






	return 0;
}


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


int main() {
	int n;
	string s,t,st="A";
	cin>>n>>s>>t;
	st.pop_back();
	for(i,n){
		st+=s[i];
		st+=t[i];
	}
	cout<<st<<endl;
}


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

int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}

int lcm(int x,int y){
	return x*y/gcd(x,y);
}
 
signed main(){
	int n;
	cin>>n;
	map<int,int>mp;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		mp[a]++;
	}
	for(auto itr=mp.begin();itr!=mp.end();itr++){
		if(itr->second%2==1)ans++;
	}
	cout<<ans<<endl;
}

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

T = 0
H = 0

for i in range(n):
    T_card , H_card = input().split()
    if T_card == H_card :
        T += 1
        H += 1
    elif T_card > H_card :
        T += 3
    else:
        H += 3
    
print(T,H)


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  string s;
  cin >> s;
  if(s=="AAA" || s=="BBB") cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256