akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  ll N; cin >> N;
  vector<pair<ll,ll>> AB(N); rep(i,N) cin >> AB[i].first >> AB[i].second;
  ll ans = 0;
  if(N%2==0){
    vector<ll> d(N);
    vector<ll> u(N);
    rep(i,N){
      d[i]=AB[i].first;
      u[i]=AB[i].second;
    }
    sort(all(d));
    sort(all(u));
    ll d1=d[N/2];
    ll d2=d[N/2-1];
    ll u1=u[N/2];
    ll u2=u[N/2-1];
    ll dd = d1+d2;
    ll uu = u1+u2;

    ans = (uu-dd+1);
  }
  else{
    vector<ll> d(N);
    vector<ll> u(N);
    rep(i,N){
      d[i]=AB[i].first;
      u[i]=AB[i].second;
    }
    sort(all(d));
    sort(all(u));
    ans = u[N/2] - d[N/2] + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9544
import Data.List
main=putStrLn.unwords.map show.solve.sort.map(read).words=<<getContents
solve(_:xs)=((\x y->[max(signum y)x,x+y])<$>f.takeWhile(<8)<*>length.dropWhile(<8)).map(`div`400)$xs
f[]=0
f(x:xs)=1+f(dropWhile(==x)xs)

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

int gcd(int x, int y) {
  if (y > x) swap(x, y);

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

int main() {
  int x, y;

  cin >> x >> y;
  cout << gcd(x, y) << endl;

  return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define random(a, b) rand()*rand()%(b-a+1)+a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 50 + 10;
const int mod = 1e9+7;
int a[maxn];
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    IOS
    int n;
    scanf("%d", &n);
    for(int i = 1; i<=n; i++) scanf("%d", &a[i]);

    int Max = -inf, maxPose;
    int Min = inf , minPose;
    for(int i = 1; i<=n; i++) {
        if(a[i]>Max)    Max = a[i], maxPose = i;
        if(a[i]<Min)    Min = a[i], minPose = i;
    }
    printf("%d\n", 2*n-1);
    if(abs(Max) > abs(Min)) {
        for(int i = 1;i<=n;i++)
            if(i!=maxPose)
                printf("%d %d\n", maxPose, i);
        printf("%d %d\n", maxPose, maxPose);
        for(int i = 1;i<n;i++)
            printf("%d %d\n", i, i+1);
    }else{
        for(int i = 1;i<=n;i++)
            if(i!=minPose)
                printf("%d %d\n", minPose, i);
        printf("%d %d\n", minPose, minPose);
        for(int i = n;i>1;i--)
            printf("%d %d\n", i, i-1);
    }
    return 0;
}


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

namespace ABC170
{

  class B
  {
  public:
    B() = default;
    ~B() = default;


    void Run()
    {
      int X, Y;
      std::cin >> X;
      std::cin >> Y;

      int min = X * 2;
      int max = X * 4;

      bool yes = (min <= Y) && (Y <= max) && (Y % 2 == 0);

      std::cout << (yes ? "Yes" : "No") << std::endl;
    }
  };

}
int main()
{

  ABC170::B prob;
  prob.Run();

  int a;
  std::cin >> a;
  return 0;
}



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

int main() {
  int64_t INT = 1000000007;
  string S;
  cin >> S;
  int length = S.size();
  vector<vector<int64_t>> dp(length + 1, vector<int64_t> (13));
  dp.at(0).at(0) = 1;
  for(int i = 0; i < length; i++) {
    if(S.at(i) != '?') {
      for(int j = 0; j < 13; j++) {
        int a = S.at(i) - '0';
        dp.at(i + 1).at((j * 10 + a) % 13) = dp.at(i).at(j);
      }
    }
    else {
      for(int k = 0; k < 10; k++) {
        for(int j = 0; j < 13; j++) {
          dp.at(i + 1).at((j * 10 + k) % 13) += dp.at(i).at(j);
          dp.at(i + 1).at((j * 10 + k) % 13) %= INT;
        }
      }
    }
  }
  cout << dp.at(length).at(5) << endl;
}

Measured memory_bytes: 16744
n = int(input())
x = [0] * n
y = [0] * n

for i in range(n):
    x[i], y[i] = map(int, input().split())

table = {}

for i in range(n - 1):
    for j in range(i + 1, n):
        dx = x[i] - x[j]
        dy = y[i] - y[j]
        if (dx, dy) not in table:
            table[(dx, dy)] = 1
            table[(-dx, -dy)] = 1
        else:
            table[(dx, dy)] += 1
            table[(-dx, -dy)] += 1

m = 0

for key, value in table.items():
    m = max(m, value)

print(n - m)


Measured memory_bytes: 67976
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    while (x % 2 == 0) {
		        x /= 2;
		        count++;
		    }
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 34352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

struct Node{
	int key;
	Node *prev, *next;
};

Node *nil;

Node* listSearch(int key){
	Node *cur = nil->next;
	while(cur != nil && cur->key != key)
	{
		cur = cur->next;
	}
	return cur;
}

void init(){
	nil = (Node *)malloc(sizeof(Node));
	nil->prev = nil;
	nil->next = nil;
}

void printList(){
	Node *cur = nil->next;
	int j = 0;
	while(1)
	{
		if (cur == nil)
		{
			break;
		}
		if (j > 0)
		{
			printf(" ");
		}
		printf("%d", cur->key);
		cur = cur->next;
		j++;
	}
	printf("\n");
	return;
}

void deleteNode(Node *t){
	if (t == nil)
	{
		return;
	}
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
	return;
}

void deleteFirst(){
	deleteNode(nil->next);
	return;
}

void deleteLast(){
	deleteNode(nil->prev);
	return;
}

void deleteKey(int key){
	deleteNode(listSearch(key));
	return;
}

void insert(int key){
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
	return;
}

int main()
{
	int key,n;
	char com[20];
	scanf("%d",&n);
	init();
	for (int i = 0; i < n; ++i)
	{
		scanf("%s%d", com, &key);
		if (com[0] == 'i')
		{
			insert(key);
		}
		else if (com[0] = 'd')
		{
			if (strlen(com) > 6)
			{
				if (com[6] == 'F')
				{
					deleteFirst();
				}
				else if(com[6] == 'L')
				{
					deleteLast();
				}	
			}
			else
			{
				deleteKey(key);
			}
		}
	}
	printList();
	return 0;
}


Measured memory_bytes: 34296
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
double dp[3003][3003];
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    double p[d5];
    for(int i=0;i<n;i++)cin>>p[i+1];  
    for(int i=0;i<3003;i++){
        for(int j=0;j<3003;j++)dp[i][j]=0;
    }
    //dp[i][j]:i枚のコインを投げてj枚が表である確率
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            dp[i][j]=dp[i-1][j]*(1-p[i]);
            if(j!=0)dp[i][j]+=dp[i-1][j-1]*p[i];
        }
    }
    double res=0;
    for(int j=0;j<3003;j++){
        if(j>n-j)res+=dp[n][j];
    }
    cout<<setprecision(15)<<res<<endl;
}

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

