akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int k; scanf("%d", &k);

	auto f = [](i64 x) -> i64 {
		i64 ret = x % 10;
		while(x /= 10) ret += x % 10;
		return ret;
	};
	
	std::vector<i64> ans(1, 1);
	while(ans.size() < k) {
		const i64 n = ans.back() + 1;
		
		i64 latte = 1;
		std::vector<i64> vec;
		while(latte <= n) {
			for(i64 d = 1; d < 10; d++) {
				i64 tmp = (n - n % (latte * 10LL)) + d * latte + (latte - 1);
				if(tmp < n) continue;
				vec.push_back(tmp);
			}
			latte *= 10LL;
		}
		
		latte /= 10LL;
		for(i64 d = 1; d < 100; d++) {
			i64 tmp = d * latte + latte - 1;
			if(tmp < n) continue;
			vec.push_back(tmp);
		}

		i64 nx = vec.front();
		for(auto m: vec) {
			if(nx * f(m) <= m * f(nx)) continue;
			nx = m;
		}
		ans.push_back(nx);
	}
	for(auto v: ans) printf("%lld\n", v);
	return 0;
}


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

bool judge_M(int n) {
    bool judge;
    judge = (n >= 1 && n <= 12);
    return judge;
}

int main() {
    int S;
    int US, DS;
    string answer;
    cin >> S;
    US = S / 100;
    DS = S - (100 * US);
    if(judge_M(US)) {
        if(judge_M(DS)) {
            answer = "AMBIGUOUS";
        } else {
            answer = "MMYY";
        }
    } else {
        if(judge_M(DS)) {
            answer = "YYMM";
        } else {
            answer = "NA";
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD!string;

	writeln("ABC" ~ N);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import numpy as np

n,d = map(int,input().split())

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

x = np.array(x)

ans = 0

for i in range(len(x)):
    for j in x[i+1:]:
        if np.sqrt(sum((x[i]-j)**2))%1 == 0:
            ans +=1
    

print(ans)

Measured memory_bytes: 21624
#include<iostream>
using namespace std;
int main(){
	int a,b;
	char op;
	cin >> a >>op>> b;
	while(op!='?'){
		if(op=='+'){
			cout<<a+b;
		}else if(op=='-'){
			cout<<a-b;
		}else if(op=='*'){
			cout<<a*b;
		}else if(op=='/'){
			cout<<a/b;
		}
		cout<<endl;
		cin>>a>>op>>b;
	}
	
	
	return 0;		
}

Measured memory_bytes: 1160
import Control.Monad.ST
import Data.Char


readInt :: IO Int
readInt = read <$> getLine :: IO Int

readIntSplit :: IO [Int]
readIntSplit = map read . words <$> getLine :: IO [Int]

readStr :: IO String
readStr = getLine

readStrSplit :: IO [String]
readStrSplit = map read . words <$> getLine

main = do
  [a, b] <- readIntSplit
  print (a * b)


Measured memory_bytes: 3820
#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 ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod = MOD) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	
	return res;
}

ll f(ll l, ll base, ll M) {
	if (l <= 1) return l;
	ll res = f(l / 2, base, M) * (mod_pow(base, l / 2, M) + 1) % M;
	if (l & 1) res = (res * base + 1) % M;
	return res;
}

ll g(ll l, ll base, ll M) {
	if (l <= 1) return 0;
	ll res = g(l / 2, base, M) * (mod_pow(base, l / 2, M) + 1) % M + f(l / 2, base, M) * ((l / 2) % M) % M;
	res %= M;
	if (l & 1) res = (res * base + l - 1) % M;
	return res;
}

int main() {
	ll L, A, B, M;
	cin >> L >> A >> B >> M;
	
	ll cnt[19] = {};
	ll sum = 0;
	for (ll k = 1, p10 = 1; k <= 18; k++, p10 *= 10) {
		// [p10, p10 * 10)の個数をcnt[k]
		ll rc = p10 * 10 - 1 >= A ? (p10 * 10 - A - 1) / B + 1 : 0;
		ll lc = p10 - 1 >= A ? (p10 - A - 1) / B + 1 : 0;
		ll cur = rc - lc;
		
		if (sum + cur >= L) cur = L - sum;
		cnt[k] = cur;
		sum += cur;
	}
	
	A %= M; B %= M;
	
	sum = 0;
	ll num[19] = {};
	FOR(k, 1, 19) {
		ll base = mod_pow(10, k, M);
		num[k] = (A + B*sum) % M * f(cnt[k], base, M) % M + B * g(cnt[k], base, M) % M;
		num[k] %= M;
		sum = (sum + cnt[k]) % M;
	}
	
	ll ans = 0;
	FOR(k, 1, 19) {
		REP(i, k) ans = ans * mod_pow(10, cnt[k], M) % M;
		ans = (ans + num[k]) % M;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#[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")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(m1: i32, _d1: i32, m2: i32, _d2: i32);
    puts!("{}\n", if m1 != m2 { 1 } else { 0 });
}

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 <vector>

using namespace std;

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

    vector<int> a(m), b(m), c(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
    }

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

    for (int i = 0; i < m; i++) {
        dist[a[i]][b[i]] = c[i];
        dist[b[i]][a[i]] = c[i];
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                if (dist[j][k] > dist[j][i] + dist[i][k]) {
                    dist[j][k] = dist[j][i] + dist[i][k];
                }
            }
        }
    }

    int res = m;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            if (dist[j][a[i]] + c[i] == dist[j][b[i]]) {
                res--;
                break;
            }
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
vector<pair<char, int>>comp(vector<pair<char, int>>ps) {
	vector<pair<char, int>>newps;
	for (int i = 0; i < ps.size(); ++i) {
		if (i==ps.size()-1||ps[i].first != ps[i + 1].first) {
			if (ps[i].second) {
				newps.push_back(ps[i]);
			}
		}
		else {
			ps[i + 1].second += ps[i].second;
		}
	}
	ps = newps;
	newps.clear();
	for (int i = 0; i < ps.size(); ++i) {
		if (i == ps.size() - 1 || ps[i].first != ps[i + 1].first) {
			if (ps[i].second) {
				newps.push_back(ps[i]);
			}
		}
		else {
			ps[i + 1].second += ps[i].second;
		}
	}
	return newps;
}
void input(vector<pair<char, int>>&p) {
	while (1) {
		char c; cin >> c;
		if (c == '$')break;
		int n; cin >> n;
		p.push_back(make_pair(c, n));
	}
}
int main() {
	vector<pair<char, int>>a, b, c;
	input(a); input(b); input(c);
	a = comp(a); b = comp(b); c = comp(c);
	if (a.size() < b.size()) {

	}else
	if (b.size() == 1) {
		for (int i = 0; i < a.size(); ++i) {
			if (a[i].first == b[0].first&&a[i].second>=b[0].second) {
				a[i].second -= b[0].second;
				a.insert(a.begin() + i, c.begin(),c.end());
				break;
				
			}
		}
	}
	else {
		for (int l = 0; l <= a.size() - b.size(); ++l) {
			bool aok = true;
			if (a[l].first != b[0].first||a[l].second < b[0].second) {
				aok = false;
			}
			for (int i = 1; i < b.size() - 1; ++i) {
				if (a[l + i] != b[i]) {
					aok = false;
				}
			}
			if (a[l+b.size()-1].first != b[b.size()-1].first || a[l + b.size() - 1].second < b[b.size() - 1].second) {
				aok = false;
			}
			if (aok) {
				a[l].second -= b[0].second;
				a[l + b.size() - 1].second -= b[b.size() - 1].second;
				a.erase(a.begin() + l + 1, a.begin() + l + b.size() - 1);
				a.insert(a.begin() + l + 1, c.begin(), c.end());
				break;
			}
		}
	}
	a = comp(a);
	for (int i = 0; i < a.size(); ++i) {
		cout << a[i].first << " " << a[i].second << " ";
	}
	cout << "$" << endl;
	return 0;
}

Measured memory_bytes: 3156
#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>;

ll nck(ll n, ll k){
    
    ll p=1000000007;
    ll p2;
    p2=p-2;
    vector <int> r(35);
    vector <ll> r2(36);

    rep(j,35){
        r[j]=(p2>>j)&1;
    }

    ll ans;
    ans=1;

    if (k!=0){
    rep(i,k-1){   
        r2[0]=i+2;
        rep(j,35){
           
            r2[j+1]=(r2[j]*r2[j])%p;
            if(r[j]==1){
            ans*=r2[j];
            ans=ans%p;
            }
        }
    }
    rep(i,k){
        ans*=n-i;
        ans=ans%p;
    }
    }
    return ans;
}

int main(){
    ll n,k;
    cin >> n >> k;
    ll ans;
    ans=0;

    rep(i,k){
        ans=nck(n-k+1,i+1)*nck(k-1,k-i-1);
        ans=ans%1000000007;
        cout << ans << endl;
    }

    
    

    return 0;
}

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

const int N = 1e5 + 100, inF = N;

int n, k, ans, out[N], dis[N];
bool mark[N];
vector<int> in[N];

void dfs(int v, bool change = false) {
	mark[v] = change;
	for (int u: in[v]) 
		if(mark[u] == false) {
			dis[u] = dis[v] + 1;
			dfs(u, change);
		}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k;
	cin >> out[0];
	ans += (out[0] != 1);
	
	for (int i = 1; i < n; i++) {
		cin >> out[i];
		in[--out[i]].push_back(i);
	}
	dfs(0);
	vector<int> vec(n);
	iota(vec.begin(), vec.end(), 0);
	sort(vec.begin(), vec.end(), [](int a, int b) {
		return dis[a] > dis[b];
	});
	for (int u: vec) {
		if(mark[u] || dis[u] <= k)
			continue;
		for (int i = 0; i < k - 1; i++)
			u = out[u];
		ans++;
		dfs(u, true);
	}
	cout << ans;
	return 0;
}//////////////////

Measured memory_bytes: 11648
N,K,Q = map(int,input().split())
A_l = []
for _ in range(Q):
  A_l.append(int(input()))

must = Q - K + 1
part_l = [0 for _ in range(N)]

for A in A_l:
  part_l[A-1] += 1

for part in part_l:
  if(part<must):
    print("No")
  else:
    print("Yes")


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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int s = 1;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i]==s) s++;
        else ans++;
    }
    if(ans == n) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
