akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns #-}
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import Data.Char
import Control.Monad

solve :: Int ->  VU.Vector (Int,Int) -> VU.Vector Int
solve !h !abs = VU.foldl' step (VU.singleton 0) (VU.generate h $ \i -> i + 1)
    where
        step :: VU.Vector Int -> Int -> VU.Vector Int
        step !v !i =  
            let
                m = VU.foldl' (\ !x (!a,!b) -> let !y = if i >= a then b + (v VU.! (i-a)) else b in min x y) (10^9) abs
            in
                VU.generate (i+1) $ \ !j -> if j == i then m else v VU.! j 
    

main = do
    [h, n] <- map  read . words <$> getLine :: IO [Int]
    abs <- VU.replicateM n $ do 
        s <- B.getLine 
        let Just (a, s') = B.readInt s
        let Just (b, _) = B.readInt $ B.dropWhile isSpace s'
        return (a,b)
    print $ VU.last $ solve h abs

Measured memory_bytes: 2428
/*
	written by Pankaj Kumar.
	country:-INDIA
*/
#include<algorithm>
#include<string.h>
#include<iostream>
#include<sstream>
#include<vector>
#include<deque>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll ;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vpl;
typedef vector<string> vs;
typedef set<string> ss;
typedef set<int> si;
typedef set<ll> sl;
typedef set<pair<int,int>> spi;
typedef set<pair<ll,ll>> spl;
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
// define values.
#define mod 1000000007;
#define phi 1.618
/* Bit-Stuff */
#define get_set_bits(a) (__builtin_popcount(a))
#define get_set_bitsll(a) ( __builtin_popcountll(a))
#define get_trail_zero(a) (__builtin_ctz(a))
#define get_lead_zero(a) (__builtin_clz(a))
#define get_parity(a) (__builtin_parity(a))
/*  Abbrevations  */
#define ff first
#define second ss
#define mp make_pair
#define line cout<<endl;
#define pb push_back
#define INT_SIZE sizeof(int)
#define INT_BITS INT_SIZE*8-1
// function
ll power(ll x,ll y)
{
	ll res=1;
	while(y>0)
	{
		if(y%2==1)res*=x;
		y/=2; x*=x;
	}
	return res;
}
/* ascii value 
A=65,Z=90,a=97,z=122
*/
/*  -----------------------------------------------------------------------------------*/


int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	while(A > 0 && C > 0)
	{
	    C -= B;
	    A -= D;
  	}
  	if(C <= 0)
  		cout << "Yes\n";
  	else
  		cout << "No\n";
}

Measured memory_bytes: 3624
(let* ((n (read))
       (k (read))
       (z 1000000007)
       (a (make-array (list n)))
       (x 0)
       (y 0))
  (loop :for i :from 0 :to (1- n)
        :do (setf (aref a i) (read)))
  ;;
  (loop :for i :from 0 :to (- n 2)
        :do (loop :for j :from i :to (- n 1)
                  :if (> (aref a i) (aref a j))
                  :do (progn (incf x) (incf y))
                  :if (< (aref a i) (aref a j))
                  :do (incf y)))
  (format t "~A~%" (mod (+ (* x k) (* (/ (* k (- k 1)) 2) y)) z)))


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

int N,M;
int ans;
vector<int> swit[11];
int judge[11];


bool good(vector<int> &vn){
    _for(i,0,M){
        int k = 0;
        _for(j,0,swit[i].size()){
            int num = swit[i][j]-1;
            if(vn[num]) k++;
        }
        if(k%2 != judge[i]) return false;

    }
    return true;

}


void searching(vector<int> &vn,int d){
    if(d == N){
        //cout << vn << endl;
        if(good(vn)) ans++;
        return;
    }
    vn[d] = 1;
    searching(vn,d+1);
    vn[d] = 0;
    searching(vn,d+1);
}

