akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

cpp_int combination(cpp_int n, cpp_int r) {
	if (r * 2 > n) r = n - r;
	cpp_int dividend = 1;
	cpp_int divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}

cpp_int dp[51][51][2501];

int main() {
	int n;
	cin >> n;
	int a; cin >> a;
	vector<int>x(n);
	FOR(i,0, n) {
		cin >> x[i];
	}
	
	int X =max(*max_element(all(x)),a);
	rep(j, n+1)rep(k, n+1)rep(s, n*X+1) {
		if (j == 0 && k == 0 && s == 0) {
			dp[j][k][s] = 1;
		}
		else if (j >= 1 && s < x[j-1]) {
			dp[j][k][s] = dp[j - 1][k][s];
		}
		else if (j >= 1 && k >= 1 && s >= x[j-1]) {
			dp[j][k][s] = dp[j - 1][k][s] +
				dp[j - 1][k - 1][s - x[j-1]];
		}
		else {
			dp[j][k][s] = 0;
		}
	}
	cpp_int count = 0;
	rep(i, n+1) {
		count += dp[n][i][i*a];
	}
	cout << count-1 << endl;
}


Measured memory_bytes: 203520
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;

typedef long long LL;
struct on {
        LL x, c;
}no[100010];

LL A[100010], sum[100010];
LL d[100010];

bool cmp (LL a, LL b) {
        return a < b;
}

int main () {
        ios::sync_with_stdio(false);
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++)    cin >> A[i];
        sort (A + 1, A + n + 1);
        no[1].x = A[1], no[1].c = 1;
        int m = 1;
        for (int i = 2; i <= n; i++) {
                if (A[i] == no[m].x) {
                        no[m].c++;
                } else {
                        no[++m].x = A[i];
                        no[m].c = 1;
                }
        }
        sum[0] = 0;
        for (int i = 1; i <= m; i++) {
                sum[i] = sum[i - 1] + no[i].c * no[i].x;
        }
        memset (d, 0, sizeof d);
        int ans = no[m].c;
        d[m] = 1;
        for (int i = m - 1; i >= 1; i--) {
                if (sum[i] * 2 >= no[i + 1].x) {
                        d[i] = 1;
                        ans = ans + no[i].c;
                } else {
                        break;
                }
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 4224
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: i32,
        h: i32,
        w: i32,
    }
    puts!("{}\n", (n - h + 1) * (n - w + 1));
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  int n; cin >> n;
  cout << n / 3 << endl;
  return;
}

int main(){
  solve();
  return 0;
}


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

using namespace std;
vector<int> ans;

int main(){
	while(1){
		int n,a,b,c,x;
		cin >> n >> a >> b >> c >> x;
		if(n + a + b + c + x == 0) break;
		int y[100];
		int count = -1;
		int reel = 0;
		for(int i = 0;i < n;i++){
			cin >> y[i];
		}
		
		for(int i = 0;i <= 10000;i++){
			if(x == y[reel]) reel++;
			if(reel == n){
				count = i;
				break;
			}
			x = (a*x + b) % c;
		}
		ans.push_back(count);
	}	
	for(int i = 0;i < ans.size();i++) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3036
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n) --a[i];  
  
  map<int,ll> mp;
  rep(i,n) mp[a[i]] = (ll)i;
  set<ll> st;
  st.insert(-1);
  st.insert(n);
  ll res = 0;
  rep(i,n){
    ll x = mp[i];
    ll l,r;
    st.insert(x);
    {
      auto itr = st.find(x);
      l = *(--itr);
    }
    {
      auto itr = st.find(x);
      r = *(++itr);
    }
    ll c = (r-x)*(x-l);
    res += c*((ll)i+1);
  }

  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 22912
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdint>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long i64;
typedef vector<int> ivec;
typedef vector<string> svec;