list=list(map(int, input().split()))
a=[]
sum=0
for i in list:
    sum+=((i-1)*(1/2)+1)
    a.append(sum)
ma=a[K-1]
for i in range(N-K):
    ma = max(ma, a[i+K]-a[i])
print(ma)

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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string s;
	
	cin>>s;
	
	if(count(s.begin(), s.end(), 'c') == 1 && count(s.begin(), s.end(), 'b') == 1 && count(s.begin(), s.end(), 'a') == 1){
		cout<<"Yes"<<endl;
	} else cout<<"No"<<endl;
	
	return 0;
}

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

#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")

// #define int long long
#define ll long long
#define endl '\n'
#define all(v) v.bg(), v.end()
#define intvect vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; i < n; i++)
#define boolv vector<bool>
#define ld long double
#define deb(x) cout << #x << " " << x << endl;
#define pb push_back
#define pob pop_back
#define ac accumulate
#define F first
#define bg begin
#define me max_element
#define S second
#define ub upper_bound
#define bs binary_search
#define lb lower_bound
#define ull unsigned long long

const ll mod = 1e9 + 7;
const int N = 1e3 + 4;
template <typename... T>
void read(T &... args)
{
    ((cin >> args), ...);
}

template <typename... T>
void write(T &&... args) //rvalue references
{
    ((cout << args), ...);
}