int main()
{
    cin >> N >> M;
    _for(i,0,M){
        int k;
        cin >> k;
        _for(j,0,k){
            int n;
            cin >> n;
            swit[i].push_back(n);
        }
    }
    _for(i,0,M){
        cin >> judge[i];
    }

    vector<int> vn(N,0);
    ans = 0;
    searching(vn,0);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# encoding: utf-8

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

def get_distance(s,H):
    distance=0

    for i in range(s,len(H)-1):
        if H[i+1] <= H[i]:
            distance += 1
        else:
            break
    
    return distance

ans = 0
i=0

while i < N:
    t = get_distance(i,H)
    if ans < t:
        ans = t
    i += t + 1

print(ans)

Measured memory_bytes: 14252
N = int(input())
p = 1
cnt = 26
while (cnt < N):
    p += 1
    cnt += 26 ** p

mod = (N - cnt + 26 ** p) % 26 ** p
mod = mod - 1

# str : p
alphabet = "abcdefghijklmnopqrstuvwxyz"

st = ['a'] * p

for i in reversed(list(range(p))):
    st[i] = alphabet[(mod % 26)]
    mod = mod // 26

print(*st, sep='')

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,a,b,c;
  cin>>n>>a>>b>>c;
  string bun;
  bun="Yes";
  vector<string> str(n);
  vector<char> ans(n);
  for(long i=0; i<n; i++){
    cin>>str.at(i);
  }
  for(long i=0; i<n; i++){
    //cout<<a<<" "<<b<<" "<<c<<endl;
    if(str.at(i)=="AB"){
      if(a<b){
        a=a+1;
        b=b-1;
        ans.at(i)='A';
      }
      else if(a>b){
        a=a-1;
        b=b+1;
        ans.at(i)='B';
      }
      else{
        if(a==0){
          bun="No";
          break;
        }
        if(a==1 && i!=n-1){
          if(str.at(i+1)=="AC"){
            a=a+1;
            b=b-1;
            ans.at(i)='A';
          }
          else{
            a=a-1;
            b=b+1;
            ans.at(i)='B';
          }
        }
        else{
          a=a+1;
          b=b-1;
          ans.at(i)='A';
        }
      }
    }
    
    if(str.at(i)=="BC"){
      if(c<b){
        c=c+1;
        b=b-1;
        ans.at(i)='C';
      }
      else if(c>b){
        c=c-1;
        b=b+1;
        ans.at(i)='B';
      }
      else{
        if(b==0){
          bun="No";
          break;
        }
        if(b==1 && i!=n-1){
          if(str.at(i+1)=="AC"){
            c=c+1;
            b=b-1;
            ans.at(i)='C';
          }
          else{
            c=c-1;
            b=b+1;
            ans.at(i)='B';
          }
        }
        else{
          c=c+1;
          b=b-1;
          ans.at(i)='C';
        }
      }
    }
    
    
    if(str.at(i)=="AC"){
      if(a<c){
        a=a+1;
        c=c-1;
        ans.at(i)='A';
      }
      else if(a>c){
        a=a-1;
        c=c+1;
        ans.at(i)='C';
      }
      else{
        if(a==0){
          bun="No";
          break;
        }
        if(a==1 && i!=n-1){
          if(str.at(i+1)=="AB"){
            a=a+1;
            c=c-1;
            ans.at(i)='A';
          }
          else{
            a=a-1;
            c=c+1;
            ans.at(i)='C';
          }
        }
        else{
          a=a+1;
          c=c-1;
          ans.at(i)='A';
        }
      }
    }
  }
  cout<<bun;
  if(bun=="Yes"){
    for(long i=0; i<n; i++){
      cout<<endl;
      cout<<ans.at(i);
    }
  }
}

Measured memory_bytes: 6404
def resolve():
    K = int(input())
    lunluns = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    count = 9
    pointer = 0
    while K > count:
        lunnum = lunluns[pointer]
        lunlast = int(str(lunnum)[-1])
        if lunlast == 0:
            for i in [0, 1]:
                lunluns.append(int(str(lunnum)+str(lunlast+i)))
                count += 1
        elif lunlast == 9:
            for i in [-1, 0]:
                lunluns.append(int(str(lunnum)+str(lunlast+i)))
                count += 1
        else:
            for i in [-1, 0, 1]:
                lunluns.append(int(str(lunnum)+str(lunlast+i)))
                count += 1
        pointer += 1
    print(lunluns[K-1])

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 80068
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
  int a,b,res;
  cin >> a >> b;
  if(a>=13) res=b;
  else if(a>=6) res=b/2;
  else res=0;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env perl
use strict;
use warnings;

my $N = <>;

my $sum = 0;
for ( 1.. $N ) {
    my $input = <>;
    my ($x, $u) = split(' ', $input );
    my $money = $u eq 'JPY' ? $x : $x * 380000.0;
    $sum += $money;
}
print $sum;

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

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

  int i = 1;
  while(1) {
    int x = i;

    if(x % 3 == 0){
      cout<<" "<<i;
    }
    else {
      while(1){
	if(x % 10 == 3){
	  cout<<" "<<i;
	  break;
	}
	x /= 10;
	if(x == 0) break;
      }
    }

    if(++i > n) break;
  }
  cout<<endl;

  return 0;
}



