akhauriyash/Code-Regression huggingface dataset:
using System;
class aoj
{
    static void Main()
    {
        int all = 0;
        while (true)
        {
            string a = Console.ReadLine();
            if (String.IsNullOrEmpty(a)) break;
            if (a.Length == 1)
                all++;
            else
            {
                if (a.Length % 2 == 0)
                {
                    int c = a.Length;
                    string e = a.Substring((c / 2), (c / 2));
                    string d = a.Substring(0, (c / 2));
                    char[] f = e.ToCharArray();
                    Array.Reverse(f);
                    string h = new string(f);
                    if (d == h)
                        all++;
                }
                else
                {
                    int c = a.Length;
                    int g = (c - 1) / 2;
                    string d = a.Substring(0, g);
                    string e = a.Substring(g + 1, g);
                    char[] f = e.ToCharArray();
                    Array.Reverse(f);
                    string h = new string(f);
                    if (d == h)
                        all++;
                }
            }
        }
        Console.WriteLine(all);
    }
}

Measured memory_bytes: 9044
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		PrintWriter pw=new PrintWriter(System.out);
		Scanner sc=new Scanner(System.in);
		
		
		int n=sc.nextInt();
		int m=sc.nextInt();
		
		int[] L=new int[m];
		
		for(int i=0;i<m;i++){
			L[i]=sc.nextInt();
		}
		int gap=0;
		for(int i=0;i<m-1;i++){
			if(gap<Math.abs(L[i]-L[i+1])){
				gap=Math.abs(L[i]-L[i+1]);
			}
		}

		if(gap<Math.abs(L[0]-(1-L[0]))){
			gap=Math.abs(L[0]-(1-L[0]));
		}
		if(gap<Math.abs(L[m-1]-(n+1+n-L[m-1]))){
			gap=Math.abs(L[m-1]-(n+1+n-L[m-1]));
		}
		if((gap-1)%2==0){
			pw.println((gap-1)/2);
		}
		if((gap-1)%2==1){
			pw.println((gap-1-1)/2+1);
		}
		
		sc.close();
		pw.close();
	}

}

Measured memory_bytes: 63064
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a;
    cin >> n;
    vector<lli> v;
    for (lli i = 0; i < n; i++) {
        cin >> a;
        v.pb(a);
    }

    lli money = 1000, stocks = 0;

    for (lli i = 0; i < n; i++) {
        if (v[i] < v[i + 1]) {
            lli no = money / v[i];
            money += (v[i + 1] - v[i]) * no;
        }
    }

    cout << money << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h> 