int main() {
	int N, K;
	string S;
	cin >> N >> K;
	cin >> S;
	if (S[K-1] == 'A')S[K-1] = 'a';
	if (S[K-1] == 'B')S[K-1] = 'b';
	if (S[K-1] == 'C')S[K-1] = 'c';
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
  int n;

  while(cin >> n){
    int cnt=0;
    for(int a=0;a<10;a++)
      for(int b=0;b<10;b++)
	for(int c=0;c<10;c++)
	  for(int d=0;d<10;d++)
	    if(a+b+c+d==n)cnt++;

    cout << cnt << endl;
  }


  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n;
LL sum;
bitset<4000030> dp; 
int main()
{
	scanf("%d",&n);
	dp[0]=1;
	for(int i=1;i<=n;i++)
	{
		int t;
		scanf("%d",&t);
		sum+=t;
		dp|=dp<<t;
	}
	for(int i=(sum+1)/2;i<=sum;i++)
	{
		if(dp[i])
		{
			printf("%d\n",i);
			return 0;
		}
	}
}

Measured memory_bytes: 1664
import sys
sys.setrecursionlimit(10**6)

H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]
mn = [[int(1e9) for j in range(10)] for i in range(10)]

def dfs(s, n, d):
    if n == 1:
        mn[s][n] = min(mn[s][n], d)
    else:
        if mn[s][n] <= d:
            return
        mn[s][n] = min(mn[s][n], d)
        for i in range(10):
            dfs(s, i, d+c[n][i])


for i in range(10):
    dfs(i, i, 0)

ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] == -1:
            continue
        ans += mn[A[i][j]][1]

print(ans)


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

using namespace std;
typedef long long ll;
const int MAXN = 200100;

int N, M;
int arr[MAXN];
ll sps[MAXN];
ll dps[MAXN]; // diff in adds
ll ans[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N >> M;
    for (int i = 0; i < N; i++)
        cin >> arr[i];

    for (int i = 0; i < MAXN; i++)
        sps[i] = dps[i] = 0;
    for (int i = 0; i < N - 1; i++)
    {
        int l = arr[i], r = arr[i+1];
        if (l < r) l += M;
        r += M;
        sps[r-M+1] += (r - l);
        dps[l+1]--;
        dps[r+1]++;
    }

    ans[0] = 0;
    for (int i = 1; i <= 2 * M; i++)
    {
        sps[i] = sps[i] + dps[i-1];
        dps[i] = dps[i] + dps[i-1];
        ans[i] = ans[i-1] + sps[i];
    }

    for (int i = 1; i <= M; i++)
        ans[i] += ans[M+i];

    ll res = 1e18;
    for (int i = 1; i <= M; i++)
        res = min (res, ans[i]);
    cout << res << "\n";
}