Measured memory_bytes: 3116
N,M,K=map(int,input().split())
cost=0
mod=10**9+7
NM=N*M
kaijo=[0]*(NM-1)
kaijo[0]=1
for i in range(1,NM-1):
    kaijo[i]=(kaijo[i-1]*i)%mod
gyaku=[0]*(NM-1)
gyaku[NM-2]=pow(kaijo[NM-2],mod-2,mod)
for i in range(NM-2,0,-1):
    gyaku[i-1]=(gyaku[i]*i)%mod
def conb(a,b):
    return (kaijo[a]*gyaku[b]*gyaku[a-b])%mod
x=conb(NM-2,K-2)
for d in range(1,N):
    cost=(cost+x*d*(N-d)*(M**2))%mod
for d in range(1,M):
    cost=(cost+x*d*(M-d)*(N**2))%mod
print(cost)

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

using namespace std;

int main(void)
{
  string s;
  cin >> s;
  
  int same_number = 0;
  
  for (int i = 0; i < 3; i++)
  {
    if(s[i] == s[i+1])
    {
      same_number++;
    }
  }
  
  if(same_number > 0)
  {
    cout << "Bad";
  }
  else
  {
    cout << "Good";
  }
}

Measured memory_bytes: 768
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

int vec[100000];
int p[100000];

int find(int a) {
	if (p[a] == -1) return a;
	return p[a] = find(p[a]);
}

void merge(int a, int b) {
	a = find(a); b = find(b);
	if (a == b) return;
	p[b] = a;
}

int main() {
	memset(p, -1, sizeof(p));
	int n, m;
	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++) {
		scanf("%d", &vec[i]);
		vec[i]--;
	}
	
	int a, b;
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &a, &b);
		a--; b--;
		merge(vec[a], vec[b]);
	}
	
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (find(vec[i]) == find(i)) cnt++;
	}

	printf("%d", cnt);
}

Measured memory_bytes: 1024
#coding utf-8

def main():
    question_a()

def question_a():
    abc = list(map(int,input().split()))
    flg = False
    if abc[0] == abc[1] or abc[0] == abc[2]:
        if abc[1] != abc[2]:
            print("Yes")
            flg = True
    elif abc[1] == abc[2]:
        if abc[0] != abc[1]:
            print("Yes")
            flg = True

    if flg == False:
        print("No")

main()


Measured memory_bytes: 3060
a,b=map(int,input().split())
if a==b:
    print(a)
else:
    s=4-a%4
    t=(1+b%4)
    ans=0
    for j in range(a,a+s):
        ans=ans^j
    for j in range(b+1-t,b+1):
        ans=ans^j
    print(ans)

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

const int mod = 1e9+7;