void vjudge()
{
#ifndef ONLINE_JUDGE
    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
const int MAX = 2e4 + 5;
const int INF = 1e9 + 5;
void solve(int test)
{
    int dp[1010];
    int n, x, t;
    cin >> n >> x >> t;
    for (int i = 1; i < 1002; i++)
        dp[i] = (x * i);
    int p = lower_bound(dp, dp + 1002, n) - dp;
    cout << p * t << endl;
}

int32_t main()
{
    vjudge();
    int t = 1;
    // read(t);
    for (int i = 1; i <= t; i++)
        solve(i);
}


Measured memory_bytes: 3632
inputs =[i for i in map(int,input().split())]
k = int(input()) 
while True:
  if k == 0:
    break
  if not inputs[1] > inputs[0]:
    inputs[1] *=2
    k -=1
  else:
    break
if inputs[0] >= inputs[1]:
  print('No')
while True:
  if k == 0:
    break
  if not inputs[2] > inputs[1]:
    inputs[2] *=2
    k -=1
  else:
    break
if inputs[2] > inputs[1]:
  print('Yes')
else:
  print('No')
 
 


Measured memory_bytes: 9200
import bisect

f_inf = float('inf')


def cal(syurui, d, index):
    if d == 'e':
        return syurui[index]
    elif d == 'w':
        return syurui[index - 1]


A, B, Q = map(int, input().split())
s = [int(input()) for i in range(A)]
s.sort()
t = [int(input()) for i in range(B)]
t.sort()
ｓ.insert(0, -f_inf)
t.insert(0, -f_inf)
ｓ.append(f_inf)
t.append(f_inf)

for i in range(Q):
    x = int(input())
    s_index = bisect.bisect_left(s, x)
    t_index = bisect.bisect_left(t, x)
    print(min(max(abs(x-s[s_index]), abs(x-t[t_index])), max(abs(x-s[s_index-1]), abs(x-t[t_index-1])), 2*abs(x-s[s_index-1])+abs(x-t[t_index]), 2*abs(x-s[s_index])+abs(x-t[t_index-1]), abs(x-s[s_index-1])+2*abs(x-t[t_index]), abs(x-s[s_index])+2*abs(x-t[t_index-1])))


Measured memory_bytes: 12152
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
ll mod=1e9+7LL;
long long modpow(long long a, long long n, long long mod=(1LL<<62)){
	long long res = 1;
	while (n > 0){
		if (n & 1)
		res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int main(){
	ll n,a,b;
	ll ans=0LL;
	cin >>n>>a>>b;
	ans=modpow(2LL,n,mod)-1LL;
	//clog<<ans<<endl;
	//if (ans < 0)ans += mod;
	V fact(200010,1LL);
	for(ll i=1LL;i<200002;i++){
		fact[i]*=fact[i-1]*i%mod;
	}
	ll cnt=1LL;
	//clog<<"A"<<endl;
	for(ll i=0LL;i<a;i++){
		cnt*=(n-i);
		cnt%=mod;
	}
	cnt*=modinv(fact[a],mod);
	cnt%=mod;
//	clog<<cnt<<endl;
	ans-=cnt;
	if (ans < 0)ans += mod;
	ans%=mod;
	cnt=1ll;
	for (ll i = 0LL; i < b; i++)
	{
		cnt *= (n - i);
		cnt %= mod;
	}
	cnt *= modinv(fact[b], mod);
	cnt%=mod;
	//clog << cnt << endl;
	ans-=cnt;
	if(ans <0)ans += mod;
	ans %= mod;
	cout<<ans<<endl;
}
// 4 1 3
//0(1) 1(4) 2(6) 3(4) 4(1) = 16 - 2^4

Measured memory_bytes: 1792
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int a,b,h=100,w=100;
    cin>>a>>b;
    cout<<h<<" "<<w<<endl;
    char x[50][100],y[50][100];
    for (int i=0;i<50;i++)
        for (int j=0;j<100;j++)
        {
            x[i][j]='.';
        }
    for (int i=0;i<50;i++)
        for (int j=0;j<100;j++)
        {
            y[i][j]='#';
        }
    if (a==0)
    {
        for (int i=0;i<50;i++)
            for (int j=0;j<100;j++)
            {
                x[i][j]='#';
            }
        for (int i=0;i<50;i++)
        {
            for (int j=0;j<100;j++)
            {
                cout<<x[i][j];
            }
            cout<<endl;
        }
        for (int i=0;i<50;i++)
        {
            for (int j=0;j<100;j++)
            {
                cout<<y[i][j];
            }
            cout<<endl;
        }
        system ("pause");
        return 0;
    }
    if (b==0)
    {
        for (int i=0;i<50;i++)
            for (int j=0;j<100;j++)
            {
                y[i][j]='.';
            }
        for (int i=0;i<50;i++)
        {
            for (int j=0;j<100;j++)
            {
                cout<<x[i][j];
            }
            cout<<endl;
        }
        for (int i=0;i<50;i++)
        {
            for (int j=0;j<100;j++)
            {
                cout<<y[i][j];
            }
            cout<<endl;
        }
        system ("pause");
        return 0;
    }
    int m=1,n=1;
    for (int i=0;i<50;i=i+2)
        for (int j=1;j<100;j=j+2)
        {
            if (m==b) break;
            x[i][j]='#';
            m++;
        }
    for (int i=1;i<50;i=i+2)
        for (int j=1;j<100;j=j+2)
        {
            if (n==a) break;
            y[i][j]='.';
            n++;
        }
    for (int i=0;i<50;i++)
    {
        for (int j=0;j<100;j++)
        {
            cout<<x[i][j];
        }
        cout<<endl;
    }
    for (int i=0;i<50;i++)
    {
        for (int j=0;j<100;j++)
        {
            cout<<y[i][j];
        }
        cout<<endl;
    }
    system ("pause");
    return 0;
}

Measured memory_bytes: 504
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    n: usize,
    s:Chars
    }

    let mut r_cnt = 0;
    for &w in s.iter() {
      if w == 'R' {
        r_cnt += 1;
      }
    }

    if r_cnt == 0 {
      println!("{}", "0");
      return;
    }

    let mut ans = 0;
    for &w in s.iter() {
      if w == 'W' {
        r_cnt -=1;
        ans += 1;
    }else{
        r_cnt -=1;
    }

      if r_cnt == 0 {
        break;
      }
    }

     println!("{}", ans);
}