using namespace std; 
int main()
{
    int a,b;
    cin >> a>>b;
    if(a==b)
    cout << a+b;
    else if(a>b)
    cout << 2*a-1;
    else
    cout << 2*b-1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

std::vector<int> edges[2000];

int dfs(int node,int parent,int depth){
    if (depth == 0) return 1;
    int cnt = 1;
    for (int child: edges[node]){
        if (child != parent) {
            cnt += dfs(child, node, depth - 1);
        }
    }
    return cnt;
}

int main(){
    int n, k;
    cin >> n >> k;
    REP(i,n-1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    int c = 0;
    REP(i,n) {
        for (int j: edges[i]) {
            c = max(c, dfs(j,i,k/2) + dfs(i,j,(k-1)/2));
        }
    }
    
    cout << n - c << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
#define allsort(X) sort(X.begin(),X.end())

typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;






ll i,j,k;


int main(){
    ll N;
    cin>>N;
    V A(N),B(N);
    rep(i,N)cin>>A[i]>>B[i];
    allsort(A);
    allsort(B);
    if(N%2==1)cout<<B[(N-1)/2]-A[(N-1)/2]+1<<endl;
    else{
        cout<<(B[N/2-1]+B[N/2]-A[N/2]-A[N/2-1])+1<<endl;

    }
}

Measured memory_bytes: 6440
import math
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

l = list(range(1,n+1))
a = 0
b = 0
x = itertools.permutations(l)
for i, e in enumerate(x,1):
    if p == e:
        a = i
    if q == e:
        b = i

print(abs(a-b))


Measured memory_bytes: 3060
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    int N;cin >> N;
    vector<string> retu(N);
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    for(int i = 0;i<N;i++) sort(retu.at(i).begin(),retu.at(i).end());
    string ans = "";
    for(int i = 0;i<26;i++){
        int minicount = 100;
        char C = i+97;
        for(int j = 0;j<N;j++){
            string now = retu.at(j);
            minicount = min(minicount,(int)count(now.begin(),now.end(),C));
        }
        for(int k = 0;k<minicount;k++) ans += C;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//=template==================================================================//
// include
#include <vector>
#include <list>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

// namespace
using namespace std;

// define
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(i,n) FOR(i,0,n)
#define MIN_V(v) *min_element(v.begin(), v.end())
#define MAX_V(v) *max_element(v.begin(), v.end())

// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef long long LL;
typedef unsigned long long ULL;

// conversion
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
inline int countChar(string s, char c) {int cnt,i; cnt=0; REP (i,s.size()) {if (s[i]==c) cnt++;} return cnt;}
template<class T> inline string toString(T x) {ostringstream sout; sout<<x; return sout.str();}
//===========================================================================//

//=function prototype========================================================//

//===========================================================================//

//=variables=================================================================//

//===========================================================================//
int main(void)
{
  // Scan begin.
  int n, k, i;
  VI a;
  cin >> n >> k;
  REP (i, n) {
    int temp;
    cin >> temp;
    a.push_back(temp);
  }
  // Scan done.

  // Code begin.
  cout << ((int) (ceil(((float)n-k)/(k-1)) + 1)) << endl;
  // Code done.

  return 0;
}

//=functions=================================================================//

//===========================================================================//

Measured memory_bytes: 892
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	l = readline() |> parseInt
	n = 0
	while 2^n<=l
		n+=1
	end
	a = Tuple{Int,Int,Int}[]
	for i in 1:n-1
		push!(a,(i,i+1,2^(i-1)))
		push!(a,(i,i+1,0))
	end
	for i in 1:n-1
		if 2^(n-1)+2^(n-i-1)<=l
			push!(a,(n-i,n,l-2^(n-i-1)))
			l -= 2^(n-i-1)
		end
	end
	m = length(a)
	println(n," ", m)
	for i in 1:m
		println(a[i][1]," ",a[i][2]," ",a[i][3])
	end
end

main()

Measured memory_bytes: 111424
import sys
read = sys.stdin.readline


def solve():
    N = int(read())
    P = [0] * N
    for i in range(N):
        P[i] = int(read())
    
    dp = [0] * (N + 1)
    ans = 0
    for i in range(N):
        p = P[i]
        dp[p] = dp[p - 1] + 1
        ans = max(ans, dp[p])
    print(N - ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 43484
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])


Measured memory_bytes: 13980
n = int(input())
s = input()
e = [0]
w = [0]
a = []

for i in range(n):
    if s[i] == 'W':
        w.append(w[i] + 1)
        e.append(e[i])
    else:
        e.append(e[i] + 1)
        w.append(w[i])

ans = n
for i in range(n):
    ans = min(ans, ((w[i] + e[n] - e[i+1])))
print(ans)


Measured memory_bytes: 17740
#include<cstdio>
int d[35][35],a[35][3];
int main()
{
	int n,c;scanf("%d%d",&n,&c);
	for(int i=1;i<=c;i++)
	for(int j=1;j<=c;j++) scanf("%d",&d[i][j]);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	{
		int x;scanf("%d",&x);
		a[x][(i+j)%3]++;
	}
	int ans=0x3f3f3f3f;
	for(int i=1;i<=c;i++)
	for(int j=1;j<=c;j++)
	for(int k=1;k<=c;k++)
	{
		if(i==j||j==k||i==k) continue;
		int s=0;
		for(int ii=1;ii<=c;ii++) s+=d[ii][i]*a[ii][0];
		for(int ii=1;ii<=c;ii++) s+=d[ii][j]*a[ii][1];
		for(int ii=1;ii<=c;ii++) s+=d[ii][k]*a[ii][2];
		if(ans>s) ans=s;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second

#define pb push_back
#define es erase
#define in insert

#define pii pair<ll, ll>
#define ll long long
#define lb long double

#define ioss                     \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);

#define m_p(i, j) make_pair(i, j)
#define mem(a, x) memset(a, x, sizeof(a))
#define endl "\n"
#define all(x) x.begin(), x.end()

const ll mod = 1e9 + 7;
const ll maxn = 6e5 + 7;
ll n, fa[maxn], m, num[maxn];
ll ifind(ll x)
{
    if (x == fa[x])
        return x;
    return fa[x] = ifind(fa[x]);
}
void cmb(ll x, ll y)
{
    ll fx = ifind(x), fy = ifind(y);
    if (fx != fy) {
        fa[fx] = fy;
        num[fy] += num[fx];
    }
}
int main()
{
    cin >> n >> m;
    for (ll i = 1; i <= n; i++) {
        fa[i] = i;
        num[i] = 1;
    }
    for (ll i = 1; i <= m; i++) {
        ll x, y;
        cin >> x >> y;
        cmb(x, y);
    }
    cout << *max_element(num + 1, num + 1 + n) << endl;
}


Measured memory_bytes: 6760
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main(){

    ll n;
    cin >> n;

    n--;

    vector<ll> timeTaken(n), initialDeparture(n), regualarity(n); 


    for (ll i = 0; i < n; i++){
        cin >> timeTaken[i] >> initialDeparture[i] >> regualarity[i];
    }  
    

    for (ll i = 0; i < n; i++){
        ll t = 0;

        for (ll j = i; j < n; j++){

            if (t < initialDeparture[j]){
                t = initialDeparture[j];
            }

            if (t % regualarity[j] != 0){
                t = t + regualarity[j] - (t % regualarity[j]);
            } 

            t += timeTaken[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;

    return 0;
}



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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(auto& i : v) cin >> i;

    vector<int> tag(n);
    REP(i, n-1){
        tag[i+1] = tag[i] + (v[i] < v[i+1] ? 0 : 1);
    }

    set<int> st;
    REP(i, k){
        st.insert(v[i]);
    }

    int ans = 0, origin = 0;

    REP(i, n - k + 1){
        int mi = *(st.begin()), ma = *(st.rbegin());

        if(tag[i] == tag[i+k-1]) origin = 1;

        if(i == 0){
            ans++;
        }
        if(i < n - k){
            if((origin == 0 || tag[i+1] != tag[i+k]) && (mi != v[i] || ma > v[i+k])){
                ans++;
            }
        }

        st.erase(v[i]);
        st.insert(v[i+k]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>

#define swap(a, b) {char tmp = a; a = b; b = tmp;}

int main(void)
{
	char str[128];
	int num = 0;
	
	while (gets(str) != NULL){
		int i;
		for (i = 0; str[i] != 0; i++){
			int n = 0;
			while ('0' <= str[i] && str[i] <= '9'){
				n *= 10;
				n += str[i] - '0';
				i++;
			}
			num += n;
			if (!str[i])i--;
		}
	}
	printf("%d\n", num);
	
	return 0;
}

Measured memory_bytes: 524
import java.util.Scanner;

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

		String N = sc.next();
		char[] S = N.toCharArray();

		if(S[2] == S[3] && S[4] == S[5]) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 21844
program MAIN
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,i,ans,b
    integer(int64),allocatable:: a(:)


    read*, n
    allocate(a(n))
    read*, a(:)

    do i=2,n
        a(i)=a(i-1)+a(i)
    end do


    ans = a(n)-2*a(1)

    do i=2,n-1
        b = a(n)-a(i)
        ans = min(ans, abs(a(i)-b))
    end do

    print'(i0)', ans
end program MAIN

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;


void solve()
{
    ld a,b,h,m,c,t,th,tm;
    cin >> a >> b >> h >> m;

    th = (1.0*h + (m/60.0) )/6;
    tm = (1.0*m)/30;
    t = abs(th-tm);
    // cout << th*180 << " "<< tm*180  << " " << t*180 << endl;

    c = sqrt ( a*a + b*b - 2*a*b*cos(pi*t) );
    sp(20);
    cout << c << endl;

}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 4172
/*
Author : Hocky Yudhiono
Min 26 Jan 2020 07:06:20  WIB

1. You can sort the query if offline!
2. Don't bring the dp remaining state when dfsing on DP on Tree.
3. Try to reverse (Think from the back) if you stuck.
4. Be careful when submitting Div. 2 D-F, dont waste it on stupid WAs.
5. Try to reduce a problem
*/

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
//If the time limit is strict, try not to use long double

#define popf pop_front
#define pf push_front
#define popb pop_back
#define mp make_pair
#define pb push_back
#define remove erase
#define fi first
#define se second

//Remember to undefine if the problem is interactive
#define endl '\n'
#define DEBUG(X) cout << ">>> DEBUG(" << __LINE__ << ") " << #X << " = " << (X) << endl

const double eps = 1e-9;
const int INFMEM = 63;
const int INF = 1061109567;
const LL LINF = 4557430888798830399LL;
const double DINF = numeric_limits<double>::infinity();
const LL MOD = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1};
const int dy[8] = {0,1,0,-1,1,-1,1,-1};
const double PI = 3.141592653589793;

inline void open(string a){
    freopen((a+".in").c_str(),"r",stdin);
    freopen((a+".out").c_str(),"w",stdout);
}

inline void fasterios(){
    //Do not use if interactive
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}
LL solve(LL n){
    if(n == 1) return 1;
    return 1+2*solve(n/2);
} 

int main(){
    LL n; cin >> n;
    cout << solve(n) << endl;   
    return 0;
}

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

typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; typedef long double ld;

int main() { 

int n;
cin >> n;
ll t;
ld ans = 1;
for (int i = 0; i < n; i++)
{
    cin >> t;
    if (ans != -1)
       ans *= t;
    if (ans > 1000000000000000000 || ans < 0)
       ans = -1;
    if (t == 0)
       ans = 0;
}
cout << (ll)ans;
return 0;
}

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

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      long long int data[n];
      long long int ans=0;
      for(int i=0;i<n;i++)
	{
	  cin>>data[i];
	  ans+=data[i];
	}
      for(long long int i=0;i<(1<<n);i++)
	{
	  //	  cout<<i<<endl;
	  long long int sum[2]={0,0};
	  for(int j=0;j<n;j++)
	    {
	      //	      cout<<(1<<j)<<endl;
	      if((i&(1<<j))==0)
		sum[0]+=data[j];
	      else
		sum[1]+=data[j];
	    }
	  //	  cout<<sum[0]<<" "<<sum[1]<<endl;
	  ans=min(ans,abs(sum[0]-sum[1]));
	  if(ans==0)
	    break;
	}


      cout<<ans<<endl;
    }

}

Measured memory_bytes: 1164
from fractions import gcd
from math import sqrt
a,b,c=map(int,input().split())
g=gcd(a,b); s=int(sqrt(g)); ans=set()
for i in range(1,min(a,b)+1):
    if a%i==0:
        if b%i==0:
            ans.add(i)
ans=list(ans)
ans.sort(reverse=True)
print(ans[c-1])

Measured memory_bytes: 65132
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define se second
#define fi first
#define rep(i, l, r) for (ll i = (ll)(l); i < (ll)(r); i++)
#define repr(i, r, l) for (ll i = (ll)(r); i > (ll)(l); i--)
#define print(v) for (const auto itr : v){cout << itr << ' ';} cout << endl;
#define all(p) p.begin(), p.end()
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 998244353
#define endl "\n"
#define inf 1e18
using namespace std;
const ll INF = 1e18L + 5;
const ll maxn = 20005;
ll ceel(ll a, ll b){if (a % b == 0)return a / b;return a / b + 1;}
ll modneg(ll a,ll m){a = a % m;if(a<0)a=a+m;return a;}
ll powermod(ll x, unsigned ll y, ll p){ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); };


int main() 
{

fastIO;
ll test,a,b,c,d,i,j;
string s;
cin>>s;
a=0;
for(auto it:s)
{
    a+=it-'0';
}
if(a%9==0)
    cout<<"Yes\n";
else
    cout<<"No\n";
return 0;
}

Measured memory_bytes: 3772
def next(ll):
    n = len(ll)
    chk = False

    for i in range(n - 1, -1, -1):

        i_num = int(ll[i])

        if i_num == 9:
            continue

        if i > 0:
            # print (ll)
            if i_num <= int(ll[i - 1]):
                if i == n - 1:
                    return str(int(ll) + 1)
                else:
                    if i_num <= int(ll[i + 1]):
                        chk = True
                        break
                        # return ll[:i] + str(i_num + 1) + ll[i + 1:]
        else:
            if i < n - 1:
                if i_num <= int(ll[i + 1]):
                    chk = True
                        # return str(i_num + 1) + ll[i + 1:]
            else:
                chk = True

    if not chk:
        st = '1' + '0' * n
        return st

    i_num = int(ll[i])
    st = ll[:i]

    # print (i, i_num)

    for j in range(n - i):
        st += str(max(i_num + 1 - j, 0))

    return st

# print (next('1012'))

k = int(input())

num = '1'
c = 1

while c < k:
    c += 1
    num = next(num)

print (num)




            


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int a = -1, b = -1;
    rrep(i, 1, s.size()) if (s[i] == s[i - 1]) a = i, b = i + 1; //1index
    rrep(i, 2, s.size()) if (s[i] == s[i - 2]) a = i - 1, b = i + 1;
    cout << a << " " << b << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
int n;
cin >> n;
int a[n];
for(int i=0;i<n;i++){
   cin >> a[i];
}
int ans = 0,now=a[0],che=0;
for(int i=1;i<n;i++){
   if(now>=a[i]){che++;now=a[i];}
   else{
      ans=max(ans,che);
      now=a[i];
      che=0;
      }
      ans = max(ans,che);
}
cout << ans << endl;
}





Measured memory_bytes: 640
jpy = []
btc = []
for _ in range(int(input())):
    s = [x for x in input().split()]
    if s[1] == "JPY":
        jpy.append(float(s[0]))
    else:
        btc.append(float(s[0]))
print(sum(jpy) + sum(btc)*380000)

Measured memory_bytes: 3060
#include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
     
    int main()
    {
    	int n;
    	cin>>n;
      	vector<int> p(n);
    	for (int i = 0; i < n; i++)
    	{
    		cin>>p[i];
    	}
    	int cnt=0;
    	for(int i=0;i<n;i++)
    	{
    		if(p[i]!=i+1)cnt++;
    	}
    	if(cnt==2||cnt==0)cout<<"YES"<<endl;
    	else cout<<"NO"<<endl;
    	return 0;
    }

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

using namespace std;

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

	if (A > 8 || B > 8) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
}


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

namespace IO
{
char gc()
{
#ifdef FREAD
	static char buf[1<<21], *P1 = buf, *P2 = buf;
	if(P1 == P2)
	{
		P1 = buf;
		P2 = buf + fread(buf, 1, 1<<21, stdin);
		if(P1 == P2) return EOF;
	}
	return *(P1++);
#else
	return getchar();
#endif
}
template<typename Tp> bool get1(Tp &x)
{
	bool neg = 0;
	char c = gc();
	while( c != EOF && (c < '0' || c > '9') && c != '-' ) c = gc();
	if(c == '-') c = gc(), neg = 1;
	if(c == EOF) return false;
	x = 0;
	for(; c>='0' && c<='9'; c = gc()) x = x*10 + c - '0';
	if(neg) x = -x;
	return true;
}
template<typename Tp> void printendl(Tp x)
{
	if(x<0)putchar('-'),x=-x;
	static short a[40], sz;
	sz = 0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
	puts("");
}
} // namespace IO
using IO::get1;
using IO::printendl;
#define get2(x,y) get1(x) && get1(y)
#define get3(x,y,z) get2(x,y) && get1(z)
#define get4(x,y,z,w) get3(x,y,z) && get1(w)
#define pb push_back
#define mp std::make_pair
#define ff first
#define ss second
typedef long long LL;
typedef unsigned long long uLL;
typedef std::pair<int,int> pii;
const int inf = 0x3f3f3f3f;
const LL Linf = 1ll<<61;

const int maxn = 2111;
int mod, n;
inline void add(int &x, int y) { x += y; if(x >= mod) x -= mod; }
int dp[maxn*3][maxn];
int main()
{
	get2(n, mod);
	dp[0][0] = 1;
	for(int i=1; i<=n+n+n; i++) for(int j=0; j<=n; j++)
	{
		dp[i][j] = dp[i-1][j];
		if(i > 1 && j) add(dp[i][j], 1ll * dp[i-2][j-1] * (i-1) % mod);
		if(i > 2 && j) add(dp[i][j], 1ll * dp[i-3][j-1] * (i-1) * (i-2) % mod);
	}
	int ans = 0;
	for(int i=0; i<=n; i++) add(ans, dp[n+n+n][i]);
	printendl(ans);
	return 0;
}

Measured memory_bytes: 51456
#include<iostream>
using namespace std;
int main(){
        int r,g,b,sum=0;
        cin>>r>>g>>b;
        sum=r*100+g*10+b;
        if((r*100+g*10+b)%4==0)cout<<"YES"<<endl;
        else{
                cout<<"NO"<<endl;
        }
}

                                                                            

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

int main() {
    Int n;
    cin >> n;
    Int ans = n * (n-1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n, a, s=1;
ll f(ll p, ll q) {
	if(q==0) return p;
	f(q, p%q);
}
int main() {
	cin>>n;
	while(n--) {
		cin>>a;
		s *= a/f(s,a);
	}
	cout<<s;
	return 0;
}


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

int main()
{
    ll n;
    cin >> n;
    ll ans[n];
    rep(i, n)
    {
        ll a;
        cin >> a;
        ans[a - 1] = i + 1;
    }

    rep(i, n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 4304
s = list(input())
num = [0]*4
num[0] = int(s[0])
for i in range(1,4):
  num[i] = [0]*2
  num[i][0] = int(s[i])
  num[i][1] = -(int(s[i]))
  
patern = [0] * 8

p = ['+', '-']

count = 0
for i in range(2):
  for j in range(2):
    for k in range(2):
      temp = num[0] + num[1][i] + num[2][j] + num[3][k]
      patern[count] = [p[i], p[j], p[k]]
      if temp == 7:
        ans_count = count
      count += 1

print(s[0] + patern[ans_count][0] + s[1] + patern[ans_count][1] + s[2] + patern[ans_count][2] + s[3] + '=7')
      

Measured memory_bytes: 38384
def abc170_c_0():
    def solve():
        x, n = map(int, input().split(' '))
        if n == 0:
            return x

        p = list(map(int, input().split(' ')))

        search_range_min = min(min(p), x) - 1
        search_range_max = max(max(p), x) + 1
        search_values = [i for i in range(search_range_min, search_range_max + 1) if i not in p]

        check_dict = {}

        for i in search_values:
            # 絶対値が小さいものを調べるので差の絶対値を格納
            check_dict[i] = abs(x - i)

        return min(check_dict, key=check_dict.get)
    print(solve())

def abc170_c_1():
    """
    もうちょいコンパクトに書いてみる
    """
    def solve():
        x, n = map(int, input().split(' '))
        if n == 0:
            return x

        p = list(map(int, input().split(' ')))

        search_range_min = min(min(p), x) - 1
        search_range_max = max(max(p), x) + 1
        search_values = [i for i in range(search_range_min, search_range_max + 1) if i not in p]

        # min関数のkeyにxとの差の絶対値を直接渡してその値の最小値を取得してしまう。
        ans = min(search_values, key=lambda a: (abs(a - x), x))

        # こっちはたぶん絶対値の差が同じ時にリストの先にあるほうをとってしまうので結果バグっている気がする
        # ans = min(search_values, key=lambda a: abs(a - x))

        return ans

    print(solve())

if __name__ == '__main__':
    abc170_c_1()


Measured memory_bytes: 9236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

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

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }

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

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int x = sc.nextInt();
    int n = sc.nextInt();
    if (n == 0) {
      System.out.println(x);
      return;
    }
    int[] p = sc.nextIntArray(n);
    Set<Integer> set = new HashSet<>();
    for (int pi: p) set.add(pi);
    for (int d = 0; d <= 101; d++) {
      if (!set.contains(x - d)) {
        System.out.println(x - d);
        return;
      } else if (!set.contains(x + d)) {
        System.out.println(x + d);
        return;
      }
    }
  }
}

Measured memory_bytes: 32708
from itertools import permutations
N, M = map(int, input().split())
table = [[] for i in range(N)]
for i in range(M):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  table[a].append(b)
  table[b].append(a)
  
numbers = [i for i in range(1,N)]
P = list(permutations(numbers,N-1))
ans = 0

for p in P:
  if p[0] in table[0]:
    for i in range(N-2):
      if p[i+1] not in table[p[i]]:
        break
    else:
      ans += 1  
print(ans)

Measured memory_bytes: 3572
#include <stdio.h>
  
int main(void){
  int n,i,j,num;
  char egara;
  int array[4][13];
  
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      array[i][j]=0;
    }
  }
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c %d", &egara,&num);
    switch(egara){
      case 'S' : array[0][num-1]=1; break;
      case 'H' : array[1][num-1]=1; break;
      case 'C' : array[2][num-1]=1; break;
      case 'D' : array[3][num-1]=1; break;
    }
  }
  
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if(array[i][j]==0){
        switch(i){
          case 0 : printf("S %d\n",j+1); break;
          case 1 : printf("H %d\n",j+1); break;
          case 2 : printf("C %d\n",j+1); break;
          case 3 : printf("D %d\n",j+1); break;
        }
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 596
import java.util.*;
import java.math.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long l = sc.nextLong();
        double d = sc.nextDouble();
        sc.close();
        BigDecimal b1 = BigDecimal.valueOf(l);
        BigDecimal b2 = BigDecimal.valueOf(d);
        BigDecimal b3 = b2.multiply(b1);
        String s = b3.toPlainString();
        char[] c = s.toCharArray();
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < c.length; i++){
            if(c[i] != '.'){
                sb.append(c[i]);
            }else{
                break;
            }
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 37520
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();
    std::io::stdin()
        .read_line(&mut line)
        .map_err(|err| format!("{:?}", err))?;

    let xs = line.trim().split_whitespace();
    let mut result = Vec::new();

    for x in xs {
        let ans = x.parse::<T>().map_err(|_| format!("{}", "parse error"))?;
        result.push(ans);
    }
    Ok(result)
}

fn main() {
    // let (a, b) = read_parameters::<isize>().map(|xs| (xs[0], xs[1])).unwrap();
    loop {
        let (a, b) = read_parameters::<isize>().map(|xs| (xs[0], xs[1])).unwrap();
        if a == 0 && b == 0 {
            break;
        }
        if a < b {
            println!("{} {}", a, b);
        } else {
            println!("{} {}", b, a);
        }
    }
}



Measured memory_bytes: 5028
#include <iostream>
#include <cmath>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
typedef unsigned long long ul;
typedef long long ll;
typedef pair<int, int> PAIR;

int main() {
	int N;
	cin >> N;
	multimap<int, int> deadstart_job;

	PAIR jobs[N];
	int deadstart[N];
	REP(i, N) {
		int A, B;
		cin >> A >> B;
		jobs[i] = PAIR(A, B);
		deadstart[i] = B - A;
		deadstart_job.insert(make_pair(B, i));
	}

	int current_time = 0;
	for (auto itr = deadstart_job.begin(); itr != deadstart_job.end(); ++itr) {
		int deadstart_time = deadstart[itr->second];
		int job_length = jobs[itr->second].first;
		if (current_time > deadstart_time) {
			cout << "No";
			return 0;
		} else {
			current_time += job_length;
		}
	}
	cout << "Yes";

	return 0;
}


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

int main(){
    int N;
    int num[2] = {0};
    cin >> N;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        num[a%2]++;
    }
    int ans = 0;
    while(num[0] && num[1]){
        if(num[0] > 1){
            ans += num[0] - 1;
            num[0] = 1;
        }else if(num[1] >= 2){
            num[0]++;
            num[1] -= 2;
            ans++;
        }else if(num[0]){
            ans++;
            num[0]--;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3120
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int x;
    cin>>x;
    int h=0;
    int c=0;
    int m[n];
    for(int i=0;i<n;i++)
    {
        cin>>m[i];
        c+=m[i];   
    }
    h=m[0];
    for(int i=0;i<n;i++)
    {
       h=min(m[i],h);        
    }
    cout<<n+(x-c)/h;
     return 0;
}
    

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define er erase
#define bg begin()
#define ed end()
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define enter cout << "\n"
#define space cout << " "
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (n); ++i)
#define fj(st,n) for (int j = (st); j <= (n); ++j)
#define fk(st,n) for (int k = (st); k <= (n); ++k)
#define fq(st,n) for (int q = (st); q <= (n); ++q)
#define fw(st,n) for (int w = (st); w <= (n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (n); ++(i))
#define ei(st,n) for (int i = (st); i >= (n); --i)
#define ej(st,n) for (int j = (st); j >= (n); --j)
#define ek(st,n) for (int k = (st); k >= (n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (n); --(i))
#define ri(st,n) for (int i = (st); i < (n); ++i)
#define rj(st,n) for (int j = (st); j < (n); ++j)
#define rk(st,n) for (int k = (st); k < (n); ++k)
#define rq(st,n) for (int q = (st); q < (n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = (int)1e9;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1000000007;
const int maxn = (int) 1e5 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

int n, a[maxn], ans;

int main()
{
//    fin("t.in");
    sync;
    cin >> n;
    fi(1, n) {
        cin >> a[i];
    }
    ans = 0;
    fi(1, n) {
        if (a[i] > i && a[a[i]] == i)
            ++ans;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n;
  int64 m;
  scanf("%d%lld", &n, &m);
  vector<int> a(n), f(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; ++i) {
    scanf("%d", &f[i]);
  }
  sort(f.begin(), f.end(), greater<int>());
  int64 low = 0, high = 1LL << 60;
  while (low != high) {
    int64 mid = (low + high) / 2;
    int64 sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += max(0LL, a[i] - mid / f[i]);
    }
    if (sum > m) {
      low = mid + 1;
    } else {
      high = mid;
    }
  }
  printf("%lld\n", high);
  return 0;
}


Measured memory_bytes: 1792
import math
a,b=map(int,input().split())
c=[]
for i in range(a):
    c.append(list(map(int,input().split())))

ans=0
for i in range(a):
    n=math.sqrt(c[i][0]**2+c[i][1]**2)
    if n<=b:
        ans+=1
print(ans)

Measured memory_bytes: 45460
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int selectionSort(vector<int> &a, int n)
{
	int count = 0;
	for (int i = 0; i < n; i++)
	{
		int minj = i;
		for (int j = i; j < n; j++)
		{
			if (a[j] < a[minj])
			{
				minj = j;
			}
		}
		swap(a[i], a[minj]);
		if (i != minj)
			count++;
	}
	return count;
}

int main()
{
	int N;
	cin >> N;
	cin.ignore();

	string A;
	getline(cin, A);

	vector<int> va;

	istringstream iss(A);
	while (!iss.eof())
	{
		int t;
		iss >> t;
		iss.ignore();
		va.push_back(t);
	}

	int count = selectionSort(va, N);
	ostringstream oss;
	for (int i = 0; i < va.size() - 1; ++i)
	{
		oss << va[i] << " ";
	}
	oss << va[va.size() - 1] << endl;

	cout << oss.str();
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	set<string> st;
	for(int i=0; i<n; ++i){
		string s;
		cin >> s;
		st.insert(s);
	}
	cout << len(st) << endl;
}


Measured memory_bytes: 19204
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		execute21_1();
	}

	private static void execute21_2() {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int[][] a = new int[m][2];
			int[] nf = new int[n];
			
			int ans=99999999;
			
			for(int i=0;i<m;i++) {
				int aa = sc.nextInt();
				int bb = sc.nextInt();
				
			}
		}
	}

	private static void execute21_1() {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			long[] a = new long[N];
			for (int i = 0; i < N; i++) {
				a[i] = sc.nextLong();
			}

			long ans = 0;
			long sum=a[N-1];

			for (int i = N - 2; i >= 0; i--) {
				
					ans += a[i]*sum;
					ans %= 1000000007;
					sum+=a[i];
					sum%=1000000007;
				
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 51200
#define _ ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long a[2];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[2]%2==0)cout<<0;
    else cout<<a[0]*a[1];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long 
#define int long long 
#define vll vector<long long>
#define pii pair<long long ,long long > 
#define vvi vector< vector<long long > > 
#define vpii vector<pair<int,int>> 
#define pll  pair<long long ,long long > 
#define pb  push_back
#define ff  first 
#define sec second  
#define SORT(a) sort(a.begin(),a.end())
#define SORTR(a) sort(a.rbegin(),a.rend()) 
#define m_p make_pair
#define all(x)   (x.begin(),x.end()) 
#define sz(v)     ((int)(v.size()))
#define INF 1e9+7
typedef vector< long long > vi ;
const int MOD=1e9 +7 ;
int size=10000000; 

bool palin (string s , int st , int end  ){

    bool  loc =1; 
    for(int i=st ; i< (end-st)/2; i++ ){

        if(s[i]!=s[end-1-i]){
          loc=0; 
          break; 
        }
    }

    return loc; 

}


int32_t main(){
  fast; 
  
  string s; cin>>s; 
  int n =s.length(); 
  bool ok = palin(s,0, s.length()); 
  bool ok1=palin(s,0,(n-1)/2 ) ; 
  bool ok3= palin(s,(n+3)/2- 1, n ) ; 

  if(ok && ok1 && ok3 ) cout<<"Yes"<<endl; 
  else cout<<"No"<<endl; 


   
  return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void solveA();
void solveB();
void solveC();
void solveD();
 
int main() {
  solveA();
}

void solveA(){
  int d;
  cin >> d ;
  string s = "Christmas";

  for(int i = 0; i<25-d; i++){
    s += " Eve";
  }
 
  cout << s <<  endl;
}


Measured memory_bytes: 256
def main():
    import numpy as np
    n=int(input())
    c=list(map(int,input().split()))
    b=list(map(int,input().split()))
    a=list(map(int,input().split()))
    a.sort()
    b.sort()
    c.sort()
    a=np.array(a)
    b=np.array(b)
    c=np.array(c)

    cnt_a=np.searchsorted(b,a).tolist()
    cnt_b=np.searchsorted(c,b).tolist()

    ans,j=0,0
    for i in range(n):
        ans+=sum(cnt_b[j:cnt_a[i]])*(n-i)
        j=cnt_a[i]
    print(ans)
if __name__=='__main__':
    main()

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}


int main() {
    int n,m; cin >> n >> m;
    vector<ll> a(n),b(n),c(m),d(m);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, m) cin >> c[i] >> d[i];

    rep(i, n) {
        ll tmpans = LONG_MAX;
        ll ans = -1;
        rep(j, m) {
            ll tmp = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(tmpans > tmp) {
                tmpans = tmp;
                ans = j+1;
            }
        }
        cout << ans << endl;
    }


    return 0;

}


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

int main(void){
  int N,i,min,max;
  int *F;
  
  while(1){
  scanf("%d",&N);
  
  if(N>=2 && N<=200000)break;
  }
    F = (int*)malloc(sizeof(int)*N);
  for(i=0;i<N;i++){
    while(1){
      scanf("%d",&F[i]);
      if(F[i]>=1 && F[i]<=1000000000)break;
    }
  }
  
  min=F[0];
  max=F[1]-min;
  
  for(i=1;i<N;i++){
    if(max<F[i]-min)max=F[i]-min;
    if(min>F[i])min=F[i];
  }
  printf("%d\n",max);
  free(F);
  
  return 0;
}


Measured memory_bytes: 2304