akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using usize = std::size_t;

using coord = std::pair<i32, i32>;

constexpr i32 INF = 1234567890;

template<typename GetX, typename GetY, typename Distance>
auto get_min(std::vector<coord>& as, std::vector<coord>& bs, GetX getx, GetY gety, Distance dist) -> i32 {
	i32 result = INF;

	auto cmp = [&getx, &gety](const auto& a, const auto& b) {
		if (getx(a) == getx(b)) return gety(a) < gety(b);
		else return getx(a) < getx(b);
	};

	std::sort(as.begin(), as.end(), cmp);
	std::sort(bs.begin(), bs.end(), cmp);
	i32 r = 0;
	for (const auto& a : as) {
		while (r < (i32)bs.size() && cmp(bs[r], a)) {
			r += 1;
		}
		if (r == (i32)bs.size()) {
			break;
		}
		if (getx(a) == getx(bs[r])) {
			result = std::min(result, dist(a, bs[r]));
		}
	}
	return result;
}

auto main() -> i32 {
	i32 n;
	scanf("%d", &n);
	std::vector<coord> us;
	std::vector<coord> rs;
	std::vector<coord> ds;
	std::vector<coord> ls;
	for (i32 i = 0; i < n; ++i) {
		i32 x, y;
		char u;
		scanf("%d%d %c", &x, &y, &u);
		switch (u) {
			case 'U': {
				us.emplace_back(x, y);
				break;
			}
			case 'R': {
				rs.emplace_back(x, y);
				break;
			}
			case 'D': {
				ds.emplace_back(x, y);
				break;
			}
			case 'L': {
				ls.emplace_back(x, y);
				break;
			}
		}
	}

	i32 ans = INF;
	ans = std::min(ans, get_min(us, ds, [](const coord& a) { return a.first; }, [](const coord& a) { return a.second; }, [](const coord& a, const coord& b) { return (b.second - a.second) * 5; }));
	ans = std::min(ans, get_min(rs, ls, [](const coord& a) { return a.second; }, [](const coord& a) { return a.first; }, [](const coord& a, const coord& b) { return (b.first - a.first) * 5; }));
	ans = std::min(ans, get_min(rs, us, [](const coord& a) { return a.first + a.second; }, [](const coord& a) { return a.first; }, [](const coord& a, const coord& b) { return (b.first - a.first) * 10; }));
	ans = std::min(ans, get_min(ds, ls, [](const coord& a) { return a.first + a.second; }, [](const coord& a) { return a.first; }, [](const coord& a, const coord& b) { return (b.first - a.first) * 10; }));
	ans = std::min(ans, get_min(us, ls, [](const coord& a) { return a.first - a.second; }, [](const coord& a) { return a.first; }, [](const coord& a, const coord& b) { return (b.first - a.first) * 10; }));
	ans = std::min(ans, get_min(rs, ds, [](const coord& a) { return a.first - a.second; }, [](const coord& a) { return a.first; }, [](const coord& a, const coord& b) { return (b.first - a.first) * 10; }));

	if (ans == INF) {
		puts("SAFE");
	} else {
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 5284
// C - Big Array
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; long long K;
	cin>>N>>K;
	vector<pair<int,int>> AB;
	for(int i=0; i<N; ++i){
		int a,b; cin>>a>>b;
		AB.emplace_back(a,b);
	}
	sort(AB.begin(), AB.end());
	for(auto p:AB){
		K -= p.second;
		if(K<=0){
			cout<< p.first <<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1400
#include <cassert>
#include <functional>
#include <utility>
#include <vector>

template <typename T, class Container = std::vector<T>,
	class Compare = std::less<typename Container::value_type>>
	class IntervalHeap {

	public:
		using container_type = Container;
		using value_compare = Compare;
		using value_type = typename container_type::value_type;
		using reference = typename container_type::reference;
		using const_reference = typename container_type::const_reference;
		using size_type = typename container_type::size_type;

	protected:
		container_type c;
		value_compare comp;

	private:
		static constexpr size_type z = ~static_cast<size_type>(1);
		bool normalize(const size_type x, const size_type y) {
			if (!comp(c[y], c[x]))
				return false;
			std::swap(c[x], c[y]);
			return true;
		}
		void build() {
			const size_type s = size() + 1;
			if (s & 1) {
				normalize(s & z, s);
				buildmin(s >> 1);
				buildmax(s >> 1);
				return;
			}
			if (s == 2)
				return;
			if (normalize(s, s >> 1 | 1))
				buildmax(s >> 2);
			buildmin(s >> 1);
		}
		void buildmin(size_type i) {
			while (i > 1 && normalize(i & z, i << 1))
				i >>= 1;
		}
		void buildmax(size_type i) {
			while (i > 1 && normalize(i << 1 | 1, i | 1))
				i >>= 1;
		}

	public:
		explicit IntervalHeap(const value_compare &x = Compare()) : c(2), comp(x) {}
		bool empty() const { return c.size() == 2; }
		size_type size() const { return c.size() - 2; }
		const_reference min() const {
			assert(!empty());
			return c[2];
		}
		const_reference max() const {
			assert(!empty());
			return size() == 1 ? c[2] : c[3];
		}
		void push(const value_type &x) {
			c.push_back(x);
			build();
		}
		void push(value_type &&x) {
			c.push_back(std::move(x));
			build();
		}
		template <class... Args> void emplace(Args &&... args) {
			c.emplace_back(std::forward<Args>(args)...);
			build();
		}
		void pop_min() {
			assert(!empty());
			const size_type s = size() + 1;
			std::swap(c[2], c[s]);
			c.pop_back();
			size_type i = 4;
			while (i < s) {
				if ((i | 2) < s && !comp(c[i], c[i | 2]))
					i |= 2;
				if (!normalize(i >> 1 & z, i))
					break;
				if ((i | 1) < s)
					normalize(i, i | 1);
				i <<= 1;
			}
		}
		void pop_max() {
			assert(!empty());
			const size_type s = size() + 1;
			if (s == 2)
				return pop_min();
			std::swap(c[3], c[s]);
			c.pop_back();
			size_type i = 5;
			while (i < s) {
				if ((i | 2) < s && !comp(c[i | 2], c[i]))
					i |= 2;
				if (!normalize(i, i >> 1 | 1))
					break;
				normalize(i & z, i);
				i = (i & z) << 1 | 1;
			}
		}
};


#include<cstdio>
#include<string>
#include<vector>
void scan(std::string &s) {
	s.clear();
	int c = fgetc(stdin);
	while (c == ' '||c == '\n') c = fgetc(stdin);
	while (c != ' '&&c != '\n') {
		s.push_back(c);
		c = fgetc(stdin);
	}
}

int main() {
	IntervalHeap<int,std::vector<int>,std::greater<int>> Q;
	std::string s;
	int k;
	scan(s);
	while (s[2] != 'd') {
		if (s[0] == 'i') {
			scanf("%d", &k);
			Q.emplace(k);
		}
		else {
			printf("%d\n", Q.min());
			Q.pop_min();
		}
		scan(s);
	}
	return 0;
}


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

int n;
vector<int> l;

void solve() {
  int i, sum = 0;

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

  for (i = 0; i < n - 1; i++) {
    sum += l[i];
  }

  if (l[n - 1] < sum) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return;
}

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

  l.resize(n);

  for (i = 0; i < n; i++) {
    cin >> l[i];
  }

  solve();

  return 0;
}

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

using namespace std;
#define LL long long

const int INF  = 0x3f3f3f3f;
const int MAXN = 512345;

int main () {

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int n;
	cin >> n;

	vector <int> w (n);

	for (int &x : w) cin >> x;
	
	int mn = INF;

	for (int t = 0; t < n; ++t) {

		int s1 = 0;
		for (int i = t + 1; i < n; ++i) s1 += w[i];

	
		int s2 = 0;
		for (int i = t; i>= 0; --i) s2 += w[i];


		mn = min (mn, abs (s1 - s2));


	}

	cout << mn << '\n';



	return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int();
        long A = Reader.Int(), B = Reader.Int(), D = A - B;
        var HP = Reader.IntArray(N);
        Predicate<int> F = x =>
        {
            long count = 0;
            foreach (var hp in HP)
                if ((count += (Math.Max(0, hp - B * x) + D - 1) / D) > x) return false;
            return true;
        };
        Console.WriteLine(BinarySearchMin(1, (int)1e9, F));
    }

    // [L, R]
    int BinarySearchMin(int L, int R, Predicate<int> F)
    {
        for (int x; L < R; )
            if (F((x = L + R >> 1))) R = x;
            else L = x + 1;
        return R;
    }
}

class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

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

int r,g,b;
int main() {
  cin >> r >> g >> b;
  if ((r * 100 + g * 10 + b) % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


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

using namespace std;

int main()
{
    int N, M;
    vector<string> s, t;

    cin >> N;

    for(int i=0; i<N; i++){
        string str;
        cin >> str;

        s.push_back(str);
    }

    cin >> M;

    for(int i=0; i<M; i++){
        string str;
        cin >> str;

        t.push_back(str);
    }

    vector<int> cost(s.size(), 0);

    for(int i=0; i<N; i++){
        string str = s.at(i);

        for(int j=0; j<N; j++){
            if(str.compare(s.at(j))==0){
                cost.at(i) = cost.at(i) + 1;
            }
        }

        for(int j=0; j<M; j++){
            if(str.compare(t.at(j))==0){
                cost.at(i) = cost.at(i) - 1;
            }
        }
    }

    int max = 0;

    for(int i=0; i<N; i++){
        if(max < cost.at(i)){
            max = cost.at(i);
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);


    string S;
    cin >> S;

    int n = S.length();

    int res = (n + 1) / 2;

    vector<int> cnts(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        cnts[i + 1] = cnts[i] + (S[i] - '0');
    }


    for (int len = n; len * 2 > n; --len) {
        int l = n - len;
        int r = len - 1;
        if (l <= r) {
            if (cnts[r + 1] - cnts[l] == 0 || cnts[r + 1] - cnts[l] == r - l + 1) {
                res = max(res, len);
            }
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 848
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int c[4][4];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    if(
        c[0][2] - c[0][1] == c[1][2] - c[1][1] &&
        c[0][2] - c[0][1] == c[2][2] - c[2][1] &&
        c[0][1] - c[0][0] == c[1][1] - c[1][0] &&
        c[0][1] - c[0][0] == c[2][1] - c[2][0]
    ) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import copy
N, K = map(int, input().split())
A = list(map(int, input().split()))
routes = [0]
visited = [False] * N
visited[0] = True
now = 0
while True:
    next_town = A[now] - 1
    if visited[next_town]:
        routes.append(next_town)
        break
    visited[next_town] = True
    routes.append(next_town)
    now = next_town
for i, r in enumerate(routes):
    if r == routes[-1]:
        loop = copy.deepcopy(routes[i:])
        break
routes.pop()
loop.pop()
if len(routes) > K:
    print(routes[K] + 1)
else:
    K -= len(routes)
    K %= len(loop)
    print(loop[K] + 1)


Measured memory_bytes: 33216
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

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

signed main(){
  int a;string s;cin>>a>>s;
  if(a >= 3200)cout << s << endl;
  else cout << "red" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);


    if (a == 5 || a == 7) {
      if (b == 5 || b == 7) {
        if (c == 5 || c == 7) {
          int d = a * b * c;
          if (d == 175) {
            printf("YES");
          }
          else printf("NO");
        }
        else printf("NO");
      }
      else printf("NO");
    }
    else printf("NO");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
  char a[100];
  cin>>a;
  int i=0;
  while(i<100){
    if(a[i]!='\0'){
      i++;
    }else{
      break;
    }
  }
  int j=i-2;
  cout<<a[0]<<j<<a[i-1]<<"\n";

  return 0;
}


Measured memory_bytes: 256
// WeirdBugsButOkay

# include <bits/stdc++.h>

# define ll long long
# define ld long double
# define pii pair <int,int>
# define pll pair <ll,ll>
# define mp make_pair
# define pb push_back
# define ff first
# define ss second
# define endl '\n'

using namespace std;

ll pow3(ll a, ll b, ll m = 1000000007)
{
    ll res = 1;
    while(b > 0)
    {
        if(b & 1)
            res = (res * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return res;
}

void solve()
{
    map <string, ll> m;
    ll n;
    cin >> n;
    for(ll i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    cout << m.size() << endl;
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll q = 1;
    //cin >> q;
    for(ll i = 0; i < q; i++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 19196
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
pint m2warizan(int num){
	pint shoamari;
	if(num>=0){
		shoamari.first=-(num/2);
		shoamari.second=num%2;
	}
	else{
		if((-num)%2==0){
			shoamari.first=(-num)/2;
		}
		else{
			shoamari.first=(-num)/2+1;
		}
		shoamari.second=(-num)%2;
	}
	return shoamari;
}
int main(){
	int N;
	scan(N);
	int m2sin[40];
	int nowsho=N;
	int keta=0;
	rep(i,40){
		if(nowsho==0){
			break;
		}
		else{
			int amari=m2warizan(nowsho).second;
			nowsho=m2warizan(nowsho).first;
			m2sin[i]=amari;
			keta++;
		}
	}
	if(keta==0){
		prin("0");
	}
	else{
		for(int i=keta-1;i>=0;i--){
			printf("%d",m2sin[i]);
		}
		kaigyo;
	}
	return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if(a > 8 || b > 8) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}

Measured memory_bytes: 3608
class LazySegmentTree:

    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.data = [ide_ele] * 2 * self.num
        self.lazy = [None] * 2 * self.num

        for i in range(n):
            self.data[self.num + i] = init_val[i]

        for i in range(self.num - 1, 0, -1):
            self.data[i] = self.segfunc(self.data[2 * i], self.data[2 * i + 1])

    def gindex(self, l, r):
            l += self.num
            r += self.num
            lm = l >> (l & -l).bit_length()
            rm = r >> (r & -r).bit_length()

            while r > l:
                if l <= lm:
                    yield l
                if r <= rm:
                    yield r
                r >>= 1
                l >>= 1
            while l:
                yield l
                l >>= 1

    def propagates(self, *ids):
        for i in reversed(ids):
            v = self.lazy[i]
            if v is None:
                continue
            self.lazy[2 * i] = v
            self.lazy[2 * i + 1] = v
            self.data[2 * i] = v
            self.data[2 * i + 1] = v
            self.lazy[i] = None

    def update(self, l, r, x):
        *ids, = self.gindex(l, r)
        self.propagates(*ids)
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                self.lazy[l] = x
                self.data[l] = x
                l += 1
            if r & 1:
                self.lazy[r - 1] = x
                self.data[r - 1] = x
            r >>= 1
            l >>= 1
        for i in ids:
            self.data[i] = self.segfunc(self.data[2 * i], self.data[2 * i + 1])


    def query(self, l, r):
        *ids, = self.gindex(l, r)
        self.propagates(*ids)

        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.data[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.data[r - 1])
            l >>= 1
            r >>= 1
        return res

def segfunc(x, y):
    return min(x, y)

ide_ele =  10**9


N, Q = map(int, input().split())
ans = (N-2)*(N-2)
R = [N]*(N+1)
W = [N]*(N+1)
seg_r = LazySegmentTree(R, segfunc, ide_ele)
seg_w = LazySegmentTree(W, segfunc, ide_ele)
for i in range(Q):
    a, b = map(int, input().split())
    if a == 1:
        t = seg_r.query(b, b+1)
        ans -= max(0, t - 2)
        if b <= seg_w.query(1, 2):
            seg_w.update(1, t+1, b)
    else:
        t = seg_w.query(b, b+1)
        ans -= max(0, t - 2)
        if b <= seg_r.query(1, 2):
            seg_r.update(1, t+1, b)
print(ans)

Measured memory_bytes: 101636
import math
a,b,x=map(float,input().split())
volume=a**2*b
if volume<x*2:
    sub=volume-x
    sub=sub/a*2/a
    ans=math.degrees(math.atan(sub/a))
else:
    x=x/a*2/b
    ans=90.0-math.degrees((math.atan(x/b)))
print(ans)

Measured memory_bytes: 9332
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		if(B/A<=C) {
			System.out.println(B/A);
		}
		else {
			System.out.println(C);
		}
	}
}

Measured memory_bytes: 22868
#include<stdio.h>
#define rep(i,l,r) for(int i=l;i<r;i++)
typedef long long ll;

ll max(ll x, ll y) { return (x > y) ? x : y; }

int main() {
    ll n, m, k,sumA[200001], sumB[200001];
    scanf("%lld%lld%lld", &n, &m, &k);
    ll a, b;
    sumA[0] = sumB[0] = 0;
    rep(i, 0, n) {
        scanf("%lld", &a);
        sumA[i + 1] = sumA[i] + a;
    }
    rep(i, 0, m) {
        scanf("%lld", &b);
        sumB[i + 1] = sumB[i] + b;
    }
    ll ans = 0,j=m;
    rep(i,0,n + 1) {
        if (k<sumA[i]) {
            break;
        }
        while (sumA[i]+sumB[j]>k) {
            j--;
        }
        ans = max(ans, i + j);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 5228
N = int(input())
res = 0
for i in range(1,N+1):
    if(i% 2 == 0):
        continue
    tmp = i
    g = 1
    for j in range(2,i+1):
        fac = 0
        while tmp%j == 0:
            tmp = tmp//j
            fac = fac + 1
        g = g*(fac+1)
    if(g == 8):
        res = res + 1
print(res)


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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1};

int main() {
	int N, A, B, C, X;
	while (cin >> N >> A >> B >> C >> X, N) {
		int Y[N]; rep(i, N) cin >> Y[i];
		int ans = -1;
		for (int i = 0; i < N;) {
			ans++;
			if (Y[i] == X) i++;
			X = (A * X + B) % C;
			if (ans > 10000) { ans = -1; break; }
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});    
	let N = parseInt(input[0][0], 10);
	let ans = N + 1;
	for (let d = 1; d < N - 1; d++){
		ans += (N - d) * (d + 1);
		// console.log(ans);
		if (ans >= Number.MAX_SAFE_INTEGER) console.log("caution!");
	}
	let line, tmp1, tmp2;
	for (let i = 0; i < N - 1; i++){
		// console.log(ans);
		line = input[i + 1].map(e => parseInt(e, 10));
		if (line[1] < line[0]) line = [line[1], line[0]];
		tmp1 = Math.min(N - line[1], line[0] - 1) + 1;
		tmp2 = N - (line[1] - line[0]) - 1;
		ans -= ((tmp1 * tmp1) + tmp1 * (tmp2 - 2 * tmp1 + 2) - 1);
		// console.log(line);
		// console.log(tmp1, tmp2, (tmp1 * tmp1) + tmp1 * (tmp2 - 2 * tmp1 + 2) - 1);
	}
	if (N === 1) ans = 1;
	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define MAX 1000

void initialize(void);
int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

int top = 0;
int S[MAX];

int main(){
  int x,a,b;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a+b);
    } else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      push(b-a);
    } else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a*b);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",S[top]);
  return 0;
}

void initialize(void){
  top = 0;
}

int isEmpty(void){
  if(top == 0) return 1;
  else return 0;
}

int isFull(void){
  if(top >= MAX - 1) return 1;
  else return 0;
}

void push(int x){
  if(isFull() == 1) fprintf(stderr,"Error(overflow)\n");
  else{
    top++;
    S[top] = x;
  }
}

int pop(void){
  if(isEmpty() == 1) fprintf(stderr,"Error(underflow)\n");
  else{
    top--;
  return S[top+1];
  }
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n,hi;
int main(){
    cin>>n;
    int ans=0,pre=0;
    rep(i,n){
        cin>>hi;
        if(pre>hi) ans+=pre-hi;
        pre=hi;
    }
    cout<<ans+pre<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007
#define REP(i,st,num)for(int i=(st);i<(num);++i)
#define ll long long
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int K,X;
    cin>>K>>X;
    REP(i,max(-1000000,X-K+1),min(1000000,X+K)){
        cout<<i<<" ";
    }
    return 0;
}

Measured memory_bytes: 256
import itertools
from math import factorial

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
f = factorial(N)
all = list(itertools.permutations(range(1,N+1), N))

count = 0
for i in range(f):
        if all[i] == P:
                count += i+1
        if all[i] == Q:
                count -= i+1

print(abs(count))

Measured memory_bytes: 7972
#include <bits/stdc++.h>
#define len(x) ((int)(x).size())

using namespace std;

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

  int N, M;
  cin >> N >> M;

  // [
  //   (count_WA_before_passed, is_passed)
  // ]
  vector<pair<int, bool>> contest_result(105000, make_pair(0, false));

  int WA_count = 0;
  int AC_count = 0;

  while (M--) {
    int p;
    string S;
    cin >> p >> S;
    if (contest_result[p].second) continue;

    if (S == "AC") {
      contest_result[p].second = true;
      AC_count++;
      WA_count += contest_result[p].first;
    } else if (S == "WA") {
      contest_result[p].first++;
    }
  }

  cout << AC_count << " " << WA_count << endl;
}


Measured memory_bytes: 3984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

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

#define PI 3.14159265358479

int main(){
	int n;
	vector<long double> s;
	while (cin >> n){
		if (n == 0)break;
		long double x, m = 0, sum = 0;
		REP(i, n){
			cin >> x;
			s.push_back(x);
			m += x;
		}

		m = m / (long double)n;

		REP(i, n){
			s[i] -= m;
			s[i] = powl(s[i], 2.0);
			sum += s[i];
		}

		sum = powl(sum / (long double)n, 0.5);
		cout << fixed << sum << "\n";
		s.clear();
	}
	return 0;
}

Measured memory_bytes: 1368
/*input
2 3 3
*/

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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define mp make_pair
#define F first
#define S second


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(long long* a,long long n,long long val){
	for(long long i=0;i<n;i++)
		a[i]=val;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll t=1,i,j;
	//cin>>t;
	while(t--){
		
	}
	ll a,b,k;
	cin>>a>>b>>k;
	ll a1=a;
	a1=max(a-k,(ll)0);
	if(a1){
		cout<<a1<<" "<<b<<endl;
		return 0;
	}
	cout<<a1<<" "<<max(b+a-k,(ll)0)<<endl;
	return 0;
}




Measured memory_bytes: 256
using System;
using System.IO;

namespace Sandbox
{
    class Program
    {
        static void Main(string[] args)
        {
            var scanner = new Scanner();
            var a = scanner.GetNextAsInt();
            var p = scanner.GetNextAsInt();

            p += a * 3;

            Console.WriteLine(p / 2);
        }
    }

    #region String Scanner
    public class Scanner
    {
        private const char Separator = ' ';
        private readonly StreamReader _Stream = new StreamReader(Console.OpenStandardInput());
        private int _Pos;
        private string[] _Line = new string[0];

        #region get a element
        public string GetNext()
        {
            // ReSharper disable once InvertIf
            if (this._Pos >= this._Line.Length)
            {
                // ReSharper disable once PossibleNullReferenceException
                this._Line = this._Stream.ReadLine().Split(Separator);
                this._Pos = 0;
            }
            return this._Line[this._Pos++];
        }
        public int GetNextAsInt()
        {
            return int.Parse(this.GetNext());
        }
        public long GetNextAsLong()
        {
            return long.Parse(this.GetNext());
        }
        public double GetNextAsDouble()
        {
            return double.Parse(this.GetNext());
        }
        #endregion

        #region get array
        public string[] ToArrayFromNextLine()
        {
            if (this._Pos >= this._Line.Length)
            {
                // ReSharper disable once PossibleNullReferenceException
                this._Line = this._Stream.ReadLine().Split(Separator);
            }

            this._Pos = this._Line.Length;
            return this._Line;
        }
        public int[] ToIntArrayFromNextLine()
        {
            return ToIntArray(this.ToArrayFromNextLine());
        }
        public long[] ToLongArrayFromNextLine()
        {
            return ToLongArray(this.ToArrayFromNextLine());
        }
        public double[] ToDoubleArrayFromNextLine()
        {
            return ToDoubleArray(this.ToArrayFromNextLine());
        }
        #endregion

        #region convert array
        private static int[] ToIntArray(string[] array)
        {
            var result = new int[array.Length];
            for (var i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }
            return result;
        }
        private static long[] ToLongArray(string[] array)
        {
            var result = new long[array.Length];
            for (var i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }
            return result;
        }
        private static double[] ToDoubleArray(string[] array)
        {
            var result = new double[array.Length];
            for (var i = 0; i < array.Length; i++)
            {
                result[i] = double.Parse(array[i]);
            }
            return result;
        }
        #endregion
    }
    #endregion
}


Measured memory_bytes: 11092
fun main(args: Array<String>) {
    yahooprocon2019qualcc()
}

fun yahooprocon2019qualcc() {
    val (k, a, b) = readLine()!!.split(' ').map { it.toLong() }

    val answer = if (b - a <= 2 || k - a + 1 < 2) 1 + k else {
        val needForA = a - 1
        val remain = k - needForA
        1 + needForA + (remain / 2) * (b - a) + remain % 2
    }

    println(answer)
}


Measured memory_bytes: 38052
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>

using namespace std;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;





int main()
{
	int N, M;
	cin >> N >> M;

	int B = 1;
	B = B << N;

	mat S(M, vec(N, 0));

	for (int i = 0; i < M; ++i)
	{
		int k; cin >> k;
		
		for (int j = 0; j < k; ++j)
		{
			int s; cin >> s; --s;
			S[i][s] = 1;
		}
	}

	vec p(M);
	for (int i = 0; i < M; ++i)
	{
		cin >> p[i];
	}

	int ans = 0;


	for (int i = 0; i < B; ++i)
	{
		int v = i;
		vec Light(N);
		for (int j = 0; j < N; ++j)
		{
			Light[j] = v % 2;
			v /= 2;
		}

		bool flag = true;

		for (int k = 0; k < M; ++k)
		{
			int total = 0;
			for (int j = 0; j < N; ++j)
			{
				total += S[k][j] * Light[j];
			}

			if (total % 2 != p[k])
			{
				flag = false;
				break;
			}
		}

		ans += flag;
	}

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

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc=new Scanner(System.in);
        double n=(double)sc.nextLong();
        long sum=0;
        long t=1;
        while(n!=1){
            n=Math.floor(n/2);
            sum+=t;
            t*=2;
        }
        System.out.println(sum+t);
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int a, b;
    cin >> a >> b;
    ll ans = 0;
    for(int i = a; i <= b; i++) {
        string str = to_string(i);
        string rev = to_string(i);
        reverse(rev.begin(), rev.end());
        if(str == rev) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>

int main() {
	int n; std::cin >> n;
	std::vector<int> count(n + 1, 1);
	for (auto i = 2; i <= n; ++i) {
		for (auto j = i; j <= n; j += i) {
			++count[j];
		}
	}
	long long int result{ 0 };
	for (auto i = 1; i <= n; ++i) {
		result += (long long int)count[i] * i;
	}
	std::cout << result << '\n';
}

Measured memory_bytes: 42324
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
  
using namespace std;

#define pi 3.141592653589793

void solve(string s)
{
	int stepnum[100001][2];
	// stepnum[i][0] :  (0から数えて)iばんめの数字の移動のときに左足を使った
	// stepnum[i][1] :            　　　　　　　       　　　右足を使った
	for(int i = 0; i < s.length(); i++){
		for(int j = 0; j < 2; j++){
			stepnum[i][j] = 0;
		}
	}
	int s1 = (s[0] - '0') % 3, s2;
	for(int i = 1; i < s.length(); i++){
		s2 = (s[i] - '0') % 3;
		if((s1 == 0 && s2 == 1) || (s1 == 0 && s2 == 2) || (s1 == 2 && s2 == 1)){
		// 右左、右右、左左はok
		stepnum[i][0] = min(stepnum[i - 1][1], stepnum[i - 1][0] + 1);
		stepnum[i][1] = stepnum[i - 1][1] + 1;
		} else if((s1 == 1 && s2 == 0) || (s1 == 1 && s2 == 2) || (s1 == 2 && s2 == 0)){
			// 左右、左左、右右はok
			stepnum[i][0] = stepnum[i - 1][0] + 1;
			stepnum[i][1] = min(stepnum[i - 1][0], stepnum[i - 1][1] + 1);
		} else {
			// どの足でもok
			stepnum[i][0] = min(stepnum[i - 1][0] + 1, stepnum[i - 1][1]);
			stepnum[i][1] = min(stepnum[i - 1][1] + 1, stepnum[i - 1][0]);
		}
		s1 = s2;
	}
	cout << min(stepnum[s.length() - 1][0], stepnum[s.length() - 1][1]) << endl;
}

int main()
{
	string s;
	while(1){
		cin >> s;
		if(s == "#") break;
		solve(s);
	}
	return 0;
}

Measured memory_bytes: 2108
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    ans = 1
    cnt = [0, 0, 0]
    for a in A:
        if a not in cnt:
            print(0)
            return
        i = cnt.index(a)
        c = cnt.count(a)
        cnt[i] += 1
        ans *= c
        ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14364
import java.util.*;

public class Main {
	public Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new aoj1141().doIt();
	}
	class aoj1141{
		int prime[] = new int [1000001];
		boolean is_prime[] = new boolean [1000002];
		void sieve(int n){
			int p = 0;
			for(int i  =0;i <= n;i++) is_prime[i] = true;
			is_prime[0] = is_prime[1] = false;
			for(int i = 2;i < n;i++){
				if(is_prime[i]){
					prime[p++] = i;
					for(int j = 2 * i;j <= n;j += i)is_prime[j] = false;
				}
			}
 		}
		void doIt() {
			sieve(1000000);
			while (true) {
				int a = sc.nextInt();
				int d = sc.nextInt();
				int n = sc.nextInt();
				if(a+d+n == 0)break;
				int ans = 0;
				while(true){
					if(is_prime[a])ans++;
					if(ans == n)break;
					a = a + d;
				}
				System.out.println(a);
			}
		}
	}
}

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

int main() {
  int N, Q;
  string s; cin >> N >> s >> Q;
  vector<set<int>> is(26);
  for(int i = 0; i < N; i++) {
    is[s[i]-'a'].insert(i);
  }
  for(int qi = 0; qi < Q; qi++) {
    int type; cin >> type;
    if(type == 1) {
      int i;
      char c;
      cin >> i >> c;
      i--;
      is[s[i]-'a'].erase(i);
      s[i] = c;
      is[s[i]-'a'].insert(i);
    } else {
      int l, r; cin >> l >> r;
      l--;
      int ans = 0;
      for(int i = 0; i < 26; i++) {
        auto it = is[i].lower_bound(l);
        if(it != is[i].end() && *it < r) ans++;
      }
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 24196
#include<cstdio>
#define MAX(x,y) ((x>y)? x:y)

int paper[14][14];
class ink {
public: 
	int x,y;
	ink(int X,int Y)
	{
		x=X,y=Y;
	}
};
class ink date_1[]={ink(-1,0),ink(0,-1),ink(1,0),ink(0,1),ink(0,0)};
class ink date_2[]={ink(-1,-1),ink(-1,0),ink(-1,1),ink(0,-1),ink(0,0),ink(0,1),ink(1,-1),ink(1,0),ink(1,1)};
class ink date_3[]={ink(-2,0),ink(0,-2),ink(2,0),ink(0,2),ink(-1,-1),ink(-1,0),ink(-1,1),ink(0,-1),ink(0,0),ink(0,1),ink(1,-1),ink(1,0),ink(1,1)};

void fail(int kind,int x,int y)
{
	if(kind==1)
	{
		for(int i=0;i<5;i++)
		{
			paper[x+date_1[i].x+2][y+date_1[i].y+2]++;
		}
	}
	if(kind==2)
	{
		for(int i=0;i<9;i++)
		{
			paper[x+date_2[i].x+2][y+date_2[i].y+2]++;
		}
	}
	if(kind==3)
	{
		for(int i=0;i<13;i++)
		{
			paper[x+date_3[i].x+2][y+date_3[i].y+2]++;
		}
	}
}

int main()
{
	int x,y,size;
	for(int i=2;i<12;i++)
	{
		for(int j=2;j<12;j++)
		{
			paper[i][j]=0;
		}
	}
	while(scanf("%d,%d,%d",&x,&y,&size)!=EOF)
	{
		if(x==-1)break;
		fail(size,x,y);
	}
	int white=0;
	int maxblack=0;
	for(int i=2;i<12;i++)
	{
		for(int j=2;j<12;j++)
		{
			if(paper[i][j]==0)white++;
			else maxblack=MAX(maxblack,paper[i][j]);
		}
	}
	printf("%d\n%d\n",white,maxblack);
    return 0;
}

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

const int N = 2002;
                               
int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, pair<int, int>>> edges;
  for (int i = 0; i < m; i++){
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    edges.push_back({u, {v, w}});
  }
  vector<long long>cost(n, -1e12);
  cost[0] = 0;      
  bool f = false;
  for (int i = 0; i < n; i++){
    for (auto edge : edges){
      int u = edge.first;
      int v = edge.second.first;
      int w = edge.second.second;
      if (cost[v] < cost[u] + w){
        cost[v] = cost[u] + w;
        if (i == n - 1 && v == n - 1){
          f = true;
        }
      }
    }        
  }
  if (f){
    cout << "inf\n";
  } else {
    cout << cost[n - 1] << "\n";
  } 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
   ll a,b;
   cin >> a >> b;
   ll c=sqrt(a);
   ll x=a*b;
   for(int i=a;i>=2;i--){
       if(a%i==0 && b%i==0){
           x/=i;
           b/=i;
           a/=i;
       }
   }
   cout << x << endl;
}

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

vector<vector<int>> G(8, vector<int>());

void dfs(const int v, int &cnt, vector<bool> &done) {    
    done.at(v) = true;

    bool go = false;
    for (int i = 0; i < (int)G[v].size(); i++) {
        if (!done.at(G[v].at(i))) {
            go = true;
            dfs(G[v].at(i), cnt, done);
        }
    }

    if (!go) {
        bool all = true;
        for (int i = 0; i < (int)done.size(); i++) {
            if (!done.at(i)) {
                all = false;
                break;
            }
        }
        if (all) cnt++;
    }

    done.at(v) = false;
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    int cnt = 0;
    vector<bool> done(n);
    dfs(0, cnt, done);

    cout << cnt << endl;
}   

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

int eratos(int n){
	bool isprime[n + 1];
	for(int i = 0; i <= n; i++)isprime[i] = true;
	isprime[0] = isprime[1] = false;
	for(int i = 2; i * i <= n; i++){
		if(isprime[i]){
			int j = i + i;
			while(j <= n){
				isprime[j] = false;
				j = j + i;
			}
		}
	}
	int counter = 0;
	for(int i = 0; i <= n; i++){
		if(isprime[i] == true)counter++;
	}
	return counter;
}

int main(){
	int n;
	while(cin >> n){
		cout << eratos(n) << endl;
	}
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
int main(){
    int h,w;
    std::cin >> h>>w;
    vvector(a,int,h,w,INF);
    vvector(c,char,h,w,'v');
    reprep(i,j,h,w)std::cin >> c[i][j];
    reprep(i,j,h,w){
        if(c[i][j]=='#')a[i][j]=0;
    }
    rep(q,20){
        rep(i,h){
            rep(j,w-1){
                a[i][j+1]=min(a[i][j+1],a[i][j]+1);
            }
            irep(j,w-1){
                a[i][j]=min(a[i][j],a[i][j+1]+1);
            }
        }
        rep(j,w){
            rep(i,h-1){
                a[i+1][j]=min(a[i+1][j],a[i][j]+1);
            }
            irep(i,h-1){
                a[i][j]=min(a[i][j],a[i+1][j]+1);
            }
        }
    }
    int ans=0;
    reprep(i,j,h,w)ans=max(ans,a[i][j]);
    std::cout << ans << std::endl;
}

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

int main(){
    int n,j=0;
    cin>>n;
    float x[4],y[4];
    for(int i=0;i<n;i++){
        for(int j=0;j<4;j++)cin>>x[j]>>y[j];
        if( ( (y[1]-y[0]) * (x[3]-x[2]) )==( (y[3]-y[2])*(x[1]-x[0]) ) ){
           cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    
    
}


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

    #define ll long long
    #define ar array

    const int mxN=1e7;
    int n, c[mxN+1];

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

    	cin >> n;
    	for(int i=1; i<=n; ++i)
    		for(int j=i; j<=n;j+=i)  //William Lin Genius
    			++c[j];
    	ll ans=0;
    	for(int i=1; i<=n; ++i)
    		ans+=(ll)i*c[i];
    	cout << ans;
    }


Measured memory_bytes: 42708
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vpl vector<pair<long, long> >
#define vppl vector<pair<long, pair<long, long> > >

const int INF = 100100100;
const long LONG_INF = 2147483647;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    string x;
    cin >> x;
    int count = 0;
    rep(i,x.length()-1){
        if (x.substr(i,1) != x.substr(i+1,1)) {
            count+=2;
            x = x.substr(0, i) + x.substr(i+2, x.length() - i-1);
            i--;
            if (i >= 0) {
                i--;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 796
#include <stdio.h>
int main(void){
	int n;
	double b=0;
	int i,j;
	int a[10000],temp;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<n;i++){
		for(j=i+1;j<=n;j++){
			if(a[i]>a[j]){
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
		}
	}
	printf("%d ",a[1]);
	for(i=1;i<n;i++){
		for(j=i+1;j<=n;j++){
			if(a[i]<a[j]){
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
		}
	}
	printf("%d ",a[1]);
	for(i=1;i<=n;i++)b+=a[i];
	printf("%.0lf\n",b);
	return 0;
}



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

int main(void)
{
	int N;
	cin >> N;
	int num;

	num = N % 10;

	if (num == 2 || num == 4 ||
		num == 5 || num == 7 ||
		num == 9) {
		cout << "hon" << endl;
	}
	else if (num == 0 || num == 1 ||
			 num == 6 || num == 8) {
		cout << "pon" << endl;
	}
	else if (num == 3) {
		cout << "bon" << endl;
	}

	return 0;
}

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

int main(){
    int n,m; cin>>n>>m;
    vector<vector<int>> box(n+1,{1,0});
    box[1][1] = 1;
    for (int i=0; i<m; i++){
        int x, y; cin>>x>>y;
        box[x][0] -= 1; box[y][0] += 1;
        if(box[x][1]==1) box[y][1]=1;
        if(box[x][0]==0) box[x][1]=0;
    }
    int ans = 0;
    for (int i=1; i<=n; i++){
        if (box[i][1]==1) ans ++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8720