Measured memory_bytes: 3088
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long tmp = lcm(360, n);
        long tmp2 = tmp / n;
        
        // System.out.println(tmp);
        System.out.println(tmp2);
    }
    
    public static long lcm(long m, long n) {
        return m * (n / gcd(m, n));
    }
    
    public static long gcd(long a, long b) {
        if (b == 0) return a;
        
        return gcd(b, a % b);
    }
}

Measured memory_bytes: 35828
H, W, A, B = map(int, input().split())
mod = 10 ** 9 + 7
wall = [0 for _ in range(H - A)]
class Factorial:
    def __init__(self,n,mod):
        self.f=[1]
        for i in range(1,n+1):
            self.f.append(self.f[-1]*i%mod)
        self.i=[pow(self.f[-1],mod-2,mod)]
        for i in range(1,n+1)[::-1]:
            self.i.append(self.i[-1]*i%mod)
        self.i.reverse()
    def factorial(self,i):
        return self.f[i]
    def ifactorial(self,i):
        return self.i[i]
    def combi(self,n,k):
        return self.f[n]*self.i[n-k]%mod*self.i[k]%mod
f = Factorial(H + W, mod)
for i in range(H - A):
  wall[i] = f.combi(B + i - 1, i) * f.combi(W + H - B - i - 2, W - B - 1) % mod
print(sum(wall) % mod)