Measured memory_bytes: 5376
#include <iostream>
#include <cmath>

 using namespace std;
 typedef long long ll;

 int main(void){
 long double a,b,c;
 cin >> a >> b >> c;

 long double eps = 1.0E-14;

 if(sqrt(a) + sqrt(b) + eps < sqrt(c)){
 cout << "Yes" << endl;
 } else {
 cout << "No" << endl;
 }

 return 0;
 }

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

ans = 0
flag = "go"
while flag == "go":
    for i in range(N):
        if A[i] % 2 != 0:
            flag = "stop"
            break
        
    if flag == "go":
        for i in range(N):
            A[i] = A[i] / 2
        ans = ans + 1
        
print(ans)    

Measured memory_bytes: 3060
import java.util.*;

public class Main {

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

        if(N.charAt(0) == '7' || N.charAt(1) == '7' || N.charAt(2) == '7'){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}









Measured memory_bytes: 35660
#include<stdio.h>

int main()
{
	int a, b, c, r1, r2, r3;
	scanf("%d %d %d", &a, &b, &c);

	r1 = a + b;
	r2 = a + c;
	r3 = b + c;
	
	if(r1 <= r2 && r1 <= r3) printf("%d\n", r1);
	else if(r2 <= r1 && r2 <= r3) printf("%d\n", r2);
	else if(r3 <= r1 && r3 <= r2) printf("%d\n", r3);
	
	return 0;
}

Measured memory_bytes: 128
using System;

namespace ABC051B_SumofThreeIntegers
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int k = int.Parse(input[0]);
            int s = int.Parse(input[1]);

            int x = 0;
            int y = 0;
            int z = 0;

            int counter = 0;


            for (int indexX = 0; indexX <= k; indexX++)
            {
                x = indexX;

                for (int indexY = 0; indexY <= k; indexY++)
                {
                    y = indexY;
                    z = s - x - y;

                    if (0 <= z && z <= k)
                    {
                        counter++;
                    }

                }
            }



            Console.WriteLine(counter);

        }
    }
}


Measured memory_bytes: 11092
n=int(input())
s=input()
w_list=[0]
w_count=0
b_list=[0]
b_count=0
for i in s:
    if i=='.':
        w_count=w_count+1
        w_list.append(w_count)
        b_list.append(b_count)
    else:
        b_count=b_count+1
        w_list.append(w_count)
        b_list.append(b_count)
Min=n
for i in range(0,n+1):
    w_number=i-w_list[i]
    b_number=n-i-(b_list[n]-b_list[i])
    number=w_number+b_number
    if number<Min:
        Min=number
print(Min)
    


Measured memory_bytes: 12792
import sys
from copy import deepcopy
input = sys.stdin.readline

def partition(p, r):
    x = int(A[r][1])
    i = p
    for j in range(p, r):
        if int(A[j][1]) <= x:
            A[i], A[j] = A[j], A[i]
            i += 1
    A[i], A[r] = A[r], A[i]
    return i

def quick_sort(p, r):
    if p < r:
        q = partition(p, r)
        quick_sort(p, q-1)
        quick_sort(q+1, r)

def is_stable(original_list, sorted_list):
    for key, val in sorted_list:
        for original_key, original_val in original_list[:]:
            if val == original_val:
                if key != original_key:
                    print("Not stable")
                    return
                original_list.remove([original_key, original_val])
                break
    print("Stable")
    return
    
if __name__ == "__main__":
    n = int(input())
    A = [input().split() for _ in range(n)]
    A_original = deepcopy(A)
    quick_sort(0, n-1)
    is_stable(A_original, A)
    for key, val in A:
        print("{} {}".format(key, val))


Measured memory_bytes: 49864
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)


