akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> map(H,vector<char>(W));

    rep(i, H) {
        rep(j, W) {
            cin >> map[i][j];
        }
    }

    int ans = 0;
    for (int tmp_h = 0; tmp_h < (1 << H); tmp_h++) {
        
        bitset<6> sh(tmp_h);
        for (int tmp_w = 0; tmp_w < (1 << W); tmp_w++) {
            bitset<6> sw(tmp_w);
            
            int count = 0;
            vector<vector<char>> change_map = map;
            rep(h, H) {
                if (sh.test(h)) {
                    rep (change_w, W) {
                        change_map[h][change_w] = 'r';
                    }
                }
            }
            rep(w, W) {
                if (sw.test(w)) {
                    rep (change_h, H) {
                        change_map[change_h][w] = 'r';
                    }
                }
            }

            rep(h,H) {
                rep(w,W) {
                    if (change_map[h][w] == '#') {
                        count++;
                    }
                }
            }
            if (count == K) {
                ans++;
            }
        }
    }

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

Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String T = sc.nextLine();
        Map<String,String> map = new HashMap<>();
        for(int i = 0;i < T.length();i++){
            char t = T.charAt(i);
            char s = S.charAt(i);
            if(map.containsKey(String.valueOf(s)) && !map.get(String.valueOf(s)).equals(String.valueOf(t))){
                println("No");
                return;
            }
            map.put(String.valueOf(s),String.valueOf(t));
        }
        long count = map.values().stream().distinct().count();
        long count2 = map.values().stream().count();
        println(count != count2 ? "No" : "Yes");
        return;
    }
    static long getLong(String val) {return Long.parseLong(val);}
    static int getInt(String val) {return Integer.parseInt(val);}
    static String[] split(String val) {return val.split(" ");}
    static List<String> toSortedList(String[] s){ return sortList(Arrays.asList(s));}
    static List<String> sortList(List<String> list){
        Collections.sort(list, Comparator.comparingInt(val -> Integer.parseInt(String.valueOf(val))));
        return list;
    }

    static void println(String val){System.out.println(val);}
    static void println(int val){System.out.println(val);}
    static void println(long val){System.out.println(val);}
}

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

int max(int N, int *a) {
	int i;
	int max;
	max = a[0];
	for(i = 1; i < N; i += 1) {
		if(a[i] > max) {
			max = a[i];
		}
	}
	return max;
}

int min(int N, int *a) {
	int i;
	int min;
	min = a[0];
	for(i = 1; i < N; i += 1) {
		if(a[i] < min) {
			min = a[i];
		}
	}
	return min;
}
int main(void) {
	int i;
	int N;
	int *a;
	char buf[512], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);

	a = (int *)calloc(N, sizeof(int));
	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	a[0] = atoi(ch);
	for(i = 1; i < N; i += 1) {
		ch = strtok(NULL, " ");
		a[i] = atoi(ch);
	}

	printf("%d\n", max(N, a) - min(N, a));

	free(a);
	return 0;
}


Measured memory_bytes: 2124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		StringBuilder sb = new StringBuilder();
		for(int i = 0;i < 20;i++){
			sb.append("#");
		}
		String sepalator = sb.toString();
		sb = null;
		
		Building[] buildings = new Building[4];
		for(int i = 0;i < buildings.length;i++){
			buildings[i] = new Building();
		}
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		for(int i = 0;i < n;i++){
			String[] tmp = br.readLine().split(" ");
			int building = Integer.parseInt(tmp[0]);
			int floor = Integer.parseInt(tmp[1]);
			int room = Integer.parseInt(tmp[2]);
			int visitor = Integer.parseInt(tmp[3]);
			buildings[--building].add(--floor, --room, visitor);
		}
		for(int i = 0;i < buildings.length;i++){
			buildings[i].write();
			if(i >= buildings.length - 1)
				break;
			System.out.println(sepalator);
		}
	}

}

class Building {

	Floor[] floors;
	{
		floors = new Floor[3];
		for (int i = 0; i < floors.length; i++) {
			floors[i] = new Floor();
		}
	}

	public void add(int floor, int room, int visitor) {
		floors[floor].add(room, visitor);
	}
	
	public void write(){
		for(int i = 0;i < floors.length;i++){
			floors[i].write();
		}
	}