Measured memory_bytes: 22456
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Double Factorial
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  ll n;
  scanf("%lld", &n);

  ll sum = 0;
  if ((n & 1) == 0) {
    n /= 2;
    for (ll m = n / 5; m > 0; m /= 5) sum += m;
  }

  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str):
    lst = S[-1:]
    if lst == 's':
        return S + 'es'
    else:
        return S + 's'


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(solve(S))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9040
#include<bits/stdc++.h>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <queue>
#include <unordered_map>
#define ll long long
#define pii pair <int, int>
#define pll pair <long long, long long>
#define plxy pair <long long, pll>
#define INT_MAX 1e18
#define Keep_calm_You_are_still_learning ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace std;
const int mod=1e9+7;
const int N=1e5+5;
ll n,w,weight[105],val[105],dp[105][N],ans;
int main()
{
Keep_calm_You_are_still_learning
    cin>>n>>w;
    for(ll i=0;i<n;i++)
    {
        cin>>weight[i]>>val[i];
    }
    for(ll i=0;i<105;i++)
    {
        for(ll j=0;j<N;j++)
        {
            dp[i][j]=INT_MAX;
        }
    }
    dp[0][0]=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<N;j++)
        {
            if(j-val[i]>=0)
            {
                dp[i+1][j]=min(dp[i+1][j],dp[i][j-val[i]]+weight[i]);
                dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            }
            else
            {
                dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            }
        }
    }
    for(ll i=0;i<N;i++)
    {
         if(dp[n][i]<=w)
         {
             ans=max(ans,i);
         }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 82304
#include <stdio.h>
#include <string.h>

int main(void)
{
	char s[4];
	scanf("%s",s);
	if(strcmp(s,"SUN") == 0) printf("7\n");
	else if (strcmp(s,"MON") == 0) printf("6\n");
	else if (strcmp(s,"TUE") == 0) printf("5\n");
	else if (strcmp(s,"WED") == 0) printf("4\n");
	else if (strcmp(s,"THU") == 0) printf("3\n");
	else if (strcmp(s,"FRI") == 0) printf("2\n");
	else if (strcmp(s,"SAT") == 0) printf("1\n");
	return 0;
}



Measured memory_bytes: 128
from functools import reduce

n = int(input())
a = list(map(int, input().split()))

m = max(a)
d = [0] * (m + 1)
d[1] = 1
for i in range(2, m + 1):
    for j in range(i, m + 1, i):
        if d[j] == 0:
            d[j] = i

def prime_factorize(n):
    res = []
    if n == 1:
        return res
    while n > 1:
        res.append(d[n])
        n //= d[n]
    return res

def is_pairwise_coprime():
    exists = [0] * (m + 1)
    for ai in a:
        for p in set(prime_factorize(ai)):
            if exists[p]:
                return False
            exists[p] = 1
    return True

def gcd(a, b):
    if a == 0:
        return b
    return gcd(b % a, a)

def is_setwise_coprime():
    return reduce(gcd, a) == 1


if is_pairwise_coprime():
    print('pairwise coprime')
elif is_setwise_coprime():
    print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 127780
#include<bits/stdc++.h>
using namespace std;
 #include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
#include <iostream>  
using namespace __gnu_pbds;  
using namespace std;

// typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>  ordered_set;
#define ll long long
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll> >, rb_tree_tag,tree_order_statistics_node_update>  ordered_set;
 
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl
 
#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
 
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
 ll ar[3005][3005];
#define INF 1000000000000000000
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long double pi= 3.14159265358979323846;
    string a;
    string b;
    cin>>a>>b;
    for(ll i=0;i<a.length();i++)
    {
        for(ll j=0;j<b.length();j++)
        {
            if(a[i]==b[j])
            {
                ar[i+1][j+1]=ar[i][j]+1;
            }
            else
            {
                ar[i+1][j+1]=max(ar[i+1][j],ar[i][j+1]);
            }
            //debug(ar[i+1][j+1]);
        }
    }
    char c[3005];
    ll z=3004;
    ll k=ar[a.length()][b.length()];
    ll x=a.length();
    ll y=b.length();
    // debug(k);
    if(k==0)
    cout<<" ";
    while(k)
    {
        if(ar[x][y]==max(ar[x-1][y],ar[x][y-1]))
        {
            if(ar[x-1][y]>ar[x][y-1])
            {
                x--;
            }
            else
            {
                y--;
            }
        }
        else
        {
            c[z]=a[x-1];
            // debug(a[x-1]);
            x--;
            y--;
            k--;
            z--;
        }
    }
    z++;
    // debug(x);
    for(;z<3005;z++ )
    {
        cout<<c[z];
    }
    return 0;
}

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

int main(){
	int a,b;
	char op;
	while(1){
		cin >> a >> op >> b;
		if(op == '?')break;
		else if(op == '+')cout << a + b << endl;
		else if(op == '-')cout << a - b << endl;
		else if(op == '*')cout << a * b << endl;
		else if(op == '/')cout << a / b << endl;
	}
	
	return 0;
}

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

public class Main{
    public static void main(String[] args) throws IOException{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String str = br.readLine();
    	int[] numArray = strToInt(str.split("\\s"));
    	int result;

    	if(numArray[0] > numArray[1]){
			result = getGCD(numArray[0],numArray[1]);
    	}else{
			result = getGCD(numArray[1],numArray[0]);
    	}

        System.out.println(result);
    }
    public static int getGCD(int x,int y){
    	int temp;
    	while((temp = x % y) != 0){
    		x = y;
    		y = temp;
    	}
    	return y;
    }
    public static int[] strToInt(String[] strArray){
    	int[] numArray = new int[strArray.length];
    	for(int i=0; i<strArray.length; i++){
    		numArray[i] = Integer.parseInt(strArray[i]);
    	}
    	return numArray;
    }
}

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