void presentation_array(int A[], int N){
    for(int i=0; i<N; i++){
        if(i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

int main(){
    //?????°?????£?¨?
    int A[100];
    int N;
    int ans;

    //?????????????????????
    scanf("%d", &N);
    for(int i = 0; i < N; i++) scanf("%d", &A[i]);

    //?????????


    //??¢?????´?????????
    for(int i=0; i<N; i++){
        int minj = i;
        for(int j=i; j<N; j++){
            if (A[j] < A[minj]) minj =j;
        }
        if(i != minj){
            swap(A[i], A[minj]);
            ans++;
        }
        
    }

    //??????
    presentation_array(A, N);
    printf("%d\n", ans);
    return 0;
}

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

struct Bug {long long a, b;};

bool ok(const vector<Bug>& bug, int n) {
  if(n == 0) return true;
  priority_queue<Bug, vector<Bug>, function<bool(Bug, Bug)>> b([](Bug lhs, Bug rhs){return lhs.b != rhs.b ? lhs.b > rhs.b : lhs.a > rhs.a;});
  long long sum = 0;
  for(const auto& i: bug) {
    b.push(i);
    sum += i.a;
    if(b.size() < n) continue;
    if(sum <= b.top().b * n) return true;
    sum -= b.top().a;
    b.pop();
  }
  return false;
}

int main() {
  int N;
  cin >> N;
  vector<Bug> bug(N);
  for(auto& i: bug) cin >> i.a >> i.b;

  sort(begin(bug), end(bug), [](Bug lhs, Bug rhs){return lhs.a != rhs.a ? lhs.a < rhs.a : lhs.b < rhs.b;});

  int low = 0, high = N + 1;
  while(1 < high - low) {
    int middle = (low + high) >> 1;
    (ok(bug, middle) ? low : high) = middle;
  }
  cout << low << endl;
}

Measured memory_bytes: 20492
def int_multiple():
    return  [int(c) for c in input().split()]

def int_single():
    return int(input())

def str_multiple():
    return [c for c in input().split()]

def str_single():
    return input()

# start
N = int_single()


hash = []

d = {}

primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101]

for i in range(N):
    tmp = str_single()
    checksum = 1
    for ch in tmp:
        checksum *= primes[ord(ch)-97]

    if checksum in d:
        d[checksum] += 1
    else:
        d[checksum] = 1

res = 0
for key in d:
    if d[key] >= 2:
        res += int((d[key] * (d[key] - 1)) / 2)

print(res)


Measured memory_bytes: 15812
// 1_7_B
#include<stdio.h>

int count(void)
{
	int n, x, i, j, cnt;
	scanf("%d %d", &n, &x);
	if(n == 0 && x == 0){
		return -1;
	}

	for(i = 1, cnt = 0; i < n+1; i++){
		for(j = 1; j < n+1; j++){
			if(i < j && j < (x-i-j) && (x-i-j) <= n){
				cnt += 1;
			}
		}
	}
	return cnt;
}

int main(void){
	int result;
	while(1){
		result = count();
		if(result == -1){
			return 0;
		}
		printf("%d\n", result);
	}
}

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

vector<long long int> inverse;
vector<long long int> f, f_inverse;

void factorial_Initialize(int max){
    vector<long long int> a(max+1,1);
    inverse = a;
    f = a;
    f_inverse = a;

    for (int i=2; i<=max; i++){
        inverse[i]   = MOD - inverse[MOD % i] * (MOD / i) % MOD;
        f[i]         = f[i-1]         * i          % MOD;
        f_inverse[i] = f_inverse[i-1] * inverse[i] % MOD;
    }
}

long long int nCr(int n, int r){
    if(n < r || r < 0) return 0;
    if (n >= f.size()){
        factorial_Initialize(n);
    }
    return f[n] * f_inverse[r] % MOD * f_inverse[n-r] % MOD;
}

long long int modpow(long long int b, long long int p){// modinv(x) = modpow(x, MOD-2)
    long long int num = 1, power = b;
    for(int i=0; i<=30; i++){
        if((p>>i) & 1){
            num *= power;
            num %= MOD;
        }

        power *= power;
        power %= MOD;
    }
    return num;
}

int main(){
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    factorial_Initialize(2*n);

    long long int ans = 0;
    for(int i=0; i<n; i++){
        ans += (n+i) * nCr(n-1+i,i) % MOD * modpow(a,n) % MOD * modpow(b,i) % MOD * modpow(modpow(a+b, n+i), MOD-2) % MOD;
        ans += (n+i) * nCr(n-1+i,i) % MOD * modpow(a,i) % MOD * modpow(b,n) % MOD * modpow(modpow(a+b, n+i), MOD-2) % MOD;
        ans %= MOD;
    }
    ans *= 100;
    ans %= MOD;
    ans *= modpow(100-c, MOD-2);
    ans %= MOD;

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

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

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


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

int n;
P a[202020];

int main(){
  cin >> n;
  rep(i, n){
    cin >> a[i].first;
    a[i].second = i + 1;
  }
  sort(a, a + n);
  rep(i, n)
    cout << a[i].second << ((i == n - 1)? "\n" : " ");
  return 0;
}

Measured memory_bytes: 1536
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define MAX 10000000
#define SENTINEL 2e10


int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    int count = 0;
    set<string> se;
    rep(i, n){
        string tmp;
        cin >> tmp;
        se.insert(tmp);
    }

    cout << se.size() << endl;

}

Measured memory_bytes: 25168
#include <bits/stdc++.h>
#define int long long
using namespace std;

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        while (d--) {
            int a;
            cin >> a;
            mp[a]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (!mp[i]) ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)(1e9)+7)
#define MAX ((ull)(1e9)+1)

int main(){
	string s;
	cin >> s;
	stack<int> a;
	int l=s.length();
	for(int i=0; i<s.length(); i++){
		int x=(int)s[i]-'0';
		if(a.empty()) a.push(x);
		else{
			int y=a.top();
			if(x==y) a.push(y);
			else a.pop();
		}
	}
	cout << l-a.size() << endl;
 	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int p;
ll raise(ll a, ll b){
	ll ans = 1;
	a %= p;
	while(b){
		if(b & 1)
			ans = (a * ans) % p;
		b /= 2;
		a = (a * a) % p;
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	cin >> p;
	string s;
	cin >> s;
	map<int, int> df;
	vector<int> val(n);
	if(p == 2){
		ll ans = 0;
		for(int i = 0; i < n; i++){
			if((s[i] - '0') % 2 == 0)
				ans += i + 1;
		}
		cout << ans << '\n';
		return 0;
	}
	if(p == 5){
		ll ans = 0;
		for(int i = 0; i < n; i++){
			if(s[i] == '5' || s[i] == '0')
				ans += i + 1;
		}
		cout << ans << '\n';
		return 0;
	}
	val[0] = ((s[0] - '0') * raise(10, n - 1) )% p;
	df[val[0]]++;
	df[0]++;
	for(int i = 1; i < n; i++){
		val[i] = (val[i - 1] + ((s[i] - '0')  * raise(10, n - i - 1) % p)) % p;
		df[val[i]]++;
	}
	int cur = 1;
	ll ans = 0;
	for(int i = n - 1; i >= 0; i--){
		df[val[i]]--;
		//ans += df[val[i]];
		ans += df[(val[i] * raise(cur, p - 2) % p) * raise(raise(cur, p - 2), p - 2) % p]; 
		cur = (cur * 10) % p;
	}
	cout << ans << '\n';

}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


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

    ll ans = n - 1;
    for(ll i = 2; i * i <= n; i++){
        if(n % i == 0){
            ll sum = i + n / i - 2;
            ans = min(ans, sum);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

ll power(ll x, ll pw, ll mod) {
    ll res = 1;
    x = x % mod;  // if it x >= p
    while (pw > 0) {
        if (pw & 1)
            res = (res*x) % mod;
        pw /= 2;
        x = (x*x) % mod;
    }
    return res;
}
ll modInverse(ll n, ll p) {
    return power(n, p-2, p) % p; // Fermat's little theorem
}
ll nCr(ll n, ll m, ll mod=1e9+7) {
    m = min(m, n-m);
    if (m == 0) return 1;
    ll num = 1, dem = 1;
    for(ll i = 1; i <= m; i++) {
        num = (num*(n+1-i)) % mod;
        dem = (dem*(i)) % mod;
    }
    return (num * modInverse(dem, mod)) % mod;
}

int main() {
    int n, m;
    cin >> n >> m;
    ll mod = 1e9 + 7;

    vector<ll> fac(m+1, 1); // m >= n
    for(ll i = 1; i <= m; i++) {
        fac[i] = fac[i-1] * i;
        fac[i] %= mod;
    }
    // nCr(m, n) * n! == m! / (m-n)!
    ll a_perm = (fac[m] * modInverse(fac[m-n], mod)) % mod;
    ll b_perm = 0;
    ll comb = 1;
    for(int i = 0; i <= n; i++) {
        ll tmp = (fac[m-i] * modInverse(fac[m-n], mod)) % mod;
        // ll comb = nCr(n, i);
        if (i > 0) {
            comb = (comb * (n+1-i)) % mod;
            comb = (comb * modInverse(i, mod)) % mod;
        }
        tmp = (tmp * (comb)) % mod;
        if (i % 2 == 0) {
            b_perm += tmp;
            b_perm %= mod;
        } else {
            b_perm -= tmp;
            b_perm = (b_perm + mod*2) % mod;
        }
        // cout << "comb " << comb << endl;
    }
    ll ans = (a_perm * b_perm) % mod;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

void maxheapify(vector<int> &a,int i) {
	int l = i * 2;
	int r = i * 2 + 1;
	int largest = i;
	if (l <= a.size()-1){
		if (a[l] > a[i]) {
			largest = l;
		}
		else {
			largest = i;
		}
	}

	if (r <= a.size()-1){
		if (a[r] > a[largest]) {
			largest = r;
		}
	}
	if (largest != i) {
		swap(a[i], a[largest]);
		maxheapify(a, largest);
	}

}

void buildmaxheap(vector<int> &a) {
	for (int i = (a.size()-1) / 2; i >= 1; i--) {
		maxheapify(a, i);
	}
}

int main() {

	int n;
	cin >> n;
	vector<int> a(n+1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	buildmaxheap(a);

	for (int i = 1; i <= n; i++) {
		cout << " " << a[i];
	}
	cout << endl;

}


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

using ld = long double;
const ld eps = 1e-10, pi = acos(-1.0);

bool eq(ld a, ld b) {
	return abs(a - b) < eps;
}

using point = complex<ld>;

ld dot(point a, point b) {
	return real(conj(a) * b);
}

ld cross(point a, point b) {
	return imag(conj(a) * b);
}

int ccw(point a, point b, point c) {
	b -= a, c -= a;
	if (cross(b, c) > eps) return 1;	// a,b,c counter-clockwise
	if (cross(b, c) < -eps) return -1;	// a,b,c clockwise
	if (dot(b, c) < 0) return 2;		// c,a,b on a line
	if (norm(b) < norm(c)) return -2;	// a,b,c on a line
	return 0;							// a,c,b on a line
}

struct line {
	point a, b;
	line() : a(), b() {}
	line(const point& a_, const point &b_)
		: a(a_), b(b_) {}
};

bool isis_ll(line l, line m) {
	return abs(cross(l.b - l.a, m.b - m.a)) > eps;
}

bool isis_ls(line l, line s) {
	return (cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}

bool isis_lp(line l, point p) {
	return abs(cross(l.b - p, l.a - p)) < eps;
}

bool isis_sp(line s, point p) {
	return std::abs(s.a - p) + std::abs(s.b - p) - std::abs(s.b - s.a) < eps;
}

point proj(line l, point p) {
	ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
	return l.a + t * (l.a - l.b);
}

point is_ll(line s, line t) {
	point sv = s.b - s.a, tv = t.b - t.a;
	assert(cross(sv, tv) != 0);
	return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}

bool isis_ss(line s, line t) {
	if (isis_ll(s, t)) return isis_ls(s, t) && isis_ls(t, s);
	return isis_sp(s, t.a) || isis_sp(s, t.b) || isis_sp(t, s.a);
}

ld dist_lp(line l, point p) {
	return abs(p - proj(l, p));
}

ld dist_ll(line l, line m) {
	return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}

ld dist_ls(line l, line s) {
	return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}

ld dist_sp(line s, point p) {
	point r = proj(s, p);
	return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}

ld dist_ss(line s, line t) {
	if (isis_ss(s, t)) return 0;
	return min({ dist_sp(s, t.a), dist_sp(s, t.b), dist_sp(t, s.a), dist_sp(t, s.b) });
}

int is_in_polygon(const vector<point>& poly, point p) {
	const int n = poly.size();
	ld sum = 0;
	for (int i = 0; i < n; ++i) {
		point p1 = poly[i], p2 = poly[(i + 1) % n];
		if (isis_sp(line(p1, p2), p)) {
			return 1;
		}
		sum += arg((p2 - p) / (p1 - p));
	}
	return std::abs(sum) < pi / 2 ? 0 : 2;
}

int main()
{
	int n;
	cin >> n;
	vector<point> ps;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		ps.emplace_back(x, y);
	}
	int q;
	cin >> q;
	while (q--) {
		int x, y;
		cin >> x >> y;
		point p(x, y);
		cout << is_in_polygon(ps, p) << endl;
	}
	return 0;
}



Measured memory_bytes: 3172
#include<stdio.h>

int main(){
  
  int N,A[100],i,j,v,k;
  
  scanf("%d",&N);
  
  for(i=0; i < N; i++){
    scanf("%d",&A[i]);
  }

for(i=1; i <= N; i++){
for(v=0; v< N; v++){
      printf("%d",A[v]);
      if(v==N-1)
	break;
      else printf(" ");
 }

printf("\n");

v=A[i];
  j=i-1;

  while(j >=0 && A[j] > v){
    A[j+1]=A[j];
    j--;
    A[j+1]=v;
  }
  }
 
  return 0;
  }

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,a,b,t,i,j,c1=0,c2=0,c3=0;
	cin>>n>>a>>b;
	for (i=0;i<n;i++){
		cin>>t;
		if (t>b){
			c3++;
		}
		else if (t>a){
			c2++;
		}
		else {
			c1++;
		}
	} 
	cout<<min(c1,min(c2,c3));
	return 0;
}

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

    h, w = map(int, input().split())
    s = [input().rstrip() for _ in range(h)]

    d = (1, 0), (-1, 0), (0, 1), (0, -1)

    checked = [[False] * w for _ in range(h)]

    def dfs(r, c):
        sharp, dot = 0, 0
        if s[r][c] == '#':
            sharp = 1
        else:
            dot = 1

        for dr, dc in d:
            nr = r + dr
            if nr < 0 or h <= nr:
                continue
            nc = c + dc
            if nc < 0 or w <= nc:
                continue
            if s[nr][nc] == s[r][c]:
                continue
            if checked[nr][nc]:
                continue
            checked[nr][nc] = True

            res_sharp, res_dot = dfs(nr, nc)
            sharp += res_sharp
            dot += res_dot

        return sharp, dot

    ret = 0
    for r in range(h):
        for c in range(w):
            if checked[r][c]:
                continue
            checked[r][c] = True
            sharp, dot = dfs(r, c)
            ret += sharp * dot

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 189428
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,m,sum[100010] = {};
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		int a,b;
		cin >> a >> b;
		sum[a]++;
		sum[b]--;
	}
	for(int i = 1;i <= n;i++){
		sum[i] += sum[i - 1];
	}
	bool flag = true;
	for(int i = 1;i <= n;i++){
		if(sum[i] % 2) flag = false;
	}
	if(flag) YES();
	else NO();
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        String S=sc.next();
        long w=0,res=0;
        for(int i=0;i<S.length();i++){
            if(S.charAt(i)=='W') {
                res+=i-w;
                w++;
            }
        }
        System.out.println(res);
    }
}


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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   int H,W;
   cin>>H>>W;
   vector<string>S(H);
   for(int i=0;i<H;i++)cin>>S[i];
   for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
         if(S[i][j]=='#')continue;
         int sum = 0;
         for(int y=-1;y<=1;y++){
            for(int x=-1;x<=1;x++){
               if(x == 0 && y == 0)continue;
               if(j+y>=0 && j+y<W && i+x>=0 && i+x<H){
                  if(S[i+x][j+y]=='#')sum++;
               }
            }
         }
         string s = to_string(sum);
         S[i][j] = s[0];
      }
   }
   for(int i=0;i<H;i++)cout<<S[i]<<endl;
   return 0; 
}


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