	private class Floor {
		int[] people;
		{
			people = new int[10];
			for (int i = 0; i < people.length; i++) {
				people[i] = 0;
			}
		}

		public void add(int room, int visitor) {
			people[room] += visitor;
		}
		
		public void write(){
			StringBuilder sb = new StringBuilder();
			for(int i = 0;i < people.length;i++){
				sb.append(" ");
				sb.append(people[i]);
			}
			System.out.println(sb.toString());
		}
	}
}

Measured memory_bytes: 19244
N=int(input())
A=list(map(int,input().split()))
M=1
if 0 in A:
    print('0')
else:
    for i in range(len(A)):
        M*=A[i]
        if M > 10**18:
            break
    if M > 10**18:
        print('-1')
    else:
        print(int(M))

Measured memory_bytes: 21632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
using namespace std;

int main(){
  double R;
  cin>>R;
  cout<<setprecision(9)<<2*R*PI<<endl;
}

Measured memory_bytes: 3788
from sys import stdin

def main():

    input = stdin.readline

    N,K = map(int,input().split())


    print(len(Base_10_to_n(N, K)))

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
    
if __name__ == "__main__":
    main()

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

using namespace std ;

int n ;

char s[1000010]; 

int main() { 
#ifdef YJQ_LOCAL
		freopen(".in", "r", stdin) ;
#endif
		scanf("%s", s + 1) ; 
		n = strlen(s + 1) ; 
		int cur = s[1] - 'A' ; 
		int ans = 0 ;  
		for (int i = 2; i <= n; i ++) { 
				if (s[i] - 'A' != cur) cur = s[i] - 'A', ans ++ ; 
		}
		printf("%d\n", ans) ;
}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner (System.in);
		int R = scanner.nextInt();

		if((0 <= R )&&(R <1200)) {
			System.out.println("ABC");
		}
		else if((1200 <= R)&&(R < 2800)) {
			System.out.println("ARC");
		}
		else {
			System.out.println("AGC");
		}

	}

}