int main() {
  string key;
  cin >> key;
  transform(key.begin(), key.end(), key.begin(), ::tolower);
  int cnt = 0;
  for (string s; cin >> s;) {
    if (s == "END_OF_TEXT") break;
    transform(s.begin(), s.end(), s.begin(), ::tolower);
    if (s==key) ++cnt;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3176
#include <stdio.h>

int main(void)
{
	int k;
	int n;
	int a[100000];
	int r;
	
	scanf("%d", &n);
	scanf("%d", &k);
	
	for (r = 0; r < n; r++){
		scanf("%d", &a[r]);
	}
	r = 0;
	n -= k;
	r++;
	
	k -= 1;
	
	while (n > 0){
		n -= k;
		r++;
	}
	
	printf("%d", r);
	return 0;
}


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

int main(){
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    int dp[n][3];
    for(int i = 0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
        dp[i][0] = 0,dp[i][1] = 0,dp[i][2] = 0;
    }


    dp[0][0] = a[0],dp[0][1] = b[0],dp[0][2] = c[0];
    dp[1][0] = max(dp[0][0],max(dp[0][1],dp[0][2]))+a[1];
    dp[1][1] = max(dp[0][0],max(dp[0][1],dp[0][2]))+b[1];
    dp[1][2] = max(dp[0][0],max(dp[0][1],dp[0][2]))+c[1];
    for(int i = 2;i<n;i++){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2] = max(dp[i-1][1],dp[i-1][0])+c[i];
    }


    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));



      
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct node{
	string post;			//ポスト内容
	vector< int > chnode;	//子ノードのインデックス
	bool flg;
};

void output( vector<node> *tree, int indx, int depth ) {
	string s = "";
	s.append(depth, '.');

	if( tree -> at(indx).flg ) return;
	cout << s << tree->at(indx).post << endl;

	tree -> at(indx).flg = true;

	if( tree->at(indx).chnode.size() > 0 )
		for(int i = 0; i < tree->at(indx).chnode.size(); i++)
			output( tree, tree->at(indx).chnode[i], depth+1);
}

int main(void){
	int n;
	cin >> n;
	
	vector< node > nlist;

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

		node newnode;
		newnode.post = M;
		newnode.flg = false;

		if( k > 0 )
			nlist[k - 1].chnode.push_back( i );

		nlist.push_back( newnode );
	}
	output( &nlist, 0, 0 );
    return 0;
}

Measured memory_bytes: 2016
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
 
int main(){
  int N;
  cin >> N;
  int A[N];
  int ans = 0;
  for(int i=0;i<N;i++){
    cin >> A[i];
    ans ^= A[i];
  }
  if(ans) cout << "No" << endl;
  else cout << "Yes" << endl; 
}

Measured memory_bytes: 640
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {


		String s = nextString();
		int x=1;
		int df=0;
		int ans =0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)-'0'!=x){
				df++;
			}
			x=(x+1)%2;
		}
		ans=df;

		x=0;
		df=0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)-'0'!=x){
				df++;
			}
			x=(x+1)%2;
		}

		System.out.println(Math.min(ans, df));

	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 300009
ll m,a,b,c,d,n,arr[sz],i,k,j,x,y;
int main()
{
scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
if(a<=k)
{
    m+=a;
    k-=a;
}
else
{
    m+=k;
    k=0;
}
if(b<=k)
{
    //m+=a;
    k-=b;
}
else
    k=0;
if(c<=k)
{
m-=c;
}
else
    m-=k;
    printf("%lld\n",m);
return 0;
}