int main() {
	int n, ans = 0;
	cin >> n;
	string a, b, c;
	cin >> a >> b >> c;
	REP(i, n) {
		if (a[i] == b[i] and b[i] == c[i]) ans += 0;
		else if (a[i] == b[i] or a[i] == c[i] or c[i] == b[i])ans++;
		else ans += 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
	int ans=0;
	char s[4]={};
	char t[4]={};
	scanf("%s%s", s,t);
	for (int i = 0; i < 3; i++) {
		if(s[i]==t[i]){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
long = read :: String -> Integer
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = long . head . words
printer = unlines . (:[]) . show

solver x = sum $ filter (\x -> x`mod`3 /= 0 && x`mod`5 /= 0) $ [1..x]

Measured memory_bytes: 4928
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
int dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};


int main(int argc, char const *argv[]) {
  ll a,b,c;
  std::cin >> a >> b >> c;
  ll s=a/2,t=b/2,u=c/2;
  ll ans1=abs(a*b*u-a*b*(c-u));
  ll ans2=abs(a*t*c-a*c*(b-t));
  ll ans3=abs(s*b*c-c*b*(a-s));

  std::cout << min(min(ans1,ans2),ans3) << '\n';



  return 0;
}


Measured memory_bytes: 256
<?php
define('MOD', 10 ** 9 + 7);
fscanf(STDIN, '%d %d', $x, $y);
$y_step = (2 * $y - $x) / 3;
$x_step = (2 * $x - $y) / 3;
if ($y_step != (int) $y_step || $y_step < 0 || $x_step <0) {
    echo 0;
    exit;
}
echo nCr($y_step + $x_step, $y_step);

// 足し算
function modAdd($x, $y)
{
    return ($x + $y) % MOD;
}

// 引き算
function modSub($x, $y)
{
    return ($x + MOD - $y) % MOD;
}

// 掛け算
function modMul($x, $y)
{
    return ($x * $y) % MOD;
}

// 割り算
function modDiv($x, $y)
{
    return modMul($x, modPow($y, MOD - 2));
}

// 累乗（繰り返し二乗法）
function modPow($n, $x)
{
    if ($x === 0) return 1;
    $res = (modPow($n, $x >> 1) ** 2) % MOD;
    if ($x & 1) $res = modMul($res, $n);
    return $res;
}

// 階乗
function modFac($n)
{
    if ($n === 0) return 1;
    return modMul($n, modFac($n - 1));
}

// 順列
function nPr($n, $r)
{
    if ($r === 0) return 1;
    return modDiv(modFac($n), modFac($n - $r));
}

// 組み合わせ
function nCr($n, $r)
{
    $r = min($r, $n - $r);
    return modDiv(nPr($n, $r), modFac($r));
}

Measured memory_bytes: 266744
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1000000007

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

int main() {
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    int sum = 0;
    int arr[n];
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        sum += arr[i];
    }
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        if(arr[i] >= (sum + 4 * m - 1) / (4 * m)) cnt++;
    }
    if(cnt >= m) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
S = input()
K = int(input())
N = len(S)
substrs = set()

for i in range(N):
    cur = S[i]
    if cur not in substrs:
        substrs.add(cur)
    for j in range(i + 1, min(N, i + 6)):
        cur += S[j]
        if cur not in substrs:
            substrs.add(cur)

substrs = sorted(substrs)
print(substrs[K - 1])


Measured memory_bytes: 4936
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV], lcp[MV];
ll arr[MV];

void solve(int T)
{
	int n;
	string s;
	cin>>n>>s;
	string z = "ABC#" + s;
	int m = (int)z.sz();
	for(int i=1;i<m;i++)
	{
		int j = lcp[i-1];
		while(j && (z[i] != z[j]))
		j = lcp[j-1];
		if(z[i] == z[j])
		j++;	
		lcp[i] = j;
	}
	int ct = 0;
	for(int i=3;i<m;i++)
	{
		if(lcp[i] == 3)
		ct++;	
	}
	cout<<ct<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
const ll md = 1000000007;

ll add(ll a, ll b, ll mod = md) {
    return (a%mod + b%mod + mod)%mod;
}

ll mul(ll a, ll b, ll mod = md) {
    return (a%mod * b%mod + mod)%mod;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = n/2;
        x = (x*x)%mod;
    }
    return res;
}

ll power2(ll x, ll n) {
    ll res = 1;
    while (n) {  
        if (n & 1) res = (res*x);
        n = n/2;
        x = (x*x);
    }  
    return res;
}

ll lg(ll k, ll e) {
	ll i, x = k;
	for(i = 0; ; i++, x = x*k) {
		if(x > e) {
			break;
		}
	}
	return i;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long double a, b;
    cin >> a >> b;
    ll res = a*b;
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3744
#include <stdio.h>

int main(int ac, char **argv) {
  int N, i, a, b, c;
  scanf("%d", &N);
  for(i = 0; i < N; i++) {
    scanf("%d %d %d", &a, &b, &c);
    printf("%s\n", (a*a+b*b==c*c || b*b+c*c==a*a || c*c+a*a==b*b) ? "YES" : "NO");
  }
  return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p.at(i);
    }
    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        if (i + 1 == p[i]) {
            ans++;
            swap(p[i], p[i + 1]);
        }
    }
    if (N == p[N - 1]) {
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
n = gets.to_i
words = []
n.times do
  words << gets.to_s
end
if words.size != words.uniq.size
  puts "No"
else
  result = true
  words.size.times do |i|
    next if i == 0
    result = false if words[i-1][-2] != words[i][0]
  end
  puts result ? "Yes" : "No"
end


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

int A[55];
bool boleh[55];
int B[55];
int C[55];
int indx[55];
long long ncr[55][55];

long long ncrUpTo[55][55];

int main(){
    int N, K, S, T;
    scanf("%d%d%d%d", &N, &K, &S, &T);

    if( ((S&T) == S) && ((S|T) == T) ){
    }else{
        printf("0");
        return 0;
    }

    memset(ncr, 0, sizeof(ncr));
    ncr[0][0] = 1;
    for(int i = 1; i <= N; i ++){
        ncr[i][0] = 1;
        for(int j = 1; j <= i; j ++){
            ncr[i][j] = ncr[i-1][j] + ncr[i-1][j-1];
        }
    }

    ncrUpTo[0][0] = 0;
    for(int i = 1; i <= N; i ++){
        ncrUpTo[i][0] = 0;
        for(int j = 1; j <= N; j ++){
            ncrUpTo[i][j] = ncrUpTo[i][j-1] + ncr[i][j];
        }
    }

    for(int i = 0; i < N; i ++){
        scanf("%d", &A[i]);
        boleh[i] = true;
        //printf("A[%d]=%d\n", i, A[i]);
    }

    int L = 0;
    for(int i = 0; i < 20; i ++){
        if( (S&(1<<i)) == (T&(1<<i)) ){
            for(int j = 0; j < N; j ++){
                if( (S&(1<<i)) != (A[j]&(1<<i)) ){
                    boleh[j] = false;
                    //printf("boleh[%d]=false\n", j);
                }
            }
        }else{
            indx[L ++] = i;
        }
    }

    for(int i = 0; i < L; i ++){
        for(int j = 0; j < N; j ++){
            if(A[j]&(1<<indx[i])){
                B[j] |= (1<<i);
            }
        }
    }

    int M = 0;
    for(int i = 0; i < N; i ++){
        if(boleh[i]){
            C[M ++] = B[i];
        }
    }

    for(int i = 0; i < M; i ++){
        //printf("C[%d]=%d\n", i, C[i]);
    }

    long long ans = 0;
    for(int U = 0; U < (1<<L); U ++){
        long long f = 0;

        set<int> s;
        multiset<int> ms;
        for(int i = 0; i < M; i ++){
            s.insert(U&C[i]);
            ms.insert(U&C[i]);
        }

        for(int j: s){
            int cnt = ms.count(j);
            f += ncrUpTo[cnt][K];
        }

        int temp = __builtin_popcount(U);
        if(temp&1){
            ans -= f;
        }else{
            ans += f;
        }
    }

    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){
  int n,vlen;
  string str,ans;
  set<string> s;
  vector<string> v;
  vector<P> defdata;//1,0
  string d[15]={
    "Rock","Fire","Scissors","Snake","Human",
    "Tree","Wolf","Sponge","Paper","Air",
    "Water","Dragon","Devil","Lightning","Gun"
  };
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++){
      cin>>str;
      s.insert(str);
    }
    for(int i=0;i<15;i++){
      set<string>::iterator ite;
      for(ite=s.begin();ite!=s.end();ite++){
	if(d[i]==(*ite)){
	  v.push_back(d[i]);
	  defdata.push_back(P(0,0));
	}
      }
    }
    vlen=v.size();
    for(int i=0;i<vlen;i++){
      for(int j=i+1;j<vlen;j++){
	int iid,jid;
	for(int k=0;k<15;k++)
	  if(v[i]==d[k])iid=k;
	for(int k=0;k<15;k++)
	  if(v[j]==d[k])jid=k;
	if(jid-iid<=7){
	  defdata[i].first++;
	  defdata[j].second++;
	}
	if(iid+15-jid<=7){
	  defdata[j].first++;
	  defdata[i].second++;
	}
      }
    }
    ans="0";
    for(int i=0;i<vlen;i++){
      int w=defdata[i].first;
      int l=defdata[i].second;
      if(w&&!l)ans=v[i];
    }
    if(ans!="0")cout<<ans<<endl;
    else cout<<"Draw"<<endl;
    s.clear();
    v.clear();
    defdata.clear();
  }
  return 0;
}