int main() {
  int N, M;// Ｎ個の都市、Ｍ本の道路
  cin >> N >> M;
  //cout << "N:" << N << "::" << "M:" << M <<endl;
  vector<int> a(M);
  vector<int> b(M);
  
  for(int i=0; i<M; i++){
    cin >> a.at(i) >> b.at(i);
  }
  
  //cout << "a.at(2):" << a.at(2) << endl;
  //cout << "b.at(1):" << b.at(1) << endl;
  
  // aとbの値を調べて、書き出す
  vector<int> x(N);
  //cout << "x.at(2):" << x.at(2) << endl;
  //cout << "x.at(1) + 1 :" << x.at(1) + 1 << endl;
  
  
  for( int j=1; j<N+1; j++){ 
    for( int i=0; i<M; i++){
      if(a.at(i) == j){
        x.at(j-1) ++;// !!ここの添字をiではなくj-1に変えないと行けなかった！！なぜ？？？
      }      
    }
    for( int i=0; i<M; i++){
      if(b.at(i) == j){
        x.at(j-1) ++;
      }      
    }   
  }
   
  for( int i=0; i<N; i++){
    cout << x.at(i) << endl;    
  }
}


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

int main(){
    char str;

    while((str=getchar()) != '\n'){
        int d = (int)(str);
        if((65<=d) && (d<=90)){
            d = d + 32;
        }
        else if((97<=d) && (d<=122)){
            d = d - 32;
        }
        printf("%c", (char)(d));
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2040
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	r := bufio.NewReader(os.Stdin)

	var v []interface{}
	for {
		var s string
		if _, err := fmt.Fscan(r, &s); err != nil {
			break
		}

		var t interface{}
		n, err := strconv.Atoi(s)
		if err == nil {
			t = n
		} else {
			t = []rune(s)[0]
		}

		v = append(v, t)
	}

	fmt.Println(calc(v))
}

func calc(v []interface{}) interface{} {
	if len(v) == 0 {
		return func(n int) interface{} {
			return n
		}
	}

	switch t := v[0].(type) {
	case int:
		return calc(v[1:]).(func(int) interface{})(t)
	case rune:
		return c(v[1:], t)
	default:
		panic(t)
	}
}

func c(v []interface{}, op rune) interface{} {
	switch op {
	case '+':
		return curry(v, func(a, b int) int {
			return a + b
		})
	case '-':
		return curry(v, func(a, b int) int {
			return a - b
		})
	default:
		return curry(v, func(a, b int) int {
			return a * b
		})
	}
}

func curry(v []interface{}, f func(int, int) int) interface{} {
	return func(b int) interface{} {
		return func(a int) interface{} {
			return calc(v).(func(int) interface{})(f(a, b))
		}
	}
}



Measured memory_bytes: 1172
#include <iostream>

using namespace std;

int main() {
  string a, b;
  cin >> a >> b;
  if (a.size() > b.size()) {
    cout << "GREATER" << endl;
    return 0;
  }
  if (a.size() < b.size()) {
    cout << "LESS" << endl;
    return 0;
  }
  if (a > b) {
    cout << "GREATER" << endl;
    return 0;
  }
  if (a < b) {
    cout << "LESS" << endl;
    return 0;
  }
  cout << "EQUAL" << endl;
  return 0;
}


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

int main() { /* ここに書く */
  
  int N,M;
  cin >> N >> M;
  
  vector<int>high(N);
  
  for(int i = 0; i<N ; i++){
    
    cin >> high.at(i);
    
  }
  
  vector<bool>vec(N);
  
  for(int i = 0; i<M ; i++){
    
    int A,B;
    cin >> A >> B;
    A--;
    B--;
    
    if(high.at(A) >= high.at(B)){
      vec.at(B) = 1;  
    }
    if(high.at(A) <= high.at(B)){
      vec.at(A) = 1;
    }
  }
  
  int d;

  for(int i = 0; i<N ; i++){

    if(vec.at(i) == 0){
      d = d +1;
  }

  }
  
    cout << d << endl;
   
  
}


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

int w, h;
int m[50][50];

void dfs(int y, int x){
    m[y][x] = 0;
    for(int dy = -1; dy <= 1; dy++){
        for(int dx = -1; dx <= 1; dx++){
            int ny = y + dy;
            int nx = x + dx;
            if(ny >= 0 && ny < h && nx >= 0 && nx < w &&
               m[ny][nx] == 1)
                dfs(ny, nx);
        }
    }
    return;
}

int main(){
    while(1){
        cin >> w >> h;
        int ans = 0;
        if(w == 0 && h == 0) break;

        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cin >> m[i][j];
            }
        }
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(m[i][j] == 1){
                    dfs(i, j);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3180
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void makePrimeNumber(int N, vector<bool>& prime) // 0ツ暗按湘」Nツ暗按可コツづ個青ョツ青板つゥツづァツ素ツ青板づーツ探ツつキ
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    makePrimeNumber(60000, prime);

    vector<int> num;
    for(int i=0; i<=60000; ++i){
        if(prime[i])
            num.push_back(i);
    }

    for(;;){
        int n;
        if(!(cin >> n))
            return 0;

        vector<int>::iterator it = upper_bound(num.begin(), num.end(), n);
        int tmp = *it;
        -- it;
        if(*it == n)
            -- it;
        cout << (*it) << ' ' << tmp << endl;
    }
}

Measured memory_bytes: 0
def main():
    N = int(input())
    K = int(input())
    *xs, = map(int, input().split())

    ans = 0
    for x in xs:
        ans += min(x, K - x)
    ans *= 2
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}
int deg[205];