Measured memory_bytes: 3820
#include <cstdio>
#include <algorithm>
#define maxn 100005
using namespace std;
int a[maxn], b[maxn], c[maxn];
int cmp(int x, int y)
{
    return x > y;
}
int main()
{
    int x, y, an, bn, cn;
    scanf("%d%d%d%d%d", &x, &y, &an, &bn, &cn);
    for (int i = 0; i < an; i++)
        scanf("%d", a + i);
    for (int i = 0; i < bn; i++)
        scanf("%d", b + i);
    for (int i = 0; i < cn; i++)
        scanf("%d", c + i);
    sort(a, a + an, cmp);
    sort(b, b + bn, cmp);
    sort(c, c + cn, cmp);
    long long ans = 0;
    for (int i = 0; i < x; i++)
        ans += a[i];
    for (int i = 0; i < y; i++)
        ans += b[i];
    a[maxn - 1] = b[maxn - 1] = 1000000000;
    int ea = x - 1, eb = y - 1;
    for (int i = 0; i < cn; i++)
    {
        int t1 = c[i] - a[ea], t2 = c[i] - b[eb];
        if (t1 <= 0 && t2 <= 0)
            break;
        if (t1 > t2)
        {
            ans -= a[ea];
            ans += c[i];
            ea--;
            if (ea < 0)
                ea = maxn - 1;
        }
        else
        {
            ans -= b[eb];
            ans += c[i];
            eb--;
            if (eb < 0)
                eb = maxn - 1;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1280
def solve(string):
    n, *p = map(int, string.split())
    ans = 0
    m = n + 1
    for _p in p:
        if _p < m:
            ans += 1
            m = _p
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 26012
#include<bits/stdc++.h>
using namespace std;
bool dp[85][85][12810];
int n,m,a[100][100],x;
int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			cin>>a[i][j];
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			cin>>x;
			a[i][j]=abs(a[i][j]-x);
		}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			for (int k=0;k<=12800;k++)
				if (dp[i][j-1][k]==1||dp[i-1][j][k]==1){
					dp[i][j][k+a[i][j]]=1;
					dp[i][j][abs(k-a[i][j])]=1;
				}
				else if (i==1&&j==1)
					dp[i][j][a[i][j]]=1;
	for (int i=0;i<=12800;i++)
		if (dp[n][m][i]==1){
			cout<<i<<endl;
			break;
		}
	return 0;
}

Measured memory_bytes: 86784
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define cont continue  
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 2147483646;
const double pi = 3.141592653589793;

string makes[5001] = {};
bool compare(string u, string v) {
  if(u.size() > v.size()) {
    int diff = u.size() - v.size();
    v += makes[diff];
  }
  else if(u.size() < v.size()) {
    int diff = v.size() - u.size();
    u += makes[diff];
  }
  return u < v;
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);

  string s;
  cin >> s;
  int K;
  cin >> K;
  set<string>st;
  for(int i = 1 ; i <= 5000 ; i++) {
    makes[i] = makes[i - 1] + 'a';
  }
  for(int i = 0 ; i < s.size() ; i++) {
    string tmp;
    for(int j = i ; j < s.size() ; j++) {
      tmp += s[j];
      if(tmp.size() > K) break;
      st.insert(tmp);
    }
  }

  vector<string> arr;

  for(auto x : st) {
    arr.pb(x);
  } 

  sort(arr.begin(), arr.end(), compare);
  cout << arr[K - 1] << endl;
} 


Measured memory_bytes: 21248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    int Q;cin >> Q;
    vector<int> l(Q),r(Q);
    for(int i=0; i<Q; i++) cin >> l[i] >> r[i];
    vector<bool> Primes(100010,true);
    Primes[1]=false;
    Primes[0]=false;
    for(int i=2; i*i<100010; i++){
        if(!Primes[i]) continue;
        for(int j=i*i; j<=100010; j+=i){
            Primes[j]=false;
        }
    }
    vector<int> sum(100010);
    for(int i=1; i<100010; i++){
        if(Primes[i]&&Primes[(i+1)/2]) sum[i]=sum[i-1]+1;
        else sum[i]=sum[i-1];
    }
    for(int i=0; i<Q; i++){
        cout << sum[r[i]]-sum[l[i]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
    int N, mp, lp, mm, lm;
    scanf("%d", &N);
    scanf("%d %d", &mp, &lp);
    scanf("%d %d", &mm, &lm);
    std::printf("%d\n", N - max(((mp % mm == 0)? mp/mm : mp/mm+1), ((lp % lm == 0)? lp/lm : lp/lm+1)));
    return 0;
}



Measured memory_bytes: 2700
from collections import Counter

n = int(input())
lst = [int(i) for i in input().split()]

x,y = 0,0

c = Counter(lst)

for k,v in c.items():
    if 4 <= v:
        x = max(x,k)
        y = max(y,k)

    elif 2 <= v:
        s = min(x,y)
        if k > s:
            x = max(x,y)
            y = k
print(x*y)

Measured memory_bytes: 18600
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x;
	cin >> x;
      cout<<"ABC" << x << endl;
}

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

#define BIG 10000