Measured memory_bytes: 1216
cat<<EOF>Source.cpp
#include <iostream>
#include <vector>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int max(int a,int b){
	return a>b?a:b;
}
int x[100000],y[100000],x_mod_k[100000],x_div_k[100000];
char s[100000][2];
int n,k;

void add(vector<int>&cnt,int x,int t){
	if((x_div_k[x]&1)==0){
		if(t==0){
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
		else{
			cnt[k-x_mod_k[x]]++;
		}
	}
	else{
		if(t==0){
			cnt[k-x_mod_k[x]]++;
		}
		else{
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
	}
}
int ans[2000];
int main(){
	scanf("%d%d",&n,&k);
	rep(i,n){
		scanf("%d%d%s",&x[i],&y[i],s[i]);
		x_mod_k[i]=y[i]%k;
		x_div_k[i]=y[i]/k;
	}
	int Max=0;
	#pragma omp parallel for schedule(dynamic, 1) num_threads(20)
	rep(i,k){
		vector<int>cnt(max(n,k));
		rep(j,n){
			if(s[j][0]=='B'){
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,0);
				}
				else{
					add(cnt,j,1);
				}
			}
			else{
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,1);
				}
				else{
					add(cnt,j,0);
				}
			}
		}
		rep(j,k){
			if(j)cnt[j]+=cnt[j-1];
			ans[i]=max(ans[i],max(cnt[j],n-cnt[j]));
		}
	}
	rep(i,k)Max=max(Max,ans[i]);
	cout<<Max<<endl;
}
EOF
g++ -O3 Source.cpp -o Source -fopenmp -std=c++11
./Source

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