int main(){

    int H, W, K;
    cin >> H >> W >> K;


    int A[101][8] = {};
    A[0][0] = 1;

    for( int i = 0; i < H; i++ ){
        for( int j = 0; j < W; j++ ){
            //bitで処理する -> 横線が繋がっているかをbitが立っているかで判断
            for( int k = 0; k < 1 << W-1; k++ ){
                bool connected = true;
                // 横線が繋がっているかどうか調べる
                for( int l = 0; l < W-2; l++ ){
                    if( ((k >> l) & 1) && ((k >> (l + 1)) & 1) ) connected = false;
                    // kのl番目とl+1番目にbitが立っていれば
                    // -> 隣同士に横線がある状態なのでダメ
                }

                if( connected ){
                    if( j >= 1 && ( (k >> j-1) & 1 ) ){ // 左方向に行く場合
                        A[i+1][j-1] += A[i][j];
                        A[i+1][j-1] %= mod;
                    }else if( j <= W-2 && ( (k >> j) & 1 ) ){ // 右方向に行く場合
                        A[i+1][j+1] += A[i][j];
                        A[i+1][j+1] %= mod;
                    }else{ // 真ん中に行く場合
                        A[i+1][j] += A[i][j];
                        A[i+1][j] %= mod;
                    }
                }
            }
        }
    }
    
    cout << A[H][K-1] % mod << endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<numeric>
#include<math.h>
#include<deque>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
bool dfs ( int a, int b, vector<vector<char>>& hw, vector<vector<bool>>& flg, int h, int w ) {
    if ( a >= h || b >= w ) return false;
    flg[a][b] = true;
    bool ng = false;
    int dx[2] = {1, 0};
    int dy[2] = {0, 1};
    int cnt = 0;
    bool ok = true;
    rep(i, 2) {
        int next_y = a + dy[i];
        int next_x = b + dx[i];
        if ( next_y >= h || next_x >= w ) continue;
        if ( hw[next_y][next_x] == '#' ) {
            ok = dfs(next_y, next_x, hw, flg, h, w);
            ++cnt;
        }
    }
    if ( !ok ) return false;
    if ( cnt == 2 ) return false;
    else            return true;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> hw(h, vector<char>(w));
    vector<vector<bool>> flg(h, vector<bool>(w, false));
    rep(i, h) rep(j, w) cin >> hw[i][j];
    bool ok = dfs(0, 0, hw, flg, h, w);
    if ( !ok ) {
        cout << "Impossible" << endl;
        return 0;
    }
    rep(i, h) rep(j, w) {
        if ( hw[i][j] == '#' && !flg[i][j] ) {
            cout << "Impossible" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()

{
  int m,f,r,score;
  for(;;)

    {

      scanf("%d%d%d",&m,&f,&r);
      score=m+f;

      if(m+f+r==-3)return 0;
      if(m==-1||f==-1) printf("F\n");

      else if(score>=80) printf("A\n");
      else if(score>=65) printf("B\n");
      else if(score>=50||r>=50) printf("C\n");
      else if(score>=30) printf("D\n");
      else puts("F");

    }

  return 0;

}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
// B - Power Socket 2325-
int main(){
    int A,B;
    cin>>A>>B;
    for (int i = 0; i < 1000; i++)
    {
        if ((A-1)*i+1 >= B){
            cout << i << endl;
            return 0;
        }
        
    }
    
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int cnt = 0,n[500],x[500];
  while(1){
    cin >> n[cnt] >> x[cnt];
    if(n[cnt] == 0 && x[cnt] == 0) break;
    cnt++;
  }
  int ans = 0;
  for(int l=0;l < cnt;l++){
    for(int i=1;i <= n[l];i++){
      for(int j=1;j <= n[l];j++){
        if(i == j) break;
        for(int k=1;k <= n[l];k++){
          if(j == k || k == i){
            break;
          }else{
            if(i+j+k == x[l]) ans++;
          }
        }
      }
    }
    cout << ans << endl;
    ans = 0;
  }
  return 0;
}


Measured memory_bytes: 3108
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextLine()
    val n = s.length
    val count = Array(2019) { 0 }
    var pow10 = 1
    var sum = 0
    for (j in n - 1 downTo 0) {
        val d = s[j].toString().toInt()
        sum += pow10 * d
        sum %= 2019
        count[sum]++
        pow10 *= 10
        pow10 %= 2019
    }

    var ans = 0L
    var diff = 0
    pow10 = 1
    for (j in n - 1 downTo 0) {
        ans += count[diff]
        val d = s[j].toString().toInt()
        diff += pow10 * d
        diff %= 2019
        pow10 *= 10
        pow10 %= 2019
        count[diff]--
    }
    println(ans)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 53236
main = do
  n <- getLine
  s1 <- getLine
  s2 <- getLine
  s3 <- getLine
  putStrLn . show $ solve (s1,s2,s3)

solve :: (String,String,String) -> Int
solve ([],_,_) = 0
solve ((c1:s1), (c2:s2), (c3:s3)) = (compare3 c1 c2 c3) + solve (s1,s2,s3)


compare3 :: Char -> Char -> Char -> Int
compare3 a b c
  | a == b && b == c = 0
  | a == b && b /= c = 1
  | b == c && a /= b = 1
  | c == a && a /= b = 1
  | otherwise = 2


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define foreach(c,it) for (__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
using namespace std;
long long n,i,j,p[100005],pc,np[100005],a[515][515];
int main(){
	for(i=2;i<=100000;i++){
		if(!np[i]){p[++pc]=i;}
		rep(j,pc){if(i*p[j]>100000) break;
			np[i*p[j]]=1;if(i%p[j]==0) break;
		}
	}
	cin>>n;;
	rep(i,n+2)rep(j,n+2)if(!((i+j)&1)){
		int t1=(i+j)/2,t2=(i-j+n+2)/2+n+2;
		a[i][j]=p[t1]*p[t2];
	}
	rep(i,n+2)rep(j,n+2)if((i+j)&1){
		a[i][j]=a[i][j-1]*a[i][j+1]+1;
	}
	rep(i,n){
		rep(j,n){
			cout<<a[i+1][j+1]<<' ';
		}cout<<endl;
	}
	return 0;
}

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

int main() 
{
  int array[4][3][10] = {0};
  int n;
  cin >> n;
  int i,j,k,l;
  int b,f,r,v;
  int temp;
  for(i = 0;i < n;i++){
    cin >> b >> r >> f;
    cin >> temp;
    array[b-1][r-1][f-1] += temp;
  }
  for(i = 0;i < 4;i++){
    for(j = 0;j < 3;j++){
      for(k = 0;k < 10;k++){
          cout << " " << array[i][j][k];
          if(k == 9){
            cout << "\n";
          }
        }
      }
      if(i != 3){
      for(l = 0;l < 20;l++){
        cout << "#";
      }
      cout << "\n";
    }
    }
    
  return 0;
}


Measured memory_bytes: 3088
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())



N,M = map(int,input().split())
F = UnionFind(N)

for i in range(M):
  A,B = map(int,input().split())
  F.union(A-1,B-1)
  
res = 0
for i in range(N):
  res = max(res,F.size(i))
  
print(res)

Measured memory_bytes: 14404
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
//YESNO

using namespace std;

signed main()
{
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
}


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


using namespace std;

typedef long long ll;

double eps = 1e-9;
int change(string a,string b)
{
    int cnt=0;
    for(int i=0; i<a.size(); i++)
    {
        if(a[i]!=b[i])
        {
            cnt++;
        }
    }
    return cnt;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string s,t;
    cin>>s>>t;
    int ans=INT_MAX;
    for(int i=0; i<s.size(); i++)
    {
        string tmp = s.substr(i,t.size());
        //cout<<tmp<<endl;

        if(tmp.size()==t.size())
        {
            ans = min(ans,change(tmp,t));
        }

    }
    cout<<ans<<endl;

}



Measured memory_bytes: 3576
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int x, y, z;
    cin >> x >> y >> z;

    x -= z;

    cout << x / (y + z) << endl;

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> cnt1;
    ll res = 0;
    rep(i, N) {
        cin >> A[i];
        res += cnt1[i - A[i]];
        ll num1 = A[i] + i;
        cnt1[num1]++;
    }

    cout << res << endl;
}

Measured memory_bytes: 27336
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

struct Point
{
    int x;
    int y;
};

struct Data
{
    int index;
    int count;
};

int main(int, const char**)
{
    int h, w, m;
    cin >> h >> w >> m;

    auto compare = [](const Point& a, const Point& b)
    {
        if(a.x == b.x)
        {
            return a.y < b.y;
        }
        return a.x < b.x;
    };

    set<Point, decltype(compare)> ps{compare};
    vector<Data> hb(h, {0, 0}), wb(w, {0, 0});
    rep(i, h)
    {
        hb[i] = {i, 0};
    }
    rep(i, w)
    {
        wb[i] = {i, 0};
    }
    rep(i, m)
    {
        int y, x;
        cin >> y >> x;
        y--; x--;

        hb[y].count++;
        wb[x].count++;
        ps.insert({x, y});
    }
    sort(hb.begin(), hb.end(), [](const auto& a, const auto& b) -> bool
    {
        return b.count < a.count;
    });
    sort(wb.begin(), wb.end(), [](const auto& a, const auto& b) -> bool
    {
        return b.count < a.count;
    });
    auto maxh = hb[0].count;
    auto maxw = wb[0].count;
    for(auto hi = hb.begin(); (*hi).count == maxh; hi++)
    {
        for(auto wi = wb.begin(); (*wi).count == maxw; wi++)
        {
            if(ps.find({wi->index, hi->index}) == ps.end())
            {
                cout << maxh + maxw << endl;
                return 0;
            }
        }
    }
    cout << maxh + maxw - 1 << endl;
    return 0;
}


Measured memory_bytes: 21936
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<int>;
using A = array<int, 2>;
using P = pair<int, int>;
constexpr int MOD{1000000000 + 7};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr array<int, 4> dx{1, 0, -1, 0}, dy{0, 1, 0, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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;
}
constexpr int div_roundup(int a, int b)
{
    return (a + b - 1) / b;
}

// vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));

// *****************************************************************************

void solve()
{
    int a, b;
    cin >> a >> b;

    int k2 = abs(a - b);
    if (k2 % 2 == 0)
        cout << k2 / 2 + min(a, b) << endl;
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
}

// *****************************************************************************

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

    solve();
}


Measured memory_bytes: 256
from collections import defaultdict


def main():
    _, _, m = map(int, input().split())

    row_dict = defaultdict(int)
    col_dict = defaultdict(int)
    row_col_dict = defaultdict(set)
    for _ in range(m):
        row, col = map(int, input().split())
        row_dict[row] += 1
        col_dict[col] += 1
        row_col_dict[row].add(col)

    max_row_val = max(row_dict.values())
    max_col_val = max(col_dict.values())

    max_rows = {k for k, v in row_dict.items() if v == max_row_val}
    max_cols = {k for k, v in col_dict.items() if v == max_col_val}
    ans = max_row_val + max_col_val - 1
    flg = False
    if ans < m:
        for row in max_rows:
            for col in max_cols:
                if not col in row_col_dict[row]:
                    ans += 1
                    flg = True
                    break
            if flg:
                break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 148884
#include <bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
 
const ll oo=1e18;
const int MOD=1000000007;
const int INF=1000000000;
const ld EPS=0.000000001;
 
string s1,s2,ans="";
int dp[3005][3005];
 
signed main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>s1>>s2;
    for(int i=1;i<=s1.length();++i) {
        for(int j=1;j<=s2.length();++j) {
            if(s1[i-1]==s2[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int i=s1.length(),j=s2.length();
    while(i>0&&j>0) {
        if(s1[i-1]==s2[j-1]) {
            ans=s1[i-1]+ans;
            --i;--j;
        }
        else {
            if(dp[i][j-1]>dp[i-1][j]) --j;
            else --i;
        }
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

int n;
int sum(int v){
  int res = 0;
  while(v){
    res += v % 10;
    v /= 10;
  }
  return res;
}
int calc(int v){
  return sum(v) + sum(n - v);
}
int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  cin >> n;
  int mn = n;
  for(int i = 1;i < n;i++){
    mn = min(mn, calc(i));
  }
  cout << mn;
}


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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
void Yes(){
  cout << "Yes" << endl;
}
void YES(){
  cout << "YES" << endl;
}
void No(){
  cout << "No" << endl;
}
void NO(){
  cout << "NO" << endl;
}
int main(){
  int i,j,N,M,number,count,K;
  count = 0;
  cin >> N >> M;
  
  vector<int> A(M);
  
  /* 1  2  3
     0  1  2 */
  for(i=0;i<N;i++){
    cin >> K;
  	for(j=0;j<K;j++){
      cin >> number;
      A.at(number-1)++;
    }
  }
  
  for(i=0;i<M;i++){
  	if(A.at(i) == N) count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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


// 素数判定
bool is_prime(ll N) {
    if (N == 1) return false;
    for (ll i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}


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


// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll N){
    vector<pair<ll, ll>> res;
    for(ll i = 2; i * i <= N; i++){
        if(N % i != 0)  continue;
        ll ex = 0;

        while(N % i == 0){
            ex++;
            N /= i;
        }

        res.push_back({i, ex});
    }

    if(N != 1)  res.push_back({N, 1});
    return res;
};


int main(){
    ll a, b;    cin >> a >> b;
    vector<P> fact_a = prime_factorize(a);
    vector<P> fact_b = prime_factorize(b);

    set<ll> st;
    for(int i = 0; i < fact_a.size(); i++){
        st.insert(fact_a[i].fs);
    }

    int res = 1;
    for(int i = 0; i < fact_b.size(); i++){
        if(!(st.find(fact_b[i].fs) == st.end())){
            res++;
        }
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

namespace BIT_ {
	using RET = int;
	constexpr int BUF = 2123456;
	int ptr = 0;
	RET t[BUF];
	inline RET* get(const int size) {
		return t;
	}
}
//[1,n],0は扱えない!
struct BIT {
	using T = BIT_::RET;
	T* bit;
	int sz;
	BIT(int n) :bit(BIT_::get(n + 10)), sz(n) {
		fill(bit, bit + n + 10, 0);
	}
	T sum(int i) {
		T s = 0;
		while (i>0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	T sum(int lb, int ub) {
		return sum(ub) - sum(lb - 1);
	}
	void add(int i, T x) {
		while (i <= sz) {
			bit[i] += x; i += i & -i;
		}
	}
};

int N;
LL a[112345];
int b[112345];
int c[112345];
bool f(LL x) {
	LL ok = 0, ng = 0;
	c[0] = N + 10;
	for (int i : range(N)) {
		if (a[i] >= x)b[i] = 1;
		else b[i] = -1;
		c[i + 1] = b[i] + c[i];
	}
	BIT bit(3 * N + 100);
	bit.add(c[0], 1);
	for (int i : range(N)) {
		LL o = bit.sum(c[i + 1]);
		LL n = i + 1 - o;
		ok += o;
		ng += n;
		bit.add(c[i + 1], 1);
	}
	//cout << x << " " << ok << " " << ng << endl;
	return ok >= ng;
}
int main() {
	cin >> N;
	for (int i : range(N)) {
		cin >> a[i];
	}
	LL ub = 1e10;
	LL lb = 0;
	while (ub - lb > 1) {
		const int mid = (lb + ub) / 2;
		(f(mid)? lb : ub) = mid;
	}
	cout << lb << endl;

	return 0;
}


Measured memory_bytes: 4224
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b
def ceil(x):
    return math.ceil(x)
def floor(x):
    return math.floor(x)

def main():
    N = int(input())

    ans = 0
    for a in range(1, N + 1):
        for b in range(a, N + 1):
            if a * b > N - 1:
                break
            else:
                ans += 1
                if a != b:
                    ans += 1
    print(ans)







if __name__ == '__main__':
    main()


Measured memory_bytes: 78428
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 
  typedef pair<double,double> PDD;

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const double MAX_V = 100.5;

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<double> t(N);
  vector<double> t_(N+1);
  vector<double> v(N);
  rep(i,N) cin >> t[i];
  rep(i,N) cin >> v[i];
  t_[0] = 0.0;
  rep(i,N) t_[i+1] = t_[i]+t[i];
  double T = t_[N];
  double time = 0.0;
  vector<double> w((int)T*2+1);
  while(time <= T){
    double v_ = MAX_V;
    v_ = min(v_,time);
    v_ = min(v_,T-time);
    rep(i,N){
      if(time <= t_[i]) v_ = min(v_, v[i] + t_[i] - time);
      else if(time <=t_[i+1]) v_ = min(v_, v[i]);
      else v_ = min(v_, v[i] + time -t_[i+1]);
    }
    int index =  (int)2*time;
    w[index] = v_;
    time+=0.5;
  }
  double ans = 0.0;
  rep(i,w.size()-1) ans += 0.25*(w[i]+w[i+1]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
    int countTable[128]={0};
    char ch;
    while((ch = getchar()) != EOF){
        countTable[ch]++;
    }
    for(int i=97;i<123;i++)
    printf("%c : %d\n",i,countTable[i]+countTable[i-32]);
}


Measured memory_bytes: 2680
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    long long ans = 0;
    long long left = 0, right = 0;
    int temp = a[0];
    while (right < n) {
        if ((temp & a[right+1]) != 0) {
            while ((temp & a[right+1]) != 0) {
                ans += right - left + 1;
                temp ^= a[left++];
            }
        }
        right++; temp |= a[right];
    }
    ans += (n - left) * (n - left + 1) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 1024
cards = [[0 for i in range(13)] for j in range(4)]
s2n = {'S': 0, 'H': 1, 'C': 2, 'D': 3}
n2s = 'SHCD'
n = int(input())
for i in range(n):
    card = list(input().split())
    card[1] = int(card[1])
    if card[0] == 'S':
        suit = 0 
    elif card[0] == 'H':
        suit = 1 
    elif card[0] == 'C':
        suit = 2 
    elif card[0] == 'D':
        suit = 3 
    cards[suit][card[1]-1] = 1
for i in range(4): 
    for j in range(13):
        if not(cards[i][j]):
            print(n2s[i], j+1)

Measured memory_bytes: 7744
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(a*b, c);
    return 0;
}

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

int a[10];

int main() {
	int T;
	cin >> T;
	while (T--) {
		bool ans = true;
		for (int i = 0; i < 10; ++i) {
			cin >> a[i];
		}
		int l, r;
		l = r = 0;
		for (int i = 0; i < 10; ++i) {
			if (a[i] > l) {
				l = a[i];
			} else if (a[i] > r) {
				r = a[i];
			} else {
				ans = false;
				break;
			}
		}
		cout << (ans ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
typedef long long int ll;

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

typedef long long int ll;

int n, a, b;
int main(void){
	cin >> n >> a >> b;
	cout << min(a,b) << " " << max(0, a+b-n) << endl;
	


    return 0;
}


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

int N;
double D;
double X[200005],Y[200005];
int ans;

signed main(){
    cin>>N>>D;
    for(int i=0;i<N;++i){
        double x,y;
        cin>>x>>y;
        double d=sqrt(x*x+y*y);
        if(d<=D)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3844
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    
    queue<int> que;
    
    int ans=0;
    int temp=0;
    int one_zero=0;
    
    for(int i=0; i<N; i++){
        if(S[i]=='0'){
            if(i==0 || S[i-1]=='1'){
                K--;
                if(K<0){
                    temp-=que.front();
                    que.pop();
                    K++;
                }
            }
            temp++;
            
        }else if(S[i]=='1'){
            if(i!=0 && S[i-1]=='0'){
                que.push(one_zero);
                one_zero=0;
            }
            
            temp++;
        }
        
        ans=max(ans,temp);
        one_zero++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define sync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define repp(i,a,n) for(int i=a; i<int(n); ++i)
#define sz(x) (x).size()
#define pq priority_queue
#define pb push_back
#define mp make_pair

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T> &input){for (auto const& i: input) {os << i << " ";}return os;}
template<class T1,class T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1,T2> &input){os << "(" << input.first << ", " << input.second << ')';return os;}

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<pi> vp;
typedef vector<ll> vl;
typedef vector<vi> vvi;


const int maxn = 50;

void pre(){
}

void solve(){
	int x, n;
	cin >> x >> n;
	vi a(200, 0);
	rep(i,n){
		int y;
		cin >> y;
		a[y] = 1;
	}

	rep(i,101){
		int y = x - i;
		if(a[y] == 0){
			cout << y;
			return;
		}
		y = x + i;
		if(a[y] == 0){
			cout << y;
			return;
		}
	}

}


int main() {
    sync;
    int cas = 1;
    // cin >> cas;
    pre();
    rep(ca, cas) solve();
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int max(int a, int b){
    if(a>=b)return a;
    else return b;
}
int main(){
    int n;cin>>n;
    vector<int > dp(3,0);
    for(int k=0;k<n;k++){
        vector<int > new_dp(3,0);
        vector<int > costs(3,0);
        cin>>costs[0]>>costs[1]>>costs[2];
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(i!=j)new_dp[i] = max(new_dp[i],dp[j]+costs[i]);
            }
        }
        dp = new_dp;
    }
    cout<<max(max(dp[0],dp[1]),dp[2]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000000000
int main() {
    int N, M;
    cin >> N >> M;
    int a[N];
    bool broken[N];
    for(int i = 0; i < N; i++) {
        broken[i] = true;
    }
    long long int dp[N+1] = {};
    dp[0] = 1;
    dp[1] = 2;
    for(int i = 0; i < M; i++) {
        cin >> a[i];
        broken[a[i]-1] = false;
        dp[a[i]-1] = INF;
    }
    if(dp[0] == INF && dp[1] != INF) {
        dp[1] = 1;
    }

    for(int i = 2; i < N; i++) {
        if(broken[i]) {
            if(dp[i-1] == INF && dp[i-2] == INF) {
                cout << 0 << endl;
                return 0;
            }
            dp[i] += dp[i-1]%INF + dp[i-2]%INF;
            dp[i] %= 1000000007;
        }
    }
    if(dp[N-1] == INF) {
        dp[N-1] = 0;
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if (a>0)
    {
        cout<<"Positive";
        return 0;
    }
    if (a<=0&&b>=0)
    {
        cout<<"Zero";
        return 0;
    }
    if (b<0)
    {
        if ((b-a)%2==0) cout<<"Negative";
        else cout<<"Positive";
    }
    return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-

"""
参考：https://emtubasa.hateblo.jp/entry/2019/02/12/003250
・問題の意味読み違えてた。
　A*2枚のビスケットがあったら2円分換金していいと思ってた。
　どうりでビスケット増え過ぎると思った。
"""

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

K,A,B=MAP()

rate=B/A
rest=K-(A-1)
bis=A

bis+=(B-A)*(rest//2)+(rest%2)

print(max(bis, K+1))


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>


using namespace std;


int main()
{
	char* ara = "IVXLCDM";
	int num[] = { 1, 5, 10, 50, 100, 500, 1000 };

	char buf[101];
	while (scanf("%s\n", buf) != EOF)
	{
		int len = strlen(buf);
		int n[100];
		for (int i = 0; i < len; ++i)
		{
			for (int j = 0; j < 7; ++j)
			{
				if (buf[i] == ara[j])
				{
					n[i] = num[j];
					break;
				}
			}
		}
		for (int i = 0; i < len-1; ++i)
			n[i] *= n[i] < n[i+1] ? -1 : 1;

		int res = 0;
		for (int i = 0; i < len; ++i)
			res += n[i];

		printf("%d\n", res);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int n, a, b;
  while(cin >>n >>a >>b && n){
    vector<bool> v(n + 5, false);
    for(int i = a; i < v.size(); i += a) v[i] = true;
    for(int i = b; i < v.size(); ++i) if(i % b == 0 || v[i - b]) v[i] = true;
    int cnt = 0;
    FOR(i, 1, n + 1) if(!v[i]) ++cnt;
    cout <<cnt <<endl;
  }
  return 0;
}

Measured memory_bytes: 1316