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

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

template <typename T, typename U>
bool chmin(T &a, const U &b){
  return (a > b ? a = b, true : false);
}

template <typename T, typename U>
bool chmax(T &a, const U &b){
  return (a < b ? a = b, true : false);
}

template <typename T, size_t N, typename U>
void fill_array(T (&a)[N], const U &v){
  std::fill((U*)a, (U*)(a + N), v);
}

template <typename T, size_t N, size_t I = N>
auto make_vector(const std::array<int, N> &a, T value = T()){
  static_assert(I >= 1);
  static_assert(N >= 1);
  if constexpr (I == 1){
    return std::vector<T>(a[N - I], value);
  }else{
    return std::vector(a[N - I], make_vector<T, N, I - 1>(a, value));
  }
}

template <typename T>
std::ostream& operator<<(std::ostream &s, const std::vector<T> &a){
  for(auto it = a.begin(); it != a.end(); ++it){
    if(it != a.begin()) s << " ";
    s << *it;
  }
  return s;
}

template <typename T>
std::istream& operator>>(std::istream &s, std::vector<T> &a){
  for(auto &x : a) s >> x;
  return s;
}


namespace haar_lib {}

namespace solver {
  using namespace haar_lib;

  void init(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(12);
    std::cerr << std::fixed << std::setprecision(12);
    std::cin.exceptions(std::ios_base::failbit);
  }

  void solve(){
    int n; std::cin >> n;
    std::cout << (1 - n) << "\n";
  }
}