int main(){
  int a, b, k, maxnum = 0, ans = 0;
  cin >> a >> b >> k;
  
  if(a > b) maxnum = a;
  else maxnum = b;

  int num = 0;
  for(int i = maxnum; i >=1; --i){
    if((a % i == 0) && (b % i == 0)){
      ans = i;
      ++num; 
    }
    if(num == k) break;
  } 
  cout << ans << endl;
  return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	vector<long double> A(N);
	long double max_ = 0;
	for (int i=0;i<N;i++) {
		cin >> A.at(i);
		max_ = max(max_, A[i]);
	}

	long double ok = max_;
	long double ng = 0;
    while (ok-ng > 0.0000000001) {
        long double mid = (ok+ng)/2;
        long cnt = 0L;
        for (int i=0;i<N;i++) {
            cnt += floor(A[i]/(mid+0.000000000005));
        }
            if (cnt > K) {
                ng = mid;
            } else { // cnt <= K
                ok = mid;
            }
    }
    // cout << ok << endl;
    cout << (int)(ceil(ok-0.0000000005)) << endl;
}

Measured memory_bytes: 6364
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

int A[maxn][4],B[4],C[maxn],c[maxn];

int inv[2];

void add(int x){
	for(;x<=n;x+=x&-x)c[x]^=1;
}

int query(int x){
	int ans=0;
	for(;x;x-=x&-x)ans^=c[x];
	return ans;
}

void Work(){
	REP(i,1,n){
		REP(j,1,3)B[j]=A[i][j];
		sort(B+1,B+4);
		if(B[2]!=B[1]+1||B[3]!=B[2]+1||B[3]%3!=0||B[2]!=A[i][2]||(B[3]/3-i)%2!=0)return void(puts("No"));
		if(A[i][1]>A[i][3])inv[i&1]^=1;
		C[i]=B[3]/3;
	}
	for(int i=n;i>=1;i-=2){
		inv[(n-1)&1]^=query(C[i]);
		add(C[i]);
	}
	memset(c,0,sizeof(c));
	for(int i=n-1;i>=1;i-=2){
		inv[n&1]^=query(C[i]);
		add(C[i]);
	}
	if(inv[0]||inv[1])puts("No");else puts("Yes");
}