signed main()
{
    showoff;
    int n,ans = -1;
    cin >> n;
    string s[n+5];
    FOR(i,0,n)cin >> s[i];
    FOR(i,0,n){
    	int curdeg = 1,fo = 1;
    	memset(deg,0,sizeof deg);
    	queue<int>q;
    	q.push(i);
    	deg[i] = 1;
    	while(!q.empty()){
    		int x = q.front();
    		q.pop();
    		FOR(j,0,n)if(j != x && s[x][j] == '1'){
    			if(deg[j] == deg[x]){fo = 0;break;}
    			if(deg[j] > 0)continue;
    			deg[j] = deg[x]+1;
    			q.push(j);
    		}
    		if(!fo)break;
    	}
    	if(fo)FOR(j,0,n)ans = max(ans,deg[j]);
    }
    cout << ans;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ... 

Measured memory_bytes: 256
using System;

class Program
{
  public static void Main(string[] args)
  {
    while(true)
    {
      string[] read = Console.ReadLine().Split(' ');
      int a = int.Parse(read[0]);
      char op = char.Parse(read[1]);
      int b = int.Parse(read[2]);
      if(op == '?') break;
      switch(op){
        case '+':
        Console.WriteLine(a + b);
        break;
        case '-':
        Console.WriteLine(a - b);
        break;
        case '*':
        Console.WriteLine(a * b);
        break;
        case '/':
        Console.WriteLine(a / b);
        break;
        default:
        break;
      }
    }
  }
}

Measured memory_bytes: 9164
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <fstream>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}