int main(){
	int n, m;
	cin>>n>>m;
	vector<string> s(n);
	rep(i, n) cin>>s[i];

	mcf_graph<int, int> g(n*m*2+2);
	int b=n*m*2, t=n*m*2+1, ura=n*m;
	rep(i, n) rep(j, m){
		if(i+1<n) g.add_edge(ura+i*m+j, ura+(i+1)*m+j, BIG, BIG);
		if(j+1<m) g.add_edge(ura+i*m+j, ura+i*m+j+1, BIG, BIG);
	}
	rep(i, n) rep(j, m){
		if(s[i][j]!='#'){
			g.add_edge(i*m+j, ura+i*m+j, 1, BIG);
			if(i+1<n && s[i+1][j]!='#') g.add_edge(i*m+j, (i+1)*m+j, BIG, BIG-1);
			if(j+1<m && s[i][j+1]!='#') g.add_edge(i*m+j, i*m+j+1, BIG, BIG-1);
		}
		if(s[i][j]=='o'){
			g.add_edge(b, i*m+j, 1, BIG);
		}
	}
	g.add_edge(ura+(n-1)*m+(m-1), t, BIG, BIG);
	// g.add_edge(b, t, BIG, BIG);

	// auto vp=g.slope(b, t);
	// int mx=0;
	// for(auto p : vp) mx=max(mx, BIG*p.first - p.second);
	// cout<<"sum"<<sum<<endl;
	// cout<<p.first<<" "<<p.second<<endl;
	auto p=g.flow(b, t);
	int sum=0;
	auto es=g.edges();
	for(auto e : es) sum+=e.flow;
	int ans=BIG*sum - p.second;

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


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

int main(void){
  string str;
  while(cin >> str, str[0] - '0'){
    map<char, int> p;
    p['A'] = 0; p['B'] = 0;
    for(int i=1; i < str.length(); i++){
      p[str[i]]++;
    }
    if(p['A'] >= 10 && p['B'] >= 10){
      p[*(str.end()-1)]++;
      cout << p['A'] << " " << p['B'] << endl;
    }else if(p['A'] == 10){
      p['A']++;
      cout << p['A'] << " " << p['B'] << endl;
    }else if(p['B'] == 10){
      p['B']++;
      cout << p['A'] << " " << p['B'] << endl;
    }
  }
  return 0;
}

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

int n, m, d;
bool mat[650][650];
bool a[25][25];

bool valid(int x, int y)
{
    if(x < n && x >= 0 && y < m && y >= 0) return true;
    return false;
}

int main()
{
    int cnt = 0;
    while(~scanf("%d%d%d", &m, &n, &d), n + m + d)
    {

        cnt++;
        memset(mat, 0, sizeof mat);

        for(int i = 0; i < n; i++)
            for(int j = 0; j < m; j++)
                scanf("%d", &a[i][j]);

        int row = n * m, col = n * m + 1;

        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                for(int k = 0; k <= d; k++)
                {
                    int t1x = i + k, t1y = j + d - k;
                    int t2x = i - k, t2y = j + d - k;
                    int t3x = i + k, t3y = j - d + k;
                    int t4x = i - k, t4y = j - d + k;
                    if(valid(t1x, t1y)) mat[t1x * m + t1y][i * m + j] = 1;
                    if(valid(t2x, t2y)) mat[t2x * m + t2y][i * m + j] = 1;
                    if(valid(t3x, t3y)) mat[t3x * m + t3y][i * m + j] = 1;
                    if(valid(t4x, t4y)) mat[t4x * m + t4y][i * m + j] = 1;
                }
                mat[i * m + j][i * m + j] = 1;
            }
        }

        int flag = 0, pivot = 0;

        for(int i = 0; i < n * m; i++)
            mat[i][n * m] = a[i / m][i % m];

        int ansl = 0, matl = 0;

        for(int i = 0; i < col - 1; i++)
        {
            int pt = pivot;
            while(mat[pt][i] == 0 && pt < row) pt++;
            if(pt >= row) continue;
            for(int j = 0; j < col; j++) swap(mat[pivot][j], mat[pt][j]);
            for(int j = pivot + 1; j < row; j++)
                if(mat[j][i] == 1)
                    for(int k = i; k < col; k++)
                        mat[j][k] ^= mat[pivot][k];
            pivot++;
        }

        for(int u = row - 1; u >= 0; u--)
        {
            int fla = 0;
            for(int v = 0; v < col - 1; v++)
                if(mat[u][v] == 1) fla = 1;
            if(fla == 0 && mat[u][col - 1] == 1)
            {
                flag = 1;
                break;
            }
        }
        printf("%d\n", flag ^ 1);
    }
    return 0;
}

/*

2 3 1
0 0 1
0 0 0
2 3 1
1 0 1
0 0 0
2 3 1
0 1 1
0 0 0

*/

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

int main()
{
    int X, A, B;
    cin >> X >> A >> B;

    if(B-A <= 0){
        cout << "delicious" << endl;
    }else if( B-A <=X ){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const int mod=1e9+7;
const vi emp;
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};

int n,m;
vi a;

int main(){
	cin>>n>>m;
	a=vi(m);
	vi ans(n);
	for(int i=0;i<m;i++) cin>>a[i];
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			int t;
			cin>>t;
			if(a[i]!=t) ans[a[i]-1]++;
			else ans[j]++;
		}
	}
	for(int i=0;i<n;i++) cout<<ans[i]<<endl;
}

Measured memory_bytes: 3156
#!/usr/bin/env python3
import sys


def solve(N: int):
    print((N-1)//2+1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int n,k,tmp,ct=1;

void solve(){
        tmp=k;
        if(k<n) {
                while(true) {
                        ct++;
                        tmp*=k;
                        if(tmp>n) {
                                break;
                        }
                }
        }
        cout<<ct<<endl;
}

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

        solve();
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
	int H, W, count;
	cin >> H >> W;
    string weather;
	
	rep(i, H)
	{
	    cin >> weather;
	    count = -1;
		rep(j, W)
		{
		    if(j!=0) cout << " ";
			if(weather[j]=='c') count = 0;
			cout << count;
			if(count!=-1) count++;
		}
		cout << endl;
	}
}



Measured memory_bytes: 3168