Measured memory_bytes: 23380
#include<stdio.h>
int main()
{
    int i,j,k=0,n,t,m=1;
    scanf("%d",&n);
    if(n%2!=0)
        n--;
    for(i=n;i>=2;i=i-2){
        t=0;
        for(j=i;j>=2&&(j%2==0);){
            j/=2;
            t++;
        }
        if(t>k){
            m=i;
            k=t;
        }
    }
    printf("%d\n",m);
    return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
const ll INF = 999999999999999;
int main(){
  ll n;cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  ll cnt = 0;
  ll ans = 0;
  rep(i,n){
    if( i == 0 ){
      ans += a.at(i);
      ++cnt;
      if( cnt == n-1 ) break;
      continue;
    }
    ans += a.at(i);
    ++cnt;
    if( cnt == n-1 ) break;
    ans += a.at(i);
    ++cnt;
    if( cnt == n-1 ) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4836
k = int(input())
a,b = map(int, input().split())

ans = "NG"
if k == 1:
    ans = "OK"
elif k >1000:
    ans = "NG"
else:
    for i in range(a, b+1):
        if i % k == 0:
            ans = "OK"
            break

print(ans)


Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int n ;
  cin >> n ;
  
  cout <<n/3<<endl ;

    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

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

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

    int a, b, k;
    cin >> a >> b >> k;
    
    vector<int> v;
    for(int i=1; i<=min(a, b); i++){
        if(a%i==0 && b%i==0) v.push_back(i);
    }
    
    cout << v[v.size() - k] << endl;

    return 0;
}


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

string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	if(s[1] == s[0] || s[2] == s[1] || s[3] == s[2])
		cout << "Bad";
	else
		cout << "Good";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
template< typename T > T modpow(T x, T n, const T& p) {
	T ret = 1;
	while (n > 0) {
		if (n & 1) (ret *= x) %= p;
		(x *= x) %= p;
		n >>= 1;
	}
	return ret;
}

int main() {
	init();

	string s; cin >> s;
	map<int, int>mp;
	mp[0]++;
	ll cnt = 0;
	rREP(i, 0, s.size()) {
		ll x = s[i] - '0';
        x *= modpow(10LL, (ll)s.size() - i - 1, 2019LL);
        cnt += x;
        cnt %= 2019;
        mp[cnt]++;
	}
    ll ans = 0;
    for (auto p : mp) {
        //cout << p.second << "\n";
        ans += (p.second * (p.second - 1)) / 2;
    }
    cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<cmath>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
int main() {
    ll n, m;
    L2(n, m);
    int cnt = 0;
    m *=m;
    for(int i = 1; i<=n;i++){
        ll x, y;
        L2(x, y);
        ll ans = x * x + y * y;
        if(ans <= m)cnt++;
    }
    cout<<cnt<<endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<pair<ll,ll>> W(N);
    rep(i,N) cin >> W[i].second >> W[i].first;

    sort(W.begin(),W.end());

    ll time=0;
    rep(i,N){
        time+=W[i].second;
        if(W[i].first<time){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3328
// 2016-12-01
#include <iostream>
#include <cmath>
using namespace std;

int main() {
	int n, w, h, s, t;
	int x[500], y[500];
	int c[100][100];
	while (cin >> n, n) {
		cin >> w >> h;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				c[i][j] = 0;
			}
		}
		for (int i = 0; i < n; i++) {
			cin >> x[i] >> y[i];
			x[i]--; y[i]--;
		}
		cin >> s >> t;
		for (int i = 0; i < n; i++) {
			for (int j = max(0, y[i] - t + 1), jj = min(h, y[i] + 1); j < jj; j++) {
				for (int k = max(0, x[i] - s + 1), kk = min(w, x[i] + 1); k < kk; k++) {
					c[j][k]++;
				}
			}
		}
		int m = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				m = max(m, c[i][j]);
			}
		}
		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
    string s;
    cin >> s;
    if (s == "ABC")
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
using namespace std;
int anum[200007], cnt[200007];
int fastin(){
	register int i; register char ch;
	while (ch = getchar(), ch < '0' || ch > '9');
	i = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9') i = i * 10 + ch - '0';
	return i;
}
int main(){
	register int n, k, i, tot, ans;
	n = fastin(), k = fastin();
	for (i = 1; i <= n; ++i) ++cnt[fastin()];
	tot = 0;
	for (i = 1; i <= n; ++i) {
		if (cnt[i]) anum[++tot] = cnt[i];
	}
	sort(anum + 1, anum + tot + 1);
	k = tot - k;
	ans = 0;
	for (i = 1; i <= k; ++i) ans += anum[i];
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1664
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))

sum_a = list(accumulate(A))
lft = 0
rgt = 2
t = sum_a[-1]
ans = t

for i in range(1,N-2):
    # P<=Q となるように左側の仕切りを動かす
    while sum_a[i] > sum_a[lft] + sum_a[lft+1]:
        lft += 1
        
    while t + sum_a[i] > sum_a[rgt] + sum_a[rgt+1]:
        rgt += 1
        
    p = sum_a[lft]
    q = sum_a[i] - p
    r = sum_a[rgt] - q - p
    s = t - r - q - p
    
    ans = min(ans, max(p,q,r,s) - min(p,q,r,s))
    
print(ans)

Measured memory_bytes: 24300
import java.io.*;
import java.util.*;

public class Main {
    class Reader {
        BufferedReader in;

        Reader() throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in), 32768);
        }

        Reader(String name) throws IOException {
            in = new BufferedReader(new FileReader(name));
        }

        StringTokenizer tokin = new StringTokenizer("");

        String next() throws IOException {
            if (!tokin.hasMoreTokens()) {
                tokin = new StringTokenizer(in.readLine());
            }
            return tokin.nextToken();
        }

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

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

    class Writer {
        PrintWriter cout;

        Writer() throws IOException {
            cout = new PrintWriter(System.out);
        }

        Writer(String name) throws IOException {
            cout = new PrintWriter(new FileWriter(name));
        }

        StringBuilder out = new StringBuilder();

        void print(Object a) {
            out.append(a);
        }

        void close() {
            cout.print(out.toString());
            cout.close();
        }
    }

    void solve() throws IOException {
        Reader in = new Reader();
        Writer out = new Writer();
        int n = in.nextInt();
        int k = in.nextInt();
        int p[] = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = in.nextInt();
        }
        TreeSet<Integer> t = new TreeSet<>();
        int ans = 0;
        int colInv = 0;
        for (int i = 1; i < k; i++) {
            if (p[i - 1] > p[i]) {
                colInv++;
            }
            t.add(p[i]);
        }
        if (colInv > 0) {
            ans++;
        }
        boolean not = false;
        if (colInv == 0) {
            not = true;
        }
        for (int i = k; i < n; i++) {
            if (p[i - k] > p[i - k + 1]) {
                colInv--;
            }
            t.remove(p[i - k]);
            boolean can = !(t.lower(p[i - k]) == null && t.higher(p[i]) == null);
            if (p[i - 1] > p[i]) {
                colInv++;
            }
            if (can && colInv > 0) {
                ans++;
            }
            t.add(p[i]);
            if (colInv == 0) {
                not = true;
            }
        }
        if (not) {
            ans++;
        }
        out.print(ans);
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

Measured memory_bytes: 57904
def solve(prev, r, n, dic):
    d = [0] * n
    md = 0
    t = r
    stack = []
    stack += [[prev, r, 0]]
    while stack:
        prev, r, d1 = stack.pop(-1)
        if r in dic:
            for vtx, cost in dic[r]:
                if vtx == prev:
                    continue
                stack += [[r, vtx, d1 + cost]]
                if d[vtx] < d1 + cost:
                    d[vtx] = d1 + cost
                    if md < d[vtx]:
                        md = d[vtx]
                        t = vtx
    return d, t

dic = {}
line = input()
n = int(line)
for _ in range(1, n):
    line = input()
    s, t, w = list(map(int, line.split()))
    if s not in dic:
        dic[s] = [[t, w]]
    else:
        dic[s] += [[t, w]]
    if t not in dic:
        dic[t] = [[s, w]]
    else:
        dic[t] += [[s, w]]
d1, t1 = solve(-1, 0, n, dic)
d2, t2 = solve(-1, t1, n, dic)
d3, t3 = solve(-1, t2, n, dic)
print("\n".join(map(str, [max(a, b) for a, b in zip(d2, d3)] )))


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

using namespace std;

int main()
{
	int N, i;

	cin >> N;

	for (i = 1; i * i <= N; i++)
	{
	}
	i--;

	cout << i * i << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char s[100];
  int len,i,check=0;
  scanf("%s",s);
  len=strlen(s);
  for(i=0;i<len;i++)
    if(s[i]!=s[len-i-1])
      check=1;
  for(i=0;i<(len-1)/2;i++)
    if(s[i]!=s[(len-3)/2-i] || s[i+(len+1)/2]!=s[len-i-1])
      check=1;
  if(check==1)
    printf("No\n");
  else
    printf("Yes\n");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N = 112345;


int c[N];
int ok;

int main() {
	int n; scanf("%d", &n);
	
	for(int i = 1; i <= n; ++i) {
		scanf("%d", c+i);
	}
	
	
	int res=0;
	for(int i = 1; i <= n; ++i) {
		if(c[i] == i) {
			swap(c[i], c[i+1]);
			res++;
		}
	}
	printf("%d", res);
	
	
}


Measured memory_bytes: 640
using System;

namespace A
{
    class A
    {
        static void Main(string[] args)
        {
            int n, q, i, count=0;
            string a;
            string[] b = new string[30000];
            int[] S = new int[10000];
            int[] T = new int[10000];
            LinerSearch search = new LinerSearch();
            a = Console.ReadLine();
            n = int.Parse(a);
            b = Console.ReadLine().Split(' ');
            for (i=0; i<n; i++)
            {
                S[i] = int.Parse(b[i]);
            }
            a = Console.ReadLine();
            q = int.Parse(a);
            b = Console.ReadLine().Split(' ');
            for (i=0; i<q; i++)
            {
                T[i] = int.Parse(b[i]);
            }

            for (i=0; i<q; i++)
            {
                count = count + search.search(S, T[i], n);
            }

            Console.WriteLine(count);
            
        }
    }

    class LinerSearch
    {
        int i;
        public int search(int[] A, int key, int a)
        {
            for (i = 0; i < a; i++)
            {
                if (A[i] == key)
                {
                    return 1;
                }
            }
            return 0;
        }
    }
}



Measured memory_bytes: 10020
x = 0

while True:
    
    sentence = list(input())
    
    if sentence[0] == "-":
        break
        
    m = int(input())
    
    while x < m:
        
        h = int(input())
        
        tmp = sentence[0 : h]
        del sentence[0 : h]
        sentence += tmp
        
        x += 1
        
    print("".join(sentence))
    x = 0


Measured memory_bytes: 5592
N, Q = map(int, input().split())
S = input()
lr = [list(map(int, input().split())) for _ in range(Q)]

cnt = [0] * (N + 1)
for i in range(N):
    if S[i:i+2] == 'AC':
        cnt[i+1] = cnt[i] + 1 
    else:
        cnt[i+1] = cnt[i]

for i in range(Q):
    print(cnt[lr[i][1]-1]-cnt[lr[i][0]-1])

Measured memory_bytes: 30652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    map <string, int> mp;
    mp["AC"] = 0;
    mp["WA"] = 0;
    mp["TLE"] = 0;
    mp["RE"] = 0;

    int n;
    cin >> n;
    rep(i,n){
        string tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <cstring>

using namespace std;
char field[12][6];
bool passed[12][6];

int areaSize(int x, int y, char c){
        if(x < 0 || x >= 6 || y < 0 || y >= 12){ return 0; }
        if(field[y][x] != c || passed[y][x]){ return 0; }
        passed[y][x] = true;
        return
                1 + areaSize(x - 1, y, c) + areaSize(x + 1, y, c) +
                areaSize(x, y - 1, c) + areaSize(x, y + 1, c);
}
void paint(int x, int y, char c){
        if(x < 0 || x >= 6 || y < 0 || y >= 12){ return; }
        if(field[y][x] == 'O'){
                field[y][x] = '.';
                return;
        }
        if(field[y][x] != c){ return; }
        field[y][x] = '.';
        paint(x - 1, y, c);
        paint(x + 1, y, c);
        paint(x, y - 1, c);
        paint(x, y + 1, c);
}

int main(){
        int T;
        cin >> T;
        while(T--){
                for(int i = 0; i < 12; ++i){
                        string line;
                        cin >> line;
                        for(int j = 0; j < 6; ++j){ field[i][j] = line[j]; }
                }
                bool modified = true;
                int answer = -1;
                while(modified){
                        modified = false;
                        ++answer;
                        memset(passed, 0, sizeof(passed));
                        for(int i = 0; i < 12; ++i){
                                for(int j = 0; j < 6; ++j){
                                        if(field[i][j] == '.' || field[i][j] == 'O' || passed[i][j]){ continue; }
                                        int s = areaSize(j, i, field[i][j]);
                                        if(s < 4){ continue; }
                                        modified = true;
                                        paint(j, i, field[i][j]);
                                }
                        }
                        for(int j = 0; j < 6; ++j){
                                int p = 11;
                                for(int i = 11; i >= 0; --i){
                                        if(field[i][j] != '.'){
                                                field[p--][j] = field[i][j];
                                        }
                                }
                                for(; p >= 0; --p){ field[p][j] = '.'; }
                        }
                }
                cout << answer << endl;
        }
        return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
typedef long long ll;
const int mod = 1e9 + 7;
using namespace std;

void solve() {
	int x, y, a, b;
	cin >> x >> y;
	for(int i = 0; i <= x; ++i) {
		a = x - i;
		b = i;
		if(4 * a  + 2 * b == y) {
			cout << "Yes" << endl;
			return;
			}
		}
		cout << "No" << endl;
		return;
 }

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.precision(20);
	solve();
	return 0;
}
 
 
 
 
 
 


Measured memory_bytes: 3616
from math import ceil
s = input()
n = len(s)
rslt = [0] * n
dic = {0:0, 1:0}
cnt = 0
for i in range(0, n):
    if s[i] == 'R':
        cnt += 1
    else:
        rslt[i] += cnt//2
        rslt[i-1] += ceil(cnt/2)
        cnt = 0
for i in range(n-1, -1, -1):
    if s[i] == 'L':
        cnt += 1
    else:
        rslt[i] += cnt//2
        rslt[i+1] += ceil(cnt/2)
        cnt = 0
print(' '.join(list(map(str, rslt))))


Measured memory_bytes: 10484
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,b=0;
	cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
      cin>>a[i];
      if(a[i]%2==0){
        if(a[i]%3!=0&&a[i]%5!=0)b++;
      }
    }
    if(b!=0){
      cout<<"DENIED";
    }else{
      cout<<"APPROVED";
    }
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    int freq[1001];
    using namespace std ; 
    int main (){
      int x, n , Min=1000000;
      cin>>x>>n;
      int arr[n];
      for(int i =0;i<n;i++){
        cin>>arr[i];
        freq[arr[i]]++;
         
      } for(int i =-102;i<=102;i++ ){
             
        if(i>=1 and i<=100){
          if(!freq[i]){
            if(abs(x-i)<abs(x-Min))Min=i;
          }
        }else  if(abs(x-i)<abs(x-Min))Min=i;
      }cout<<Min;
      return 0; 
    }

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<ii > vii;
typedef vector<iii > viii;

int main()
{
  ios::sync_with_stdio(false);
  size_t n;
  cin >> n;
  cout << (n-1)/2 << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector<ll> cnt(n,0);
    for(ll i = 1; i <= n; i++) {
        ll d=i;
        while(d<=n) {
            cnt[d-1]++;
            d+=i;
        }
    }
    ll ans=0;
    for(ll i = 0; i < n; i++) {
        ans+=cnt[i]*(i+1);
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 81328
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

int main()
{ 
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b){
        if(a==c){cout<<"No"<<endl;}
        else{cout<<"Yes"<<endl;}
    }
    else{
        if(a==c||b==c){cout<<"Yes"<<endl;}
        else{cout<<"No"<<endl;}
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, x, m = map(int, input().split())

ans = 0
f_ans = None
anses = []
for i in range(n):
    if f_ans is None:
        f_ans = x % m
    else:
        f_ans = (f_ans ** 2) % m
    if f_ans == 0:
        print(ans)
        sys.exit(0)
    if f_ans == 1:
        ans += (n - i)
        print(ans)
        sys.exit(0)
    if f_ans in anses:
        index = anses.index(f_ans)
        anses = anses[index:]
        ans += ((n - i) // len(anses)) * sum(anses)
        ans += sum(anses[:((n-i) % len(anses))])
        print(ans)
        sys.exit(0)
    anses.append(f_ans)
    ans += f_ans
print(ans)


Measured memory_bytes: 68864
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        mp[a]++;
    }
    if (mp.rbegin()->second < 2) {
        puts("Impossible");
        return 0;
    }
    int d = mp.rbegin()->first;
    mp[d] -= 2;
    int mn = d;
    rep(i, d-1) {
        int x = max(d-1-i, i+1);
        chmin(mn, x);
        if (mp[x] == 0) {
            puts("Impossible");
            return 0;
        }
        mp[x]--;
    }

    for (auto&& p : mp) {
        if (p.se > 0) {
            if (mn < p.fi && p.fi <= d) continue;
            puts("Impossible");
            return 0;
        }
    }
    puts("Possible");
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      S[i].push_back(s);
    }
  }
  vector<int> P(M);
  for (int i = 0; i < M; i++)
    cin >> P[i];

  int res = 0;
  for (int i = 0; i < (1 << N); i++) {
    bool flag = true;
    for (int j = 0; j < S.size(); j++) {
      int cnt = 0;
      for (int l = 0; l < S[j].size(); l++)
        if ((i >> (S[j][l] - 1)) & 1) cnt++;
      if (cnt % 2 != P[j]) flag = false;
    }
    if (flag) res++;
  }
  cout << res << '\n';
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};

template<typename DATA>
class Sparse_Segment_Tree{
  public:
    ll n_;
    unordered_map<ll, DATA> lazy2;

    using F = function<DATA(DATA,DATA)>;
    const F f;
    const DATA init;

    Sparse_Segment_Tree(const F &f, const DATA init) : f(f), init(init){
      n_=1;
      return;
    };

    ~Sparse_Segment_Tree(void){
      return;
    };

    inline ll get_hash(ll l, ll r){
      return l*2000000001 + r;
    }

    //[a,b)の範囲に対してxを作用させる
    void rangeupdate2(ll a, ll b, DATA x, ll l, ll r){
      if(a<=l && r<=b){
        lazy2[get_hash(l,r)] = f(lazy2[get_hash(l,r)], x);
      }else{
        if(a<(l+r)/2) rangeupdate2(a, b, x, l, (l+r)/2);
        if((l+r)/2<b) rangeupdate2(a, b, x, (l+r)/2, r);
      }
      return;
    }

    void rangeupdate2(ll a, ll b, DATA x){
      while(n_<=b) n_<<=1;
      rangeupdate2(a, b, x, 0, n_);
      return;
    }

    DATA pointquery(ll a, ll l, ll r){
      DATA tmp = init;
      if(lazy2.find(get_hash(l,r))!=lazy2.end()) tmp = lazy2[get_hash(l,r)];
      if(r-l<=1) return tmp;
      if(a<(l+r)/2) return f(tmp, pointquery(a, l, (l+r)/2));
      return f(tmp, pointquery(a, (l+r)/2, r));
    };

    DATA pointquery(ll a){
      if(a<0){
        fprintf(stderr, "Segment_Tree Search Space Error\n");
        fprintf(stderr, "Desired:\n");
        fprintf(stderr, "%lld <= %lld\n", 0, a);
        exit(0);
      }else if(n_<=a){
        return 0;
      }
      return pointquery(a, 0, n_);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, Q;
  cin >> N >> Q;

  auto f = [](ll a, ll b){return min(a,b);};
  Sparse_Segment_Tree<ll> que(f, 0);

  ll Shift = 1000000001;

  ll S, T, X;
  REP(i,N){
    cin >> S >> T >> X;
    que.rangeupdate2(S-X+Shift, T-X+Shift, X-Shift);
  }

  ll D;
  REP(i,Q){
    cin >> D;
    ll X = que.pointquery(D+Shift)+Shift;
    if(X==Shift) X=-1;
    cout << X << "\n";
  }

  return 0;
}



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

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	string s;
	cin >> s;
	string rain = "";
	int ans = 0;
	for (int i = 0; i < s.length(); ++i) {
		rain += "R";
		if ((int)s.find(rain) != -1) {
			ans = max(ans, i + 1);
		}
	}

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

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

using namespace std;

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int N, U, V, M;
int idx(int x, int y){
  return y*N+x;
}

int check(int id, vector<bool>& vb){
  if(N == 1){
	if(vb[id]) return 1;
	else return 0;
  }
  
  int x = id % N, y = id / N;
  int tx, ty, res = 0;
  for(tx=0;tx<N;++tx)
	if(!vb[idx(tx,y)]) break;
  if(tx == N) ++res;

  for(ty=0;ty<N;++ty)
	if(!vb[idx(x,ty)]) break;
  if(ty == N) ++res;

  if(x == y){
	for(tx=0;tx<N;++tx)
	  if(!vb[idx(tx,tx)]) break;
	if(tx == N) ++res;
  }
  if(x+y == N-1){
	for(tx=0;tx<N;++tx)
	  if(!vb[idx(tx,N-1-tx)]) break;
	if(tx == N) ++res;
  }
  return res;
}

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

  cin >> N >> U >> V >> M;
  map<int,int> p1, p2;
  vector<bool> tab1(N*N, false), tab2(N*N, false);
  REP(y,N) REP(x,N){
	int a; cin >> a;
	p1[a] = idx(x,y);
  }
  REP(y,N) REP(x,N){
	int a; cin >> a;
	p2[a] = idx(x,y);
  }


  int ans = 0;
  REP(m,M){
	int a; cin >> a;
	if(p1.count(a)){
	  tab1[p1[a]] = true;
	  U -= check(p1[a], tab1);
	}
	if(p2.count(a)){
	  tab2[p2[a]] = true;
	  V -= check(p2[a], tab2);
	}
	//cout<<U<<","<<V<<endl;
	if(U <= 0){
	  if(V <= 0)
		ans = 0;
	  else
		ans = -1;
	  break;
	}
	else if(V <= 0){
	  ans = 1;
	  break;
	}
  }

  if(ans < 0) cout << "USAGI" << endl;
  else if(ans == 0) cout << "DRAW" << endl;
  else cout << "NEKO" << endl;
  
  return 0;
}

Measured memory_bytes: 14696
#include <iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a - 1 >=b) {
		cout << a * 2 - 1;
	}
	else if (b - 1 >= a) {
		cout << b * 2 - 1;
	}
	else if (b = a) {
		cout << b + a;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    int a[2][n];
    int answer=0;
    int tmp=0;
    REP(i,2)REP(j,n)cin >> a[i][j];
    REP(i,n){
        tmp=0;
        REP(j,n){
            if(j<=i)tmp+=a[0][j];
            else if(j>=i)tmp+=a[1][j];
        }
        tmp += a[1][i];
        //if(tmp > answer)cout << i << endl;
        answer = max(answer,tmp);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [0] * n

for i in range(n):
    a[i] = int(input())

#maxV = max(a)
sortedA = sorted(a)
maxV = sortedA[n-1]
maxV2 = sortedA[n-2]

for i in range(n):
    if a[i] == maxV:
        # new = list(a)
        # del new[i]
        # print(max(new))
        print(maxV2)
    else:
        print(maxV)


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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  ll N,D;
  cin >> N >> D;
  ll X[N],Y[N];
  REP(i,N) cin >> X[i] >> Y[i];

  int ans = 0;
  REP(i,N) {
    if (X[i] * X[i] + Y[i] * Y[i] <= D * D) ans++;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 6736
// D- Summer vacation- atcoder.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <deque>
#include <set>
#include <algorithm>
using namespace std;
const int N = 1e5 , M = 1e5  ;
int n, m , u , v;
deque <pair<int, int>> Q;
int ans = 0;

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

	for (int i = 0; i < n; i++) {
		cin >> u >> v;
		Q.push_back(make_pair(u, v));
	}

	sort(Q.begin(), Q.end());
	multiset<int> s;
	for (int i = 1; i <= m; i++)
	{
		int size = Q.size();
		for(int j = 0 ; j < size ;j++){
			if (Q.front().first == i)
			{
				s.insert(Q.front().second);
				Q.pop_front();
			}
			else break;
		}
		if (!s.empty()) {
			ans += *--s.end() ;
			s.erase(--s.end()) ;
		}
	}
	cout << ans;
}


Measured memory_bytes: 4864
N,T=map(int,input().split())
t=list(map(int,input().split()))
start=t[0]
ans=0
for i in range(N-1):
  if t[i+1]-t[i]>T:
    ans+=T+t[i]-start
    start=t[i+1]
ans+=T+t[N-1]-start
print(ans)

Measured memory_bytes: 25200
#include <stdio.h>

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


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

using namespace std;
int main(int argc, char** argv) {
  vector<int> C(6);
  for (c : C) {
    cin >> c;
  }
  bool result = true;
  for (int i = 1; i <=4; i++) {
    auto cnt = count(C.begin(), C.end(), i);
    if (cnt == 3) { 
      result = false;
    }
  }

  if (result) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, M;
        public long MOD = 1000000007;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                M = line[1];
            }

            int[] F = new int[M];

            for (int i = 0; i < N; i++)
            {
                var line = Input.ReadIntArray();
                foreach (var v in line.Skip(1))
                {
                    F[v - 1] ++;
                }
            }

            int ret = 0;
            for (int i = 0; i < M; i++)
            {
                if (F[i] == N) ret++;
            }

            Console.WriteLine(ret);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;

const ll INF = 1e15;

ll edge[300 + 10][300 + 10];
ll ans[300 + 10][300 + 10];
int N, M;
ll L;

int main() {
	cin >> N >> M >> L;
	for (int i = 0; i < N; i++)for (int j = 0; j < N; j++)edge[i][j] = INF;
	for (int i = 0; i < M; i++) {
		int a, b;
		ll c;
		cin >> a >> b >> c;
		a--, b--;
		if (c > L)continue;
		edge[a][b] = c;
		edge[b][a] = c;
	}

	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (edge[i][k] + edge[k][j] < edge[i][j])
					edge[i][j] = edge[i][k] + edge[k][j];
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans[i][j] = INF;
			if (edge[i][j] <= L)ans[i][j] = 1;
		}
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (ans[i][k] + ans[k][j] < ans[i][j])
					ans[i][j] = ans[i][k] + ans[k][j];
			}
		}
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int s, t;
		cin >> s >> t;
		s--, t--;
		if (ans[s][t] >= INF)cout << -1 << endl;
		else cout << min(ans[s][t], ans[t][s]) - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 2048