long long in(){
	long long n;
	scanf("%lld",&n);
	return n;
}


string name;
int check(string s){
	for(int k = 1 ; k <= s.size() ; k++){ //kankaku
		for(int x = 0 ; x < s.size() ; x++){ //siten
			string get = "";
			for(int i = x ; i < s.size() ; i+=k){ //loop
				get += s[i];
			}
			if( ~get.find(name) ){
				return 1;
			}
		}
	}
	return 0;
}
int main(){
	//ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	cin >> name;
	int ans = 0;
	for(int i = 0 ; i < n ; i++){
		string s;
		cin >> s;
		ans += check(s);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1224
s=list(input())
ls=len(s)
fh=s[:ls//2]
lh=s[ls//2:] if ls%2==0 else s[ls//2+1:]
lh.reverse()
for i in range(len(fh)):
    if fh[i]==lh[i]:
        fh[i]="N"
while "N" in fh:
    fh.remove("N")
print(len(fh))

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>

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

template <class T> void write(T x) {
	int len = 0;
	char s[30];
	if(x < 0) putchar('-'), x = -x;
	do {
		s[++len] = x % 10;
		x /= 10;
	}while(x);
	while(len) putchar(s[len--] + '0');
}

template <class T> inline bool gmin(T &a, T b) { return a > b ? a = b, true : false; }
template <class T> inline bool gmax(T &a, T b) { return a < b ? a = b, true : false; }

const int oo = 0x3f3f3f3f;
const int maxn = 1e5 + 5;

int n, a[maxn];
int min, max;
int cntmin, cntmax;

int main() {
		read(n);
		max = -oo; min = oo;
		for(int i = 1; i <= n; i++) {
			read(a[i]);
			min = std::min(min, a[i]), max = std::max(max, a[i]);
		}
		if(max - min >= 2) puts("No");
		else if(max - min == 1) {
			cntmin = cntmax = 0;
			for(int i = 1; i <= n; i++) {
				if(a[i] == min) cntmin++;
				else cntmax++;
			}
			if(max >= cntmin + 1 && max <= cntmin + (cntmax >> 1)) puts("Yes");
			else puts("No");
		} else {
			if(max == n - 1 || (max << 1) <= n) puts("Yes");
			else puts("No");
		}
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
#define REP(i,A) for(int i=0;i<A;i++)

using namespace std;
using ll = long long int;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;

int num(ld a, ld b) {
	return (int)(b - 0.0000001) - ceil(a) + 1;
}

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

	int N, K;
	cin >> N >> K;

	ld kazu[20];
	for (int i = 1; i<20; i++) {
		kazu[i] = (ld)K / pow(2, i - 1);
	}
	ld cnt = 0;
	int ness = 0;
	for (int i = 1; i<20; i++) {
		if (kazu[i] <= N) {
			kazu[i - 1] = N+0.01;
			ness = i - 1;
			break;
		}
	}
	for (int i = ness; i<19; i++) {
		cnt += pow(0.5, i)*num(kazu[i + 1], kazu[i]) / (ld)N;
	}

	cout << setprecision(10) << cnt;
	cin >> cnt;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){

	char n[3];

	for (int i = 0; i < 3; i++){
		cin >> n[i];
		if (n[i] == '1'){
			n[i] = '9';
		}

		else if (n[i] == '9'){
			n[i] = '1';
		}
	}

	for (int i = 0; i < 3; i++){
		cout << n[i];
	}
cout<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))
R = list(range(N))
L = list(range(N))
I = [-1] * (N+1)
for i, p in enumerate(P):
    I[p] = i

ans = 0
for n, idx in enumerate(I[1:], 1):
    #print(f"n={n}, idx={idx}")
    l = idx-1
    while l>=0 and l!=L[l]:
        l = L[l]
    r = idx+1
    while r<N and r!=R[r]:
        r = R[r]
    L[idx] = l
    R[idx] = r

    if l != -1:
        l2 = l-1
        while l2>=0 and l2!=L[l2]:
            l2 = L[l2]
        #print(f"n * (l-l2) * (r-idx) = {n * (l-l2) * (r-idx)}")
        #print(l, l2)
        ans += n * (l-l2) * (r-idx)
        #L[l] = l2
    if r != N:
        r2 = r+1
        while r2<N and r2!=R[r2]:
            r2 = R[r2]
        #print(f"n * (idx-l) * (r2-r) = {n * (idx-l) * (r2-r)}")
        ans += n * (idx-l) * (r2-r)
        #R[r] = r2
print(ans)


Measured memory_bytes: 20596
def A(w, v, n,V):
    mem=[0 for i in range(V+1)]
    if n == 0 or V == 0:
        return 0
 
    for i in range(n):
        for j in range(V,w[i]-1,-1):
            m=v[i]+ mem[j - w[i]]
            if m>mem[j]:
                mem[j]=m
    return mem[V]
n,V=input().split()
n,V=int(n),int(V)
 
w=[0]*n
v=[0]*n
for i in range(n):
  x,y=input().split()
  w[i],v[i]=int(x),int(y)
 
print(A(w,v,n,V))

Measured memory_bytes: 9776
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 100000;
typedef long long ll;
ll x[MAXN + 5], d[MAXN + 5];
int a[MAXN + 5]; bool tag[MAXN + 5];
int b[MAXN + 5], ans[MAXN + 5];
int main() {
	int N, M; ll K;
	scanf("%d", &N);
	for(int i=1;i<=N;i++) {
		scanf("%lld", &x[i]);
		if( i != 1 ) d[i-1] = x[i] - x[i-1];
	}
	scanf("%d%lld", &M, &K);
	for(int i=1;i<N;i++)
		a[i] = i;
	for(int i=1;i<=M;i++) {
		int x;
		scanf("%d", &x);
		swap(a[x-1], a[x]);
	}
	for(int i=1;i<N;i++) {
		if( tag[i] ) continue;
		int p = i, siz = 0;
		do {
			tag[p] = true;
			b[siz++] = p;
			p = a[p];
		}while( p != i );
		int q = 0;
		for(int j=0;j<siz;j++) {
			ans[b[j]] = b[(j+K)%siz];
		}
	}
	ll nw = x[1];
	for(int i=1;i<=N;i++) {
		printf("%lld\n", nw);
		if( i != N ) nw += d[ans[i]];
	}
}

Measured memory_bytes: 3968
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
def make_divisors(n):
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]

def main():
    n = II()
    divisors = make_divisors(n)
    ans = len(str(divisors[-1][1]))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <functional>

int N, A, B, C, D[112];
int ans = -1;

int main(void) {
	scanf("%d%d%d%d", &N, &A, &B, &C);
	for (int i = 0; i < N; ++i) { scanf("%d", &D[i]); }

	std::sort(D, D + N, std::greater<int>());
	int greatest_cal = C;
	int greatest_dollar = 0;
	for (int i = 0; i < N; ++i) {
		greatest_cal += D[i];
		greatest_dollar = A + B*(i + 1);
		ans = std::max(ans, greatest_cal / greatest_dollar);
	}

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2744
n,s=open(0)
n=int(n)
a=l=s[0]<'W'>s[-2]
r=f=0
for b,c in zip(s,s[1:-1]):
 if n:a*=n;n-=1
 f^=b==c;a=a*(l-r)**f%(10**9+7);r+=f;l+=f^1
print(a*(l==r))

Measured memory_bytes: 3508
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s >= 0;s--)

int main()
{
	ll a,b,c,k,ans=0;
	string s;

	cin >> a >> b >> c >> k;

	ans += min(k, a);

	ans -= min(max(k - a - b, (ll)0), c);

	cout << ans;

}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028841971693993
#define MOD 998244353
#define sec setprecision
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	if (n == 0)
		return 1;
	else if (x == 1)return(1);
	else if (n % 2 == 0)
		return pow(x * x, (n / 2));
	else
		return x * pow(x, n - 1);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long com(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	ll a;
	cin >> a;
	ld b;
	cin >> b;
	ll c = a * b;
	cout << c << endl;
}


Measured memory_bytes: 3708
#include<stdio.h>
int main()
{
    int n,i,flag=0,temp;
    scanf("%d",&n);
    if(n>99 && n<1000){
        for(i=0;i<3;i++){
            temp=n%10;
            if(temp==7)
                flag=1;
            n/=10;
        }
        if(flag==1)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1664
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    String ans = "NG";
    for (int i = A; i <= B; i++) {
       if (i % K == 0) {
         ans = "OK";
         break;
       }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 27108
import itertools
import numpy as np

N,W,K = map(int,input().split())
g_all = np.array([list(input()) for i in range(N)])

K_all = np.count_nonzero(g_all == '#')
count = 0

def dfs(i,g):
  if (i<N):
    g[i,:] = ['r']*W
  else:
    g[:,i-N] = ['r']*N
  return g

g = g_all

for L in range(2**(N+W)):
  g = g_all.copy()
  for i in range(N+W):
    if (i<N):
      if ((L>>i)&1):
        g[i,:] = ['r']*W
    else:
      if ((L>>i)&1):
        g[:,i-N] = ['r']*N
  if np.count_nonzero(g == '#') ==K:
    count+=1
print(count)

Measured memory_bytes: 26972
#include<cstdio>
#include<iostream>
using namespace std;
int book[105];
int main()
{
    int n,x;
    scanf("%d %d",&x,&n);
    for(int i=1;i<=n;i++)
    {
        int tmp;
        scanf("%d",&tmp);
        book[tmp]++;
    }
    if(book[x]==0)
    {
        printf("%d",x);
        return 0;
    }
    int ans1=x;
    while(book[ans1]!=0)ans1++;
    int ans2=x;
    while(book[ans2]!=0&&ans2>=0)ans2--;
    if(ans2==0&&book[0]!=0)ans2=-1;
    if(ans1-x>=x-ans2)
    {
        printf("%d",ans2);
        return 0;
    }
    else
    {
        printf("%d",ans1);
        return 0;
    }
}



Measured memory_bytes: 3228
import java.util.Scanner;

public class Main {
	char [][] data;
	
	private char check(int x, int y){
		char ans = data[y][x];
		//tate
		if(ans == data[y+1][x] && ans == data[y-1][x]){
			return ans;
		}
		//yoko
		if(ans == data[y][x+1] && ans == data[y][x-1]){
			return ans;
		}
		//naname
		if(ans == data[y-1][x-1] && ans == data[y+1][x+1]){
			return ans;
		}
		if(ans == data[y-1][x+1] && ans == data[y+1][x-1]){
			return ans;
		}
		return '+';
		
	}

	private void doit() {
		Scanner sc = new Scanner(System.in);
		while(true){
			String str = sc.next();
			if(str.equals("0")){
				break;
			}
			data = new char[5][5];
			for(int i = 0; i < 5; i++){
				data[0][i] = '*';
				data[4][i] = '*';
			}
			for(int i = 0; i < 5; i++){
				data[i][0] = '*';
				data[i][4] = '*';
			}
			for(int i =0 ; i< 3; i++){
				data[1][i+1] = str.charAt(i);
			}
			for(int i = 2; i <= 3; i++){
				str = sc.next();
				for(int j = 0; j < 3; j++){
					data[i][j + 1] = str.charAt(j);
				}
			}
			char ans = '+';
			for(int i =1; i < 4; i++){
				for(int j = 1; j < 4; j++){
					if(data[i][j] == '+') continue;
					char result = check(j,i);
					if(result == 'b' || result == 'w'){
						ans = result;
						break;
					}
				}
				if(ans == 'b' || ans == 'w') break;
			}
			if(ans == 'b')
				System.out.println("b");
			else if(ans == 'w')
				System.out.println("w");
			else
				System.out.println("NA");
			
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();

	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, X;
    cin >> n >> X;
    vector<int> arr(n+1, 0);
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    arr[n] = X;
    sort(arr.begin(), arr.end());
    int ans = arr[1] - arr[0];
    for(int i = 2; i <= n; i++) {
        ans = __gcd(ans, arr[i]-arr[i-1]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
const ll INF = 999999999999999;

int main(){
  ll x;
  cin >> x;
  long double m = 100;
  ll ans = 0;
  while( m < (double)x ){
    m *= 1.01;
    m = (ll)m;
    ans++;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
int main(void) {
    int num,i,j,count;
    char digit[100000],now,new[100000],temp[100000];
    while (scanf("%d\n",&num)!=EOF&&num) {
        scanf("%s\n",digit);
        for (i=0; i<num; i++) {
        	memset(new,'\0',sizeof(new));
            for (j=0; j<strlen(digit); j++) {
                if (j==0) {
                    now=digit[0];
                    count=1;
                } else {
                    if (digit[j]!=now) {
                        sprintf(temp,"%d%c",count,now);
                        strcat(new,temp);
                        now=digit[j];
                        count=1;
                    } else {
                        count++;
                    }
                }
            }
            sprintf(temp,"%d%c",count,now);
            strcat(new,temp);
            strcpy(digit,new);
        }
        printf("%s\n",digit);
    }
    return 0;
}

Measured memory_bytes: 776