void Init(){
	read(n);
	REP(j,1,3)REP(i,1,n)read(A[i][j]);
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

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

        if(s.equals("Sunny")){
            System.out.println("Cloudy");
        } else if(s.equals("Cloudy")){
            System.out.println("Rainy");
        } else {
            System.out.println("Sunny");
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
int main(){
	long long A, B ,C, K;
	cin >> A >> B >> C >> K;
	long long sum = 0;
	for (int i = 0; i<K; i++){
		if(A){
			sum+=1;
			A--;
		}else if(B){
			B--;
		}else if(C){
			sum-=1;
			C--;
		}
	}
		cout << sum;
}



Measured memory_bytes: 3624
while n = STDIN.gets
  n = n.chomp.to_i
  if n == 0 then break end
  sum = {}
  n.times do 
    line = STDIN.gets
    ipq = line.chomp.split(" ").map { |item| item.to_i } 
    if sum.has_key?(ipq[0]) == false then
      sum[ipq[0]]=0
    end
    sum[ipq[0]] += ipq[1]*ipq[2] 
  end
  flag=true
  sum.keys.each do |k|
    if sum[k] >= 1000000 then
      puts k
      flag=false
    end
  end
  if flag then
    puts "NA"
  end
end

Measured memory_bytes: 8788
n=gets.to_i
arr = n.times.map{gets.split}

n.times{|i|
    arr[i][1]=arr[i][1].to_i
    arr[i][2]=i+1
}

arr = arr.sort{|a,b| (a[0] <=> b[0]).nonzero? || (b[1] <=> a[1])}

n.times{|i|
    puts arr[i][2]
}

Measured memory_bytes: 1788
N,M = map(int,input().split())
ac,wa = 0,0
task = [0]*N
# print(task)
for m in range(M):
    p,s = input().split()
    p = int(p)-1
    if task[p] != -1 and s == "WA":
        task[p] += 1
    elif task[p] != -1 and s == "AC":
        ac += 1
        wa += task[p]
        task[p] = -1
#print(task)
print(ac,wa)

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

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    sx += 1000;
    sy += 1000;
    tx += 1000;
    ty += 1000;
    string ans;
    //一度目往復
    REP(i, tx - sx) ans += "R"; //上回り
    REP(i, ty - sy) ans += "U";
    REP(i, tx - sx) ans += "L"; //下回り
    REP(i, ty - sy) ans += "D";
    
    //二度目往復
    ans += "L";
    REP(i, ty - sy + 1) ans += "U";
    REP(i, tx - sx + 1) ans += "R";
    ans += "D";

    ans += "R";
    REP(i, ty - sy + 1) ans += "D";
    REP(i, tx - sx + 1) ans += "L";
    ans += "U";

    cout << ans << endl;

    return 0;
}


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

public class Pg
{
    public static void Main()
    {
        var dict = new Dictionary<int, int>();
        var lst = new List<int>();
        string line;
        while ((line = Console.ReadLine()) != "0,0")
        {
            var n = line.Trim().Split(',').Select(int.Parse).ToArray();
            dict[n[0]] = n[1];
            lst.Add(n[1]);
        }
        lst = lst.Distinct().ToList();
        while ((line = Console.ReadLine()) != null)
        {
            var tmp = dict[int.Parse(line.Trim())];
            Console.WriteLine(lst.Count(x => x > tmp) + 1);
        }
    }
}



Measured memory_bytes: 14392
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACandyDistributionAgain solver = new ACandyDistributionAgain();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACandyDistributionAgain {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt(), x = in.nextInt();
            int[] a = in.nextIntArray(n);
            Arrays.sort(a);

            for (int i = 0; i < n; i++) {
                if (a[i] > x) {
                    out.println(i);
                    return;
                } else {
                    x -= a[i];
                }
            }
            if (x == 0) {
                out.println(n);
            } else {
                out.println(n - 1);
            }
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

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

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
/**
*    author:  Dooloper
*    created: 16.09.2020 23:43:27
**/

#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
using ll = long long;

#define rep(i,n) for(int i = 0; i < (n); i++)
#define repn(i,n) for(int i = 1; i <= (n); i++)
#define pb push_back
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

const double PI = acos(-1);
const int mod = 1000000007;
class mint {
   long long x;
public:
   mint(long long 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;
       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;
   }

   friend ostream& operator<<(ostream& os, const mint& m){
       os << m.x;
       return os;
   }
};
#pragma endregion

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  ll ans = 0;
  rep(i,n){
    int b;
    cin >> b;
    if(i == 0){
      a[i] = b;
      continue;
    }
    if(b < a[i-1]){
      ans += a[i-1] - b;
      a[i] = a[i-1];
    }else{
      a[i] = b;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3976
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define EPS (1e-10)

int main(){
  int n;
  double r, theta;
  cin >> n >> r >> theta;
  theta *= acos(-1)/180;
  vector<int> X(n), Y(n);
  for(int i = 0; i < n; ++i) cin >> X[i] >> Y[i];
  vector< vector< pair<double,int> > > G(n*n);

  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      if(j == i) continue;
      for(int k = 0; k < n; ++k){
        if(k == j) continue;
        int x1 = X[j] - X[i], y1 = Y[j] - Y[i], x2 = X[k] - X[j], y2 = Y[k] - Y[j];
        if(acos((x1*x2+y1*y2)/hypot(x1,y1)/hypot(x2,y2)) <= theta + EPS){
          G[i*n+j].push_back(make_pair(hypot(x2,y2),j*n+k));
        }
      }
    }
  }

  bool f = false;
  int ans = 0;
  vector<int> V;
  vector<double> dp(n*n,0);
  for(int i = 1; i < n; ++i){
    int x1 = X[i] - X[0], y1 = Y[i] - Y[0];
    if(hypot(x1,y1) <= r + EPS){
      f = true;
      dp[i] = r - hypot(x1,y1);
      V.push_back(i);
    }
  }
  while(f){
    f = false;
    ++ans;
    vector<double> dp_(n*n,0);
    vector<int> V_;
    for(int i = 0; i < V.size(); ++i){
      int v = V[i];
      for(int j = 0; j < G[v].size(); ++j){
        double c = G[v][j].first;
        int v_ = G[v][j].second;
        if(c <= dp[v] + EPS){
          f = true;
          if(dp_[v_] <= EPS) V_.push_back(v_);
          dp_[v_] = max(dp_[v_],dp[v]-c);
        }
      }
    }
    dp = dp_;
    V = V_;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3716
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char **argv)
{
	int n, t, tmp, st;
	int *array;
	cin >> t;
	
	for(int i = 0, up = 0, down = 0; i < t; i++, up = 0, down = 0){
		cin >> n;
		cin >> st;
		for(int j = 1; j < n; j++){
			cin >> tmp;
			st -= tmp;
			
			if(st < 0 && up > st){
				up = st;
			} else if(down < st){
				down = st;
			}
			
			st = tmp;
		}
		
		cout << (-up) << " " << down << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    int n; cin >> n;
    vint a(n); rep(i, n) cin >> a[i];
    sort(all(a));
    cout << (a.back() - a[0]) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<queue>
#include<string>
using namespace std;

#if 0

#endif

int N, Q, SumofTime=0;
queue<int> timeQ;
queue<string> nameQ;

int main(){
  cin >> N >> Q;
  for(int i = 0; i < N; ++i){
    string nameBuff;
    int timeBuff;
    cin >> nameBuff >> timeBuff;
    nameQ.push(nameBuff);
    timeQ.push(timeBuff);
  }
  while(!timeQ.empty()){//要素がある間
    int timeHead = timeQ.front(); string nameHead = nameQ.front();
    timeQ.pop(); nameQ.pop();

  if(timeHead <= Q){//先頭のプロセスが終了する場合
    SumofTime += timeHead;
    cout << nameHead << " " << SumofTime << endl;
  } else {//終了しない場合
    SumofTime += Q;
    timeQ.push(timeHead-Q);nameQ.push(nameHead);
    }
  }
}



Measured memory_bytes: 5680
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t H, W, N;
    std::cin >> H >> W >> N;

    std::vector<int64_t> A;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }

    boost::multi_array<int64_t, 2> mat(boost::extents[H][W]);

    auto citr = A.begin();
    int64_t col = 1;
    int64_t rem = *citr;


    for (int64_t h = 0; h < H; ++h) {
        for (int64_t w = 0; w < W; ++w) {
            mat[h][w] = col;
            rem--;
            if (rem == 0) {
                citr++;
                col++;
                if (citr == A.end()) {
                    break;
                }
                rem = *citr;
            }
        }
    }

    for (int64_t h = 0; h < H; ++h) {
        if (h % 2 == 0) {
            for (int64_t w = 0; w < W; ++w) {
                std::cout << mat[h][w] << " ";
            }
        }
        else {
            for (int64_t w = W-1; w >= 0; --w) {
                std::cout << mat[h][w] << " ";
            }
        }
        std::cout << std::endl;
    }


    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int x[1005];
string s;
int main(void){
    cin>>s;
    for(int i=0;i<4;i++){
		x[s[i]]++;
	}
    int p=0;
    for(int i=0;i<1005;i++)if(x[i]==2)p++;
    if(p==2)cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
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 ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
int n,k,r,s,p;
string t="",ss;
cin >> n >> k >> r >> s >> p>> ss;
ll ans = 0;
for(int i=0;i<n;i++){
    if(ss.at(i)=='r'){
        if(i-k<0){
            ans+=p;
            t+='p';
        }
        else{
            if(t.at(i-k)=='p'){t+='Z';continue;}
            else{
                ans+=p;
                t+='p';
            }
        }
    }
        if(ss.at(i)=='s'){
        if(i-k<0){
            ans+=r;
            t+='r';
        }
        else{
            if(t.at(i-k)=='r'){t+='Z';continue;}
            else{
                ans+=r;
                t+='r';
            }
        }
    }
        if(ss.at(i)=='p'){
        if(i-k<0){
            ans+=s;
            t+='s';
        }
        else{
            if(t.at(i-k)=='s'){t+='Z';continue;}
            else{
                ans+=s;
                t+='s';
            }
        }
    }
}
cout << ans << endl;
}



Measured memory_bytes: 640
N,Y=map(int,input().split())

L='-1 -1 -1'
flag_=False
for tt in range(0,N+1):
    for ft in range(0,N-tt+1):
        ot=N-tt-ft
        if Y==(10000*tt)+(5000*ft)+(1000*ot):
            L=str(tt)+' '+str(ft)+' '+str(ot)
            flag_=True
                
if flag_:print(L)
else:print('-1 -1 -1')

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
#include<vector>
#define fst first
#define snd second

using namespace std;

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

const int MN = 5000 + 1;

int D[MN][MN];

int main() {
    int n, mod;
    scanf("%d%d", &n, &mod);
    D[0][n] = 1;
    ll ans = 0;
    for (int i = 1; i <= n-1; i++) {
        int c = min(n + 1 - i, i);
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= n; k++) {
                if (j+c*k > n) break;

                D[i][j] += D[i-1][j+c*k];
                if (D[i][j] >= mod)
                    D[i][j] -= mod;
            }

            if (i == n-1) {
                ans = (ans + (ll)D[i][j] * j) % mod;
            }
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 97792