int main(){
  solver::init();
  while(true){
    try{
      solver::solve();
    }catch(const std::istream::failure &e){
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,x;
  cin >> N >> x;
  int sum=-1;
  vector<int> vec(N);
  for (int i=0;i<N;i++){
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  for (int i=0;i<N && x>=0;i++){
    x-=vec[i];
    sum+=1;
  }
  if(sum==N-1){
    if(x==0) sum=N;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

struct edge{int from, to; ll cost;};

const int MAX_V = 2500;
vector<edge> es;
vector<ll> d(MAX_V, -INF);

bool positive_loop(int s, int t){
    d[s] = 0;
    rep(i, 2*MAX_V){
        for(auto &e: es){
            if(d[e.from] > -INF && d[e.to] < d[e.from] + e.cost){
                if(i >= MAX_V-1 && e.to == t) return true;
                elif(i >= MAX_V-1) d[e.to] = INF;
                else d[e.to] = d[e.from] + e.cost;
            }
        }
    }
    return false;
}

int main(){
    int N, M; ll P;
    cin >> N >> M >> P;
    rep(i, M){
        int u, v; ll c;
        cin >> u >> v >> c;
        u--, v--;
        es.emplace_back((edge){u, v, c-P});
    }
    if(positive_loop(0, N-1)) cout << -1 << endl;
    else cout << max((ll)0, d[N-1]) << endl;
}

Measured memory_bytes: 512
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(min(a,x//500)+1): #iは0,1,2...,x//500
    remains = x - 500 * i
    for j in range(min(b,remains//100)+1):
        Remains = remains - 100 * j
        for k in range(min(c,Remains//50)+1):
            fifty = Remains - 50 * k
            if fifty == 0:
                count = count + 1
            else: continue

print(count)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>



int main()
{
    char a[5];
    scanf("%s",a);
    int i,j,s,flag=0;
    for(i=0;i<4;i++)
    {
        s=0;
        for(j=i+1;j<4;j++)
            if(a[i]==a[j])
        {
            s++;
        }
        if(s>1)
        {
            flag=-1;
            break;
        }
        if(s==1)
            flag++;
    }
    if(flag==2)
        printf("Yes");
    else
        printf("No");
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d",&a,&b);
	if(a>=1 && a<=9 && b>=1 && b<=9)
	{
		printf ("%d\n",a*b);
	}
	else printf("-1\n");
	return 0;
}

Measured memory_bytes: 128
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    VIN(ll, v, 5);
    rep(i, 5) {
        if (v[i] == 0) {
            cout << i+1 << endl;
        }
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
int n;
ll n3,r1,g1,b1,r2,g2,b2;
ll ans;
string s;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    n3=n;
    cin>>s;
    ans=1ll;
    for(int i=0;i<3*n;i++)
    {
        if(s[i]=='R')
        {
            if(r2!=0)
            {
                ans=ans*r2%mod;
                r2--;
            }
            else if(g1!=0||b1!= 0)
            {
                ans=ans*(g1+b1)%mod;
                if(g1!=0)g1--,b2++;
                else b1--,g2++;
            }
            else
            {
                r1++;
                ans=ans*n3%mod;
                n3--;
            }
        }
        else if(s[i]=='G')
        {
            if(g2!=0)
            {
                ans=ans*g2%mod;
                g2--;
            }
            else if(r1!=0||b1!=0)
            {
                ans=ans*(r1+b1)%mod;
                if(r1!=0)r1--,b2++;
                else b1--,r2++;
            }
            else
            {
                g1++;
                ans=ans*n3%mod;
                n3--;
            }
        }
        else if(s[i]=='B')
        {
            if(b2!=0)
            {
                ans=ans*b2%mod;
                b2--;
            }
            else if(g1!=0||r1!=0)
            {
                ans=ans*(g1+r1)%mod;
                if(g1!=0)g1--,r2++;
                else r1--,g2++;
            }
            else
            {
                b1++;
                ans=ans*n3%mod;
                n3--;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 720
def solve():
    a,b,c= map(int,input().split())
    k=int(input())
    for k in range(k):
        if b <= a:
            b = b *2
        elif  c <= b:
            c = c * 2

    if b>a and c>b:
        print("Yes")
    else:
        print("No")



solve()
    

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	ll t1, t2;
	cin >> t1 >> t2;
	ll a1, a2, b1, b2;
	cin >> a1 >> a2 >> b1 >> b2;
	//if(t1 * a1 + t2 * a2 == t1*b1 + t2*b2){
	a1 *= t1, a2 *= t2;
	b1 *= t1, b2 *= t2;
	
	a2 += a1;
	b2 += b1;

	if(a2 == b2){
		cout << "infinity" << endl;
		return 0;
	}
	if(a2 < b2){
		swap(a1,b1);
		swap(a2,b2);
	}

	ll d = a2 - b2;
	ll c = b1 - a1;
	ll ans = 0;
	if(c > 0){
		ans = (c-1)/d+1;
		ans *= 2;
		ans--;
		if(c%d==0)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3636
from heapq import *


n, m = list(map(int, input().split()))
job = [list(map(int, input().split())) for _ in range(n)]
job.sort(reverse=True)
q = []
ans = 0
for i in range(m-1, -1, -1):
    while job and job[-1][0] + i <= m:
        a, b = job.pop()
        heappush(q, -b)

    if q:
        ans -= heappop(q)

print(ans)


Measured memory_bytes: 28080
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;
const ld PI = acos(-1.0);

int main(){
    ld t, x;
    cin >> t >> x;
    cout << t/x << endl;
	return 0;
}


Measured memory_bytes: 256
from typing import List


def answer(h: int, w: int, c: List[str]) -> str:
    result = ''
    for i in c:
        for j in range(2):
            result += f'{i}\n'

    return result[:-1]


def main():
    h, w = map(int, input().split())
    c = [input() for _ in range(h)]
    print(answer(h, w, c))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10308
n = int(input())
for i in range(n):
    if (i + 1) * (i + 2) // 2 >= n:
        m = i + 1
        d = (i + 1) * (i + 2) // 2 - n
        break
for i in range(m):
    if i + 1 == d:
        continue
    else:
        print(i + 1)

Measured memory_bytes: 9296
a = input()
b = input()
dp = [[0 for n in range(len(a) + 1)] for m in range(len(b) + 1)]

for i in range(len(b) + 1):
    for j in range(len(a) + 1):
        if i == 0:
            dp[i][j] = j
        elif j == 0:
            dp[i][j] = i
        else:
            dp[i][j] = min(dp[i - 1][j - 1] + int(a[j - 1] != b[i - 1]), dp[i][j - 1] + 1, dp[i - 1][j] + 1)
print(dp[len(b)][len(a)])


Measured memory_bytes: 43800
import java.util.Scanner;

public class Main{
	static int n;
	static int[] w;
	static int[] s= {5, 7, 5, 7, 7};
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int n=sc.nextInt();
				if(n==0) break;
				w=new int[n+1];
				for(int i=1; i<=n; i++) {
					String str=sc.next();
					w[i]=str.length();
				}
				for(int k=1; k<=n; k++) {
					int c=0; 
					int j=0;
					int check=0;
					for(int i=k; i<=n; i++) {
						c+=w[i];
						if(c==s[j]) {
							j++;
							c=0;
							if(j==5) {
								System.out.println(k);
								check=1;
								break;
							}
						}
						else if(c>s[j]) {
							break;
						}
					}
					if(check==1) break;
				}
			}
		}
	}
}


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

int main() {
	string K;
	cin >> K;
	int Klength = K.length();
	int Khalf = (Klength + 1) / 2;
	int ans = Klength;
	char symbol;
	symbol = K[0];

	for (int i = 1; i < Klength; i++) {
		if (K[i] != symbol) {
			int temp = max(i, Klength - i);
			ans = min(ans, temp);
			symbol = K[i];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

LL d[110][110];//d[i][j]はe={u,v}のコスト(存在しないときはINF,i==jのときは0)
int N;
LL a[1000], b[1000], c[1000];
void warshall_floyd() {
	for (int k = 0; k<N; k++) {
		for (int i = 0; i<N; i++) {
			for (int j = 0; j<N; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int main() {
	for (int i = 0; i < 110; i++) {
		for (int j = 0; j < 110; j++) {
			if (i == j)d[i][j] = 0;
			else d[i][j] = INF;
		}
	}
	cin >> N;
	int M;
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--, b[i]--;
	}
	for (int i = 0; i < M; i++) {
		d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]);
		d[b[i]][a[i]] = min(d[b[i]][a[i]], c[i]);
	}
	warshall_floyd();
	int ans = M;
	for (int i = 0; i < M; i++) {
		bool shortest = false;
		for (int j = 0; j < N; j++) {
			if (d[j][a[i]] + c[i] == d[j][b[i]])shortest = true;
		}
		if (shortest) {
			ans -= 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pii>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;

int main() {
    int N, K, ans = 0;
    cin >> N >> K;
    for(int i = 0; i < N; ++i) {
        int h;
        cin >> h;
        if(h >= K)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
	int a[2][2],b[2];
	float a_inverse[2][2];
	float answer[2];
	while(scanf("%d %d %d %d %d %d",&a[0][0],&a[0][1],&b[0],&a[1][0],&a[1][1],&b[1]) != EOF){
		float delta = a[0][0] * a[1][1] - a[1][0] * a[0][1];
		a_inverse[0][0] = a[1][1] / delta;
		a_inverse[1][1] = a[0][0] / delta;
		a_inverse[0][1] = -a[0][1] / delta;
		a_inverse[1][0] = -a[1][0] / delta;
		answer[0] = a_inverse[0][0] * b[0] + a_inverse[0][1] * b[1];
		answer[1] = a_inverse[1][0] * b[0] + a_inverse[1][1] * b[1];
		printf("%.3f %.3f\n",answer[0],answer[1]);
	}
	return 0;
}

Measured memory_bytes: 2660
#include <iostream>
#include <string>

int main()
{
    int N;
    std::string S;
    std::cin >> N >> S;

    int len = S.size();
    for (int i=0; i<len; ++i) {
        S[i] = (((((S[i] & 0x1f) - 1) + N) % 26) + 1) | 0x40;
    }
    std::cout << S << std::endl;
    return 0;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	bool isValid = s[0] == 'A' 
		&& count_if(s.begin(), s.end(), [](char c) { return c >= 'A' && c <= 'Z';}) == 2
		&& any_of(s.begin()+2, s.end()-1, [](char c) { return c == 'C';});
	cout << (isValid ? "AC" : "WA") << endl;
	return 0;
}


Measured memory_bytes: 256
inputs = input().split(' ')
cnt_1 = int(inputs[0])
cnt_0 = int(inputs[1])
cnt_m1 = int(inputs[2])
cnts = int(inputs[3])

sum_card = 0
if cnt_1 >= cnts:
    sum_card = cnts
elif cnt_1 + cnt_0 >= cnts:
    sum_card = cnt_1
else:
    sum_card = cnt_1 - (cnts - cnt_1 - cnt_0)

print(sum_card)

Measured memory_bytes: 9184
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int H, W;
  cin >> H >> W;

  char red[510][510], blue[510][510], a[510][510];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a[i][j];
      red[i][j] = '#';
      blue[i][j] = '.';
    }
  }

  for (int i = 1; i < H - 1; i += 2) {
    for (int j = 1; j < W - 1; j++) {
      blue[i][j] = '#';
      red[i][j] = '.';
    }
  }

  int cont = 0;
  for (int i = 2; i < H - 1; i += 2) {
    if (cont % 2 == 0) {
      blue[i][W - 2] = '#';
      red[i][W - 2] = '.';
    } else {
      blue[i][1] = '#';
      red[i][1] = '.';
    }
    cont++;
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (a[i][j] == '#') {
        blue[i][j] = red[i][j] = '#';
      }
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << red[i][j];
    }
    cout << endl;
  }

  cout << endl;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << blue[i][j];
    }
    cout << endl;
  }
  return 0;
}


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

int bucket[26];

int main(){
	string s;
	while(getline(cin, s)) {
		for(auto c: s) {
			if(isupper(c)) c = tolower(c);
			int x = c - 'a';
			if(x < 0 || x > 27) continue;
			bucket[x]++;
		}
	}
	for(int i = 0; i < 26; i++)
		printf("%c : %d\n", 'a' + i, bucket[i]);
}



Measured memory_bytes: 3336
#include<bits/stdc++.h> 
const int maxn=100005;
using namespace std;
int d[maxn]={0},p[maxn]={0};
vector<int> a[maxn];
int main(){
	int i,j,k,m,n;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	queue<int>s;
	s.push(1);
	p[1]=1;
	while(!s.empty()){
		k=s.front();
		s.pop();
		for(j=0;j<a[k].size();j++)
			if(!p[a[k][j]]){
				d[a[k][j]]=k;
				p[a[k][j]]=1;
				s.push(a[k][j]);
			}	
	}
	int ok=1;
	for(i=2;i<=n;i++){
		if(d[i]==0){
			ok=0;
			break;
		}
	}
	if(ok){
		printf("Yes\n");
		for(i=2;i<=n;i++)printf("%d\n",d[i]);
	}
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 11048
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int A,B,C,D;
	int area1=0;
	int area2=0;
	scanf("%d %d %d %d",&A,&B,&C,&D);
	area1=A*B;
	area2=C*D;
	if(area1>area2)
	printf("%d",area1);
	else if(area1<area2)
	printf("%d",area2);
	else
	printf("%d",area1);
	return 0;
}


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

using namespace std;

int main(){
	while(true){
		int a, b;
		cin >> a >> b;
		if(a==0){
			break;
		}
		for(int i = 0; i < a; i++){
			for(int j = 0; j < b; j++){
				if((i+j)%2==0){
					cout << "#";
				}
				else{
					cout << ".";
				}
			}
			cout << "\n";
		}
		cout << "\n";
	}
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define PI 2*acos(0)
#define INF 1e15
//#define mx 1000005
using namespace std;
string s,t;
stack<char>m;
int N,M;
int dp[3001][3001];
int solve(int i,int j)
{
    if(i<0 || j<0) return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    int ans=0;
    if(s[i]==t[j]){
        ans=1+solve(i-1,j-1);
    }
    else{
        int val1=solve(i-1,j);
        int val2=solve(i,j-1);
        ans=max(val1,val2);
    }
    dp[i][j]=ans;
    return dp[i][j];
}
void build(int i,int j)
{
    if(i<0 || j< 0) return ;
    if(s[i]==t[j]){
        m.push(s[i]);
        build(i-1,j-1);
        return ;
    }
    if(solve(i-1,j)>solve(i,j-1)) build(i-1,j);
    else build(i,j-1);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>s>>t;
    memset(dp,-1,sizeof(dp));
    N=s.size();
    M=t.size();
    build(N-1,M-1);
    while(!m.empty()){
        cout<<m.top();
        m.pop();
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 39168
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define FOR(i,n) for(int i=0;i<(n);++i)
#define FORU(i,j,k) for(int i=(j);i<=(k);++i)
#define FORD(i,j,k) for(int i=(j);i>=(k);--i)

#define RDI(n) scanf("%d", &(n));
#define RDL(n) scanf("%lld", &(n));

using namespace std;

using lli = long long int;
using pll = pair<lli, lli>;

const long long int oo = 1000*1000*1000;

struct Coord
{
	int x, y;
	Coord(int x = 0, int y = 0) : x(x), y(y) {}
	Coord operator + (const Coord& droite) const
	{
		return Coord(x + droite.x, y + droite.y);
	}
};

struct AB
{
	int k;
	vector<lli> arbre;
	AB(int _k = 20, lli def = 0)
	{
		k = _k;
		FOR(i, 1 << k)
			arbre.push_back(i < (1 << (k-1)) ? 0LL : def);
		FORD(i, ((1 << (k-1)) - 1), 1)
			arbre[i] = arbre[i << 1] + arbre[(i << 1) ^ 1];
	}
	void set(int i, lli x)
	{
		int feuille = i + (1 << (k-1));
		arbre[feuille] = x;
		iset(feuille >> 1);
	}
	void iset(int noeud)
	{
		if(noeud)
		{
			arbre[noeud] = arbre[noeud << 1] + arbre[(noeud << 1)  ^ 1];
			iset(noeud >> 1);
		}
	}
	lli sum(int deb, int fin, int noeud = 1, int p = 0, int q = -1)
	{
		if(q < p)
			q = 1 << (k-1);
		if(deb <= p && q <= fin)
			return arbre[noeud];
		if(deb >= q || fin <= p)
			return 0LL;
		int mil = (p + q) / 2;
		return sum(deb, fin, noeud << 1, p, mil) + sum(deb, fin, (noeud << 1) ^ 1, mil, q);
	}
};

int main()
{
	lli a, b, c, d, e, f, g;
	scanf("%lld%lld%lld%lld%lld%lld%lld", &a, &b, &c, &d, &e, &f, &g);
	lli r = 0;
	if(a && d && e && ((d % 2) + (e % 2) + (a % 2)) > 1)
	{
		--a;
		--d;
		--e;
		r += 3;
	}
	printf("%lld\n", r + b + 2*(a/2) + 2*(d/2) + 2*(e/2));
	return 0;
}


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

void half(int N,long *A){
    for(int i=0;i<N;i++){
        A[i]/=2;
    }
}

bool check(int N,long *A){
    for(int i=0;i<N;i++){
        if(A[i]%2!=0) return false;
    }
    return true;
}

int main(){
    int N,count=0;
    long A[200];

    cin>>N;
    
    for(int i=0;i<N;i++){
        cin>>A[i];
    }

    while (check(N,A))
    {
        half(N,A);
        count++;
    }
    cout<<count<<endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, m; cin >> n >> m;
    vector<bool> b(n, false);
    int pos = 1, mx = 1; 
    for (int i = m; i >= 1; i-=2) {
        cout << pos << " " << pos+i << endl;
        pos++;
        chmax(mx, pos+i);
    }
    pos = mx;
    for (int i = m-1; i >= 1; i-=2) {
        cout << pos << " " << pos+i << endl;
        pos++;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define getBit(x,i) (x&(1<<i))
#define setBit(x,i) (x|(1<<i))
#define mem(A,N) memset(A,N,sizeof(A))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define rep(i, x, y)  for(int i = x; i < y; ++i)
#define Rep(i, x, y)  for(int i = x; i <= y; ++i)
#define srep(i, x, y) for(int i = x; i > y; --i)
#define sRep(i, x, y) for(int i = x; i >= y; --i)
#define all(v) v.begin(),v.end()
#define Sort(x) sort(x.begin(), x.end())
#define f1(i,n) for (int i=1; i<=n; i++)
#define f0(i,n) for (int i=0; i<n; i++)
#define sz(x) ((int)(x).size())
#define len(x) ((int)(x).length())
#define fi first
#define se second

#define linf 0x7FFFFFFFFFFFFFFF
#define inf 0x7FFFFFFF
#define mod 1000000007
#define eps 1e-9
#define Pi 3.14159265358979323846

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define write(x) cerr << #x << " = " << (x) << ", ";
#define writeI0 cerr << "i = " << 0 << ", ";
#define dumpI0 cerr << "i = " << 0 << endl;
#define printSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printPairSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << '(' << it->first << ", " << it->second << ')' : cout << " (" << it->first << ", " << it->second << ')'; cout << endl;
#define printVector(x) for(auto it = x.begin(); it!=x.end(); it++) (it==x.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printArray(a,x,y) for(auto it = a+x; it != a+y; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;
#define PrintArray(a,x,y) for(auto it = a+x; it != a+y+1; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;

// ***************** End Of Template ********************


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    t += s;
    cout << t;

    return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 20;

LL n, a, b;

int main()
{
    cin >> n;
    for(int i = 1; i <= n / i; i++)
        if(n % i == 0)
        {
            a = i;
            b = n / i;
        }

    cout << a + b - 2 << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative

import Data.List
    (intercalate)
    
import Text.Printf
    (printf)

type Problem
    = (Double, Double, Double)

type Result
    = (Double, Double, Double)

solve :: Problem -> Result

solve (a, b, c)
    = (s, l, h) where
        s = a * h / 2
        l = a + b + len
        h = b * sin rad
        rad = c / 180 * pi
        sub = a - b * cos rad
        len = sqrt $ sub ** 2 + h ** 2

output :: Result -> String

output (s, l, h)
    = intercalate "\n" $ map (printf "%.6f") [s, l, h]
    
input :: IO Problem

input
    = do
        [a, b, c] <- map read <$> words <$> getLine
        return (a, b, c)

main :: IO ()

main
    = putStrLn <$> output =<< solve <$> input

Measured memory_bytes: 4180
// in the name of Allah

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

const ll mod = 1000000007;

inline ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

inline ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

inline ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	set <int> st;
	for(int i=0; i<10000; i++) {
		st.insert(i*i);
	}

	int n, d;
	cin >> n >> d;
	int a[n][d];
	for(int i=0; i<n; i++) {
		for(int j=0; j<d; j++) {
			cin >> a[i][j];
		}
	}
	int cnt = 0;
	for(int i=0; i<n; i++) {
		for(int j=i+1; j<n; j++) {
			ll res = 0;
			for(int k=0; k<d; k++) {
				res += (a[i][k] - a[j][k])*(a[i][k] - a[j][k]);
			}
			if(st.count(res)) cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 768
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    S = input()
    if S.count('A') >= 1 and S.count('B') >= 1:
        print('Yes')
    else:
        print('No')
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 64492
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}

template<class T>
T pow(T x, ll n) {
    T r = 1;
    while (n) {
        if (n & 1) r *= x;
        x *= x;
        n >>= 1;
    }
    return r;
}


template<uint MD>
struct ModInt {
    uint v;
    ModInt() : v(0) {}
    ModInt(ll v) : v(normS(v%MD+MD)) {}
    uint value() const {return v;}
    static uint normS(const uint &x) {return (x<MD)?x:x-MD;};
    static ModInt make(const uint &x) {ModInt m; m.v = x; return m;}
    const ModInt operator+(const ModInt &r) const {return make(normS(v+r.v));}
    const ModInt operator-(const ModInt &r) const {return make(normS(v+normS(MD-r.v)));}
    const ModInt operator*(const ModInt &r) const {return make((ull)v*r.v%MD);}
    ModInt& operator+=(const ModInt &r) {return *this=*this+r;}
    ModInt& operator-=(const ModInt &r) {return *this=*this-r;}
    ModInt& operator*=(const ModInt &r) {return *this=*this*r;}
    static ModInt inv(const ModInt &x) {
        return pow(ModInt(x), MD-2);
    }
};

using Mint = ModInt<TEN(9)+7>;

const int MN = 4040;
Mint g[MN][MN];
Mint C[MN][MN];
Mint fact[2*MN], iFac[2*MN];
void first() {
    fact[0] = 1;
    for (int i = 1; i < 2*MN; i++) {
        fact[i] = fact[i-1]*i;
    }
    for (int i = 0; i < 2*MN; i++) {
        iFac[i] = Mint::inv(fact[i]);
    }
    C[0][0] = 1;
    for (int i = 1; i < MN; i++) {
        C[i][0] = C[i-1][0];
        for (int j = 1; j < MN; j++) {
            C[i][j] = C[i-1][j]+C[i-1][j-1];
        }
    }
}
int main() {
    first();
    int m;
    cin >> m;
    int a[m], b[m];
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
    }
    Mint off = 0;
    for (int i = 0; i < m; i++) {
//        off += C[2*a[i]+2*b[i]][2*b[i]];
        off += fact[2*a[i]+2*b[i]]*iFac[2*a[i]]*iFac[2*b[i]];
    }
    for (int i = 0; i < m; i++) {
        g[2010-a[i]][2010-b[i]] += 1;
    }
    for (int i = 1; i < MN; i++) {
        for (int j = 1; j < MN; j++) {
            g[i][j] += g[i-1][j]+g[i][j-1];
        }
    }
    Mint ans = 0;
    for (int i = 0; i < m; i++) {
        ans += g[2010+a[i]][2010+b[i]];
    }
    ans -= off;
    ans *= Mint::inv(2);
    cout << ans.value() << endl;
    return 0;
}

Measured memory_bytes: 129408
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;

        long[] A;


        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            A = new long[N];
            for (int i = 0; i < A.length; i++) {
                A[i] = sc.nextLong();

            }

        }
        long result = 0;
        long sum = 0;
        for (int i = 0; i < A.length; i++) {
            sum += A[i];
        }
        long average = Math.round((double)sum / N);
        for (int i = 0; i < A.length; i++) {
            result += (average - A[i]) * (average - A[i]);
        }

        System.out.println(result);
    }


}


Measured memory_bytes: 22996
(let* ((n (read)) (line (concatenate 'vector (loop for i from 1 to n collect (read)))) (sum (reduce #'+ line)) (m (read)))
  (dotimes (i m)
	(let ((p (1- (read))) (x (read)))
	  (princ (+ x(- sum (aref line p))))
	  (fresh-line))))


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

int main() {
  double A, B;
  cin >> A >> B;

  double ans = -1;
  for(int i = 1; i <= 1000; i++) {
    if(A == floor(i * 0.08) && B == floor(i * 0.10)) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,x,m = map(int,input().split())

y=x
A=[]
A.append(y)
cnt=1
su=x

for i in range(m):
    y=(y**2)%m
    cnt+=1
    if y in A:
        break
    else:
        A.append(y)
        su+=y

c=A.index(y) #周期のはじめ
d=cnt-(c+1)  #周期のはじめから次の周期のはじめで個数を求める

e=sum(A[:c]) 
#周期に入るまえまでを足しておく


f=sum(A[c:c+(n-c)%d])
    #周期からはみでた最後の部分

g=su-e#1周期分
h=g*((n-c)//d)#かけざん

print(e+h+f)

Measured memory_bytes: 68304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
ll a,b,c,k;
cin >> a >> b >> c>>k;
ll ans = a + b + c - max({a, b, c}) + max({a, b, c}) * (ll)pow(2, k);
cout << ans << endl;
return 0;
}


Measured memory_bytes: 4044
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <set>
#include <cmath>
#include <cassert>
using namespace std;
#define INF 1<<30

vector<int> pos[26];
int dp[200002];

int func(int i){
    if(dp[i] != INF) return dp[i];
    for(int j=0; j<26; j++){
        auto itr = lower_bound(pos[j].begin(), pos[j].end(), i+1);
        if(itr == pos[j].end()){
            dp[i] = 1;
            break;
        }else{
            int k = *itr;
            dp[i] = min(dp[i], 1 + func(k));
        }
    }
    return dp[i];
}

int main(){
    string A;
    cin >> A;
    int N = A.size();

    {
        bool vis[26];
        fill_n(vis, 26, false);
        for(int i=0; i<N; i++)
            vis[A[i]-'a'] = true;
        for(int i=0; i<26; i++)
            if(!vis[i]){
                char ans = 'a'+i;
                cout << ans << endl;
                return 0;
            }
    }

    for(int i=0; i<N; i++)
        pos[A[i]-'a'].push_back(i);

    fill_n(dp, N, INF);
    for(int i=0; i<N; i++)
        dp[i] = func(i);

    string ans = "";
    int cur = -1;
    bool ok = false;
    while(!ok){
        for(int i=0; i<26; i++){
            auto itr = lower_bound(pos[i].begin(), pos[i].end(), cur+1);
            if(itr == pos[i].end()){
                ok = true;
                char c = 'a'+i;
                ans.push_back(c);
                break;
            }
        }
        if(ok) break;

        int i_best;
        int k_best;
        int dp_best = 1<<30;
        for(int i=25; i>=0; i--){
            auto itr = lower_bound(pos[i].begin(), pos[i].end(), cur+1);
            int k = *itr;
            if(dp[k] <= dp_best){
                dp_best = dp[k];
                k_best = k;
                i_best = i;
            }
        }
        cur = k_best;
        char c = 'a'+i_best;
        ans.push_back(c);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2436
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=50;
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 go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline 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;
}

inline ll readll()
{
    ll x=0;int 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 n,a[N+10],b[N+10],f[N+10][N+10][N+10];
bool in[N+10];

void work()
{
    rep(i,0,N) f[0][i][i]=1;
    rep(i,1,N) rep(j,0,N) rep(k,0,N)
    {
        f[i][j][k]=f[i-1][j][k];
        if (in[i]) f[i][j][k]|=f[i][j%i][k];
    }
}

int main()
{
    n=read();
    rep(i,1,n) a[i]=read();
    rep(i,1,n) b[i]=read();
    rep(i,1,N) in[i]=1;
    int ok=1;work();
    rep(i,1,n) ok&=f[N][a[i]][b[i]];
    if (!ok)
    {
        puts("-1");return 0;
    }
    ll ans=0;
    per(p,50,1)
    {
        in[p]=0;work();
        int ok=1;
        rep(i,1,n) ok&=f[N][a[i]][b[i]];
        if (!ok)
        {
            ans+=(1ll<<p);in[p]=1;
        }
    }
    printf("%lld\n",ans);
    return 0;
}
    

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int abs(int n)
{
	if (n < 0) return -n;
	else return n;
}

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

	if (abs(x - a) > abs(x - b)) cout << "B" << endl;
	else cout << "A" << endl;
}


Measured memory_bytes: 256
// AOJ Volume 0 Problem 0001

#include <stdio.h>

int main(void)
{
    int i;
    int height;
    int height_1st, height_2nd, height_3rd;
    
    height_1st = height_2nd = height_3rd = 0;
    
    for (i = 0; i < 10; i++){
        scanf("%d", &height);
        if (height > height_1st){
            height_3rd = height_2nd;
            height_2nd = height_1st;
            height_1st = height;
        }
        else if (height > height_2nd){
            height_3rd = height_2nd;
            height_2nd = height;
        }
        else if (height > height_3rd){
            height_3rd = height;
        }
    }
    
    printf("%d\n%d\n%d\n", height_1st, height_2nd, height_3rd);
    
    return (0);
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

//const int maxn=

int main()
{

	int a;
	
	scanf("%d",&a);
	
	printf("%d\n",a+a*a+a*a*a);
	
	return 0;
}


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

using namespace std;

#define ll long long
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef set<int> si;
typedef set<vi> svi;
typedef set<ll> sll;
typedef set<vll> svll;
typedef set<pii> spii;
typedef set<vpii> svpii;
typedef set<pll> spll;
typedef set<vpll> svpll;
typedef vector<si> vsi;
typedef vector<sll> vsll;
typedef vector<spii> vspii;
typedef vector<spll> vspll;
#define ft first
#define sc second
#define pb push_back
#define ins insert
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define sortarr(a,n) sort(a,a+n)
#define tt ll tc; cin >> tc; while(tc--)
#define rep(var,start,end,interval) for(ll var=start;(interval>0 and var<end) or (interval<0 and var>end);var+=interval)
#define each(x,v) for(auto x : v)
#define takearr0(a,n) rep(z,0,n,1) cin >> a[z];
#define takearr1(a,n) rep(z,1,n+1,1) cin >> a[z];

const ll max_n = 2e5 + 5;

ll n,d;

int main()
{
	io;
	cin >> n >> d;
	ll x,y,cntr = 0;;
	rep(i,0,n,1)
	{
		cin >> x >> y;
		long double dist = sqrt((long double)((x*x)+(y*y)));
		if((dist-d) <= (long double)0)
			++cntr;
	}
	cout << cntr << endl;
	return 0;
}

Measured memory_bytes: 3696
#include<iostream>
using namespace std;
#include<stdio.h>
#include<string>

int main(){
    
    string W, T;
    int n = 0;
    cin >> W;
    while(1){
        cin >> T;
        if ( T == "END_OF_TEXT" ) break;
        for ( int i = 0; i < T.size(); i++){
           if ( 65 <= T[i] && T[i] <= 90 ) T[i] += 32;
        }
        if ( T == W ) n++;
    }
    printf("%d\n", n);
    
    return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s,t; cin>>s>>t;
  vll a(26,-1);
  ll n=s.size();
  rep(i,n){
    ll j=t[i]-'a', k=s[i]-'a';
    if(a[j]!=-1){
      if(a[j]!=k){
        cout<<"No"<<endl;
        return 0;
      }
    }else{
      a[j]=k;
    }
  }
  a=vll(26,-1);
  rep(i,n){
    ll j=s[i]-'a', k=t[i]-'a';
    if(a[j]!=-1){
      if(a[j]!=k){
        cout<<"No"<<endl;
        return 0;
      }
    }else{
      a[j]=k;
    }
  }
  cout<<"Yes"<<endl;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line


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

//const ll mod = 1e9+7;
const ll mod = 998244353;
int main()
{
	ll n, k;
	cin >> n >> k;
	vector<int> l(k), r(k);
	rep(i,k) cin >> l[i] >> r[i];

	vector<ll> dp(200005,0);
	dp[1] = 1;
	dp[0] = 0;

	vector<ll> sum(200005,0);
	sum[0] = 0;
	sum[1] = 1;

	for(int i = 2; i <= n; i++){
		// dp[i] を更新する
		rep(j,k){
			ll right = i - l[j];
			if(right < 0) right = 0;
			ll left = i - r[j] - 1;
			if(left < 0) left = 0;
			ll tmp = sum[right] - sum[left];
			if(tmp < 0) tmp += mod;

			dp[i] += tmp;
			dp[i] %= mod;
		}
		sum[i] += sum[i-1] + dp[i];
		sum[i] %= mod;
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 6404
// https://atcoder.jp/contests/abc018/tasks/abc018_4

#include <bits/stdc++.h>
using namespace std;
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e18;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
// int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int main() {

  int N, K = 0;
  cin >> N >> K;
  vector<int> p(N, 0);

  
  // cout << N;
  // cin >> p[0];

  REP(i, N){
    cin >> p[i];
  }

  vector<double> kitaiti(N, 0);
  REP(i, N){
    int sum = (1 + p[i])  * p[i] / 2.0;
    kitaiti[i] = (double)sum / (double)p[i];
    // cout << kitaiti[i] << endl;
  }
  vector<double> sumkitaiti(N-K+1, 0);
  REP(i, K){
    sumkitaiti[0] += kitaiti[i]; 
  }

  REP1(i, N-K+1){
    sumkitaiti[i] = sumkitaiti[i-1] - kitaiti[i-1] + kitaiti[i + K -1];
  }
  
  sort(sumkitaiti.begin(), sumkitaiti.end(), greater<double>());

  printf("%.10f\n", sumkitaiti[0]);

  // cout << ans << endl;

  return 0;



}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std ;
int main ()
{
int a,b,c,d,x,y;
cin>>a>>b>>c>>d;
x=c-a;
y=d-b;
cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x;
}
//{
//    int a,b,c,d,x,y;
//    cin>>a>>b>>c>>d;
//    x=c
//}


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

int main() {
  int n;
  cin >> n;
  long long max;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if (i == 0) max = a;
    else if (max >= a) sum += max-a;
    else max = a;
  }
  cout << sum << endl;
}

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

int main() {
    int h, n;
    vector<int> numbs;
    cin >> h >> n;
    int sum = 0;
    int numb;
    for(int i = 0; i < n; i++) {
        cin >> numb;
        numbs.push_back(numb);
        sum+=numb;
    }

    
    if(sum >= h) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 892