akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>

using namespace std;
typedef long long ll;

const int mod = 1000000007;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        swap(a -= t * b, b);
        swap(u -= t * v, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

struct combination {
    vector<ll> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i % mod;
        ifact[n] = modinv(fact[n], mod);
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i % mod;
    }

    ll operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return (fact[n] * ifact[k] % mod) * ifact[n - k] % mod;
    }
};

int main() {
    int n, k;
    ll res = 0;
    cin >> n >> k;
    vector<ll> v(n);
    combination c(n);
    for (int i = 0; i < n; ++i) cin >> v[i];
    sort(v.begin(), v.end());
    for (int i = k - 1; i < n; ++i) {
        res = (res + c(i, k - 1) * v[i] % mod) % mod;
    }
    reverse(v.begin(), v.end());
    for (int i = k - 1; i < n; ++i) {
        res = (res - c(i, k - 1) * v[i] % mod) % mod;
    }
    cout << res << endl;
}

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

int main() {
	int h, w,i,j; char s[52][52] = {};
	cin>>h>>w;
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			cin>>s[i][j];
		}
	}
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			if(s[i][j]=='#'){
				if(s[i-1][j]=='#');
				else if(s[i+1][j]=='#');
				else if(s[i][j-1]=='#');
				else if(s[i][j+1]=='#');
				else {
					cout<<"No";
					return 0;
				}
			}
		}
	}
	cout<<"Yes";
	return 0;
}

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

int main(){
  int n,ans;
  string s,r;

  cin >> s;
  cin >> n;
  ans = 0;
  for(int i=0;i<n;i++){
    cin >> r;
    string tmp = r;
    do{
      if(r.substr(0,s.size()) == s){
	ans++;
	break;
      }
      rotate(r.begin(),r.begin()+1,r.end());
    }while(tmp!=r);
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
    vector<string> mp;
    for(int i=0;i<4;i++){
        mp.push_back("#.#.#.#.");
        mp.push_back("########");
    }
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--,b--,c--,d--;
        int res = 0;
        for(int j=0;j<8;j++){
            for (int k = 0;k<8;k++){
                if(j>=a&&j<=c&&k>=b&&k<=d)
                    res += (mp[j][k]=='#');
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

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

    if(n == m){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define F first
#define S second
#define int long long

const int maxn = 1e5+10;
const int mod = 998244353;
//const int inf = 1e9;

int n, m;
int a[maxn];

signed main()
{
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin>> n;
    int sm = 0, ans = 0, sum = 0;
    for(int i = 1; i <= n; i++)
    {
        cin>> a[i];
        sum += a[i];
        sm ^= (a[i]&1);
        if(a[i] == 0)
        {
            ans += sm;
            sm = 0;
        }
    }

    cout<< (sum - ans) / 2;
}









Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int MOD = 1e9 + 7;

ll N,M,K,H,W;

int main(){
    cin >>  N >> K;
    double m;
    vector<double> ruiseki(N+1, 0);
    for(int i = 1; i < N+1; ++i){
        cin >> m;
        ruiseki[i] = ruiseki[i-1] + (m+1)/2;
    }
    double ans = -1;
    for(int i = 0; i < N-K+1; ++i){
        ans = max(ans, ruiseki[K+i] - ruiseki[i]);
    }
    cout << setprecision(12) << ans;
    return 0;
}




Measured memory_bytes: 1792
H,W=map(int,input().split())
S=[input() for _ in range(H)]
A=[]
for i in range(H):
    tmp=''
    for j in range(W):
        if S[i][j]=='#':
            tmp+='#'
        else:
            cnt=0
            for m in range(max(i-1,0),min(i+1,H-1)+1):
                for n in range(max(j-1,0),min(j+1,W-1)+1):
                    if S[m][n]=='#':
                        cnt+=1
            tmp+=str(cnt)
    A.append(tmp)
for a in A:
    print(a)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount


int32_t main(){
	int a,b,c;
	cin>>a>>b>>c;
	int d = c-a-b;
	if(d>0 && d*d>4*a*b){
		cout<<"Yes";
	}
	else {
		cout<<"No";
	}
}


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

if K % 2 != 0:
    num = [i for i in range(1, N+1) if i % K ==0]
    print(len(num)**3)
else:
    num = [i for i in range(1, N+1) if i % K == 0]
    half_num = [i for i in range(1, N+1) if i % K == (K/2)]
    print((len(num))**3 + len(half_num)**3)

Measured memory_bytes: 10936
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let s = sc.read_chars();
    let t = sc.read_chars();

    let mut ans = std::usize::MAX;
    for i in 0..(s.len() - t.len() + 1) {
        let mut cand = 0;
        for j in 0..t.len() {
            if s[i + j] != t[j] {
                cand += 1;
            }
        }
        ans = cmp::min(ans, cand);
    }
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2280
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N; cin >> N;
  
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  
  for(int i=0; i<N; i++)
    cin >> A.at(i);
  for(int i=0; i<N; i++)
    cin >> B.at(i);
  for(int i=0; i<N-1; i++)
    cin >> C.at(i);
  
  int ans = 0;
  for(int i=0; i<N; i++){
    
    ans += B.at( A.at(i)-1 );
    if( i != N-1 && A.at(i+1) == A.at(i)+1 )
      ans += C.at( A.at(i)-1 );
  
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n;
    ll W;
    cin >> n >> W;
    vector<ll> v(n), w(n);
    for(int i = 0; i < n; i++){
        cin >> v[i] >> w[i];
    }
    int n2 = n/2;
    vector<pair<ll,ll>> vp;
    for(int i = 0; i < 1<<n2; i++){
        ll tmpv = 0, tmpw = 0;
        for(int j = 0; j < n2; j++){
            if((i>>j)&1)    tmpv += v[j], tmpw += w[j];
        }
        if(tmpw > W)    continue;
        vp.push_back({tmpw, tmpv});
    }
    sort(vp.begin(), vp.end());
    for(int i = vp.size()-1; i >= 1; i--){
        if(vp[i].first == vp[i-1].first){
            int rm = i-1;
            while(vp[rm].first == vp[i].first)  vp[rm--] = {0,0};
            i = rm+1;
        }
    }
    sort(vp.begin(), vp.end());
    vp.erase(unique(vp.begin(),vp.end()), vp.end());
    
    for(int i = 1; i < vp.size(); i++){
        vp[i].second = max(vp[i].second, vp[i-1].second);
    }
    ll ans = 0;
    for(int i = 0; i < 1<<(n-n2); i++){
        ll tmpv = 0, tmpw = 0;
        for(int j = 0; j < n-n2; j++){
            if((i>>j)&1)    tmpv += v[n2+j], tmpw += w[n2+j];
        }
        if(tmpw > W)    continue;
        auto it = upper_bound(vp.begin(),vp.end(),make_pair(W-tmpw+1,0ll));
        it--;
        ans = max(ans, (*it).second+tmpv);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  ll h, w;
  cin >> h >> w;

  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }

  ll n = h * w;
  ll result = (n + 1) / 2;
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {


    public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    for(int i=1;; i++)
        {
        String str = in.readLine();
        int num = Integer.parseInt(str);
        if(num == 0){break;}else
            {
            System.out.println("Case "+i+": "+num);
            }
        }
    }
    
}

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

struct UF {
	int par[100000];
	int num[100000];
	UF() { for (int i = 0; i < 100000; i++) { par[i] = i; num[i] = -1; } }
	int root(int x) { if (par[x] == x) return x; return par[x] = root(par[x]); }
	bool unit(int x, int y) {
		x = root(x);
		y = root(y);
		par[x] = y;
		if (num[x] != -1) {
			if (num[y] != -1 && num[y] != num[x]) return false;
			num[y] = num[x];
		}
		return true;
	}
	bool update(int c, int x) {
		c = root(c);
		if (num[c] != -1 && num[c] != x) return false;
		num[c] = x;
		return true;
	}
};

UF uf;
int n, m, k;
int t, a, b;

int main() {
	int i;
	
	cin >> n >> m >> k;
	for (i = 0; i < k; i++) {
		cin >> t >> a >> b;
		a--; b--;
		if (t == 1) {
			bool res = uf.unit(a, b);
			if (!res) break;
		}
		else {
			bool res = uf.update(a, b);
			if (!res) break;
		}
	}
	if (i == k) cout << 0 << endl;
	else cout << i + 1 << endl;
	return 0;
}


Measured memory_bytes: 3884
#include <stdio.h>
static long q, h, s, d, n, sum;
double f(double cost, double size) {
    return cost / size;
}
int main(void) {
    scanf("%ld%ld%ld%ld%ld", &q, &h, &s, &d, &n);
    if (f(s, 1) <= f(d, 2))
        d = 2 * s;
    if (f(h, 0.5) <= f(s, 1))
        s = 2 * h;
    if (f(h, 0.5) <= f(d, 2))
        d = 4 * h;
    if (f(q, 0.25) <= f(h, 0.5))
        h = 2 * q;
    if (f(q, 0.25) <= f(s, 1))
        s = 4 * q;
    if (f(q, 0.25) <= f(d, 2))
        d = 8 * q;
    while (n >= 2) {
        sum += d;
        n -= 2;
    }
    while (n >= 1) {
        sum += s;
        n -= 1;
    }
    while (n >= 0.5) {
        sum += h;
        n -= 0.5;
    }
    while (n >= 0.25) {
        sum += q;
        n -= 0.25;
    }
    printf("%ld\n", sum);
    return 0;
}


Measured memory_bytes: 128
# ABC091C
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(N)]
cd.sort()
ans = 0

for i in range(N):
    blue_x , blue_y = cd[i][0], cd[i][1]
    red_list_x = []
    red_list_y = []
    red_list_index = []
    for k in range(len(ab)):
        red_x, red_y = ab[k][0], ab[k][1]
        if blue_x > red_x and blue_y > red_y:
            red_list_x.append(red_x)
            red_list_y.append(red_y)
            red_list_index.append(k)
    if red_list_index:
        loc = red_list_index[red_list_y.index(max(red_list_y))]
        ans += 1
        del ab[loc]
        

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <bitset>
#include <cassert>
#include <queue>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
//#define double long double
#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define hash hash228
const int SZ = 1e5 + 4;
const double EPS = 1e-7;
const int mod = 998244353;
const int hashpow = 127;
const int inf = 2e9;

int n, m;
int a[SZ];
int sum = 0;

void read() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
}

void solve() {
    sort(a, a + n, [&](int a, int b) { return a > b; });

    for (int i = 0; i < m; ++i) {
        if (4 * m * a[i] < sum) {
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
}

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int S[10001], T[501];
int n, q;

int search(int key){

    int i = 0;

    // 番兵追加
    S[n] = key;

    // 探索　見つかれば脱
    while(S[i] != key){
        i++;
    }

    if(i == n) return 0;
    else return 1;
}

int main() {

    int i;
    int cnt = 0;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }

    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &T[i]);
    }


    i = 0;

    while(i < q){
        if(search(T[i])){
            cnt++;
        }
        i++;
    }
    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 640
import numpy as np
IN = lambda:map(int, input().split())

n,k = IN()
dp = np.full(n*1000+1, k+1, dtype=int)
dp[0] = 0

for _ in range(n):
  w,v = IN()
  dp[v:] = np.minimum(dp[:-v]+w, dp[v:])

print(np.max(np.where(dp <= k)))


Measured memory_bytes: 14904
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    str t;
    cin >> t;
    fx(x, t) {
 		if (x == '?')
 			x = 'D';
    }
    cout << t << '\n';

}

Measured memory_bytes: 3776
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
	int n;
	int a[100000];
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",a+i);
	sort(a,a+n);
	int ans = 0;
	for(int i=0;i<n-1;i++){
		if(min(ans,a[n-1]-ans)<min(a[i],a[n-1]-a[i])) ans = a[i];
	}
	printf("%d %d\n",a[n-1],ans);
}


Measured memory_bytes: 512
n,m,l=map(int,input().split())
abcs=[list(map(int,input().split())) for _ in range(m)]
for i in range(m):
	abcs[i][0]-=1
	abcs[i][1]-=1
inf =1234567890123456
dist = [[inf for i in range(n)] for j in range(n)]
for i in range(n):
	dist[i][i] = 0

for i in range(m):
	a=abcs[i][0]
	b=abcs[i][1]
	c=abcs[i][2]
	dist[a][b] = dist[b][a] = c

for k in range(n):
	for i in range(n):
		for j in range(n):
			dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j])

ans = [[inf for i in range(n)] for j in range(n)]
for i in range(n):
	ans[i][i]=0
for i in range(n):
	for j in range(i+1,n):
		if dist[i][j]<=l:
			ans[i][j]=ans[j][i]=1
for k in range(n):
	for i in range(n):
		for j in range(n):
			ans[i][j] = min(ans[i][j],ans[i][k]+ans[k][j])


for _ in range(int(input())):
	f,t=map(int,input().split())
	f-=1
	t-=1
	print(ans[f][t]-1 if ans[f][t]!=inf else -1)

Measured memory_bytes: 66904
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
#include <complex>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef long long ll;
typedef vector<int> vi;

const int MAX_N = 1000000;
bool prime[1000000];
int np[1000000];

void eratosthenes() {
	fill(prime, prime+MAX_N, true);
	prime[0] = prime[1] = false;
	for(int i=2; i<=MAX_N; i++) {
		if(prime[i]) {
			for(int j=i<<1; j<=MAX_N; j+=i) {
				prime[j] = false;
			}
		}
	}

	fill(np, np+MAX_N, 0);
	for(int i=1; i<=MAX_N; i++) {
		if(prime[i]) {
			np[i] = np[i-1] + 1;
		} else {
			np[i] = np[i-1];
		}
	}
}

int main() {
	eratosthenes();

	int n;
	while(scanf("%d\n", &n)!=EOF) {
		printf("%d\n", np[n]);
	}
}

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

class Dice {
private:
	int d[6];
public:
	Dice(int d1, int d2, int d3, int d4, int d5, int d6) {
		d[0] = d1;
		d[1] = d2;
		d[2] = d3;
		d[3] = d4;
		d[4] = d5;
		d[5] = d6;
	}

	int get(void) {
		return d[0];
	}

	void move(char a) {
		int nextd[6];
		switch (a) {
		case 'W':
			nextd[0] = d[2];
			nextd[1] = d[1];
			nextd[2] = d[5];
			nextd[3] = d[0];
			nextd[4] = d[4];
			nextd[5] = d[3];
			break;
		case 'S':
			nextd[0] = d[4];
			nextd[1] = d[0];
			nextd[2] = d[2];
			nextd[3] = d[3];
			nextd[4] = d[5];
			nextd[5] = d[1];
			break;
		case 'E':
			nextd[0] = d[3];
			nextd[1] = d[1];
			nextd[2] = d[0];
			nextd[3] = d[5];
			nextd[4] = d[4];
			nextd[5] = d[2];
			break;
		case'N':
			nextd[0] = d[1];
			nextd[1] = d[5];
			nextd[2] = d[2];
			nextd[3] = d[3];
			nextd[4] = d[0];
			nextd[5] = d[4];
			break;
		}
		for (int i = 0;i < 6;i++) {
			d[i] = nextd[i];
		}
	}
};

int main() {
	int a[6];
	string command;
	for (int i = 0;i < 6;i++) cin >> a[i];
	Dice dice(a[0], a[1], a[2], a[3], a[4], a[5]);

	cin >> command;

	for (int i = 0;i < command.size();i++) dice.move(command[i]);
	cout << dice.get() << endl;
}

Measured memory_bytes: 1204
#include <iostream>
#include<algorithm>
#include<set>
#include<queue>
#define rep(i,j,n) for(int i=j;i<n;i++)
using namespace std;
#define int long long
#define inf 1000000007
signed main(){
    int n;cin>>n;
    int a,b,c;cin>>a>>b;
    c=a-b;
    int hea[114514];
    int count=0;
    rep(i,0,n){
        cin>>hea[i];
        count+=hea[i]/a+1;
    }
    int left,right,mid=0;
    left=-1;
    right=count;
    rep(i,0,100){
        count=0;
        mid=(left+right)/2;
        rep(i,0,n){
            int h=hea[i];
            if(h<=b*mid)continue;
            count+=((h-(b*mid))+c-1)/c;
        }
        if(count<=mid){
            right=mid;
        }
        else left=mid;
    }
    cout<<right<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const string YES = "Yes";
const string NO = "No";

bool solve(std::string S, std::string T){
	REP(i, S.size()) {
		if(S[i] != T[i]) {
			return false;
		}
	}
	if(S.size() != T.size() -1) return false;
	return true;

}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    if(solve(S, T)) {
		cout << YES << endl;
	} else {
		cout << NO << endl;
	}
    return 0;
}



Measured memory_bytes: 3628
import sys

class HashTable:
    def __init__(self):
        self.table = [None] * 4
        self.flag = False

class Dictionary:
    def __init__(self):
        self.hashTable = HashTable()

    def insert(self, key):
        table = self.hashTable
        for c in key:
            hash = self.toHash(c)
            if table.table[hash] is None:
                table.table[hash] = HashTable()
            table = table.table[hash]
        table.flag = True

    def find(self, key):
        table = self.hashTable
        for c in key:
            hash = self.toHash(c)
            if table.table[hash] is None:
                return False
            table = table.table[hash]
        if table.flag:
            return True
        else:
            return False

    def toHash(self, key):
        if key == "A":
            return 0
        elif key == "C":
            return 1
        elif key == "G":
            return 2
        else:
            return 3

if __name__ == "__main__":
    dic = Dictionary()
    lines = sys.stdin.readlines()
    del lines[0]
    for command in lines:
        key = command.split()[1]
        if command[0] == "i":
            dic.insert(key)
        else:
            if dic.find(key):
                print "yes"
            else:
                print "no"

Measured memory_bytes: 234888
#include <iostream>
#include <set>
using namespace std;
typedef pair<int, int> Pii;
int main() {
  int N, Q;
  cin >> N >> Q;
  static int memo[1000001];
  set<Pii> st;
  for(int q=0; q<Q; q++) {
    int a, v; scanf("%d%d", &a, &v);
    st.erase(Pii(-memo[a], a));
    memo[a] += v;
    st.insert(Pii(-memo[a], a));
    printf("%d %d\n", st.begin()->second, -st.begin()->first);
  }
  return 0;
}

Measured memory_bytes: 9576
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9
#define MOD 1000000007
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
 
 
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(all(h));

    ll ans = INF;
    int i = 0;
    while(i+k-1<n){
        ans = min(ans, h[i+k-1]-h[i]);
        i++;
    }
    cout << ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i= (a); i<(b); i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(), (obj).end()
using namespace std;

const long long INF = 1LL << 60;
const int MOD = (int)1e9 + 7;
typedef long long ll;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
signed main () {
    int n;scanf("%d",&n);
    vector<int> S(n);
    REP(i,n){
        int tmp;scanf("%d",&tmp);
        S[i]=tmp;
    }
    int m;scanf("%d",&m);
    int ans=0;
    REP(i,m){
        int tmp;scanf("%d",&tmp);
        if(binary_search(S.begin(), S.end(),tmp))ans++;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 3220
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

vector<int> path[10005];
bool used[10005];
int s[10005];
priority_queue<int,vector<int>,greater<int> > q1;

void check(int a){
	if(used[a])return;
	used[a]=true;
	for(int i=0;i<path[a].size();i++){
		check(path[a][i]);
	}
	s[a]=q1.top(),q1.pop();
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	int t=0,t2=0;
	cin>>n;
	for(i=0;i<n-1;i++){
		cin>>a>>b;
		a--,b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	for(i=0;i<n;i++){
		cin>>a;
		q1.push(a);
		t+=a;
		t2=max(t2,a);
	}
	check(0);
	cout<<t-t2<<endl;
	array_show(s,n);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef vector<vector<int> > mat;
int h,w,n;
inline void mat_mul(mat &A, mat &B, int M=1000000009){
  mat ret(w,vector<int>(w));
  for(int i = 0; i < w; ++i){
    for(int j = 0; j < w; ++j){
      ret[i][j] = 0;
      for(int k = 0; k<w; ++k){
        ret[i][j] += (A[i][k]*B[k][j])%M;
        ret[i][j] %= M;
      }
    }
  }
  A=ret;
}
  
inline void mat_pow(mat &A, int N, int M=1000000009){
  mat ret(A.size(),vector<int>(A.size(),0)), t = A;
  for(int i = 0; i < A.size(); ++i) ret[i][i] = 1;
  int k = 0;
  while(N>0){
    if(N&1){
      mat_mul(ret,t,M);
    }
    mat_mul(t,t,M);
    N>>=1;
  }
  A=ret;
}
  
mat XXX;
  
void init(){
    mat res(w,vector<int>(w,0));
    for(int i=0;i<w;i++){
        for(int j=0;j<w;j++){
            if(i==j){
                if(i)res[i-1][j]=1;
                res[i][j]=1;
                if(i!=w-1)res[i+1][j]=1;
            }
        }
    }
    XXX=res;
}
  
  
inline mat make_mat(vector<int> &V){
    mat res=XXX;
    for(int i=0;i<V.size();i++){
        for(int j=0;j<w;j++){
            res[j][V[i]]=0;
        }
    }
    return res;
}
  
signed main(){
    init();
    int cnt=0;
    while(cin>>w>>h>>n,w){
        init();
        cout<<"Case "<<(++cnt)<<": ";
        vector<P>v;
        vector<int>v1;
        r(i,n){
            int x,y;
            cin>>x>>y;
            x--;y--;
            if(y==0)v1.push_back(x);
            else v.push_back(P(y,x));
        }
        v.push_back(P(1e18+1,0));
        int y=0;
        sort(v.begin(),v.end());
        mat A(w,vector<int>(w,0));
        A[0][0]=1;
        r(i,v1.size())A[v1[i]][v1[i]]=0;
        for(int i=0;i<v.size();i++){
            int s=v[i].first;
            int c=s-y;
            vector<int>vs,kara;
            vs.push_back(v[i].second);
            while(v[i].first==v[i+1].first){
                vs.push_back(v[i+1].second);
                i++;
            }
            mat B=make_mat(vs);
            mat C=make_mat(kara);
            if(s==1e18+1){
                c=(h-1)-y;
                if(c){
                   mat_pow(C,c);
                    mat_mul(A,C);
                }
                break;
            }
            if(c>1){
               mat_pow(C,c-1);
                mat_mul(A,C);
            }
            mat_mul(A,B);
            y=s;
        }
        int ans=0;
        r(i,w)ans=(ans+A[i][w-1])%1000000009;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3312
#include<bits/stdc++.h>
#define ll 	long long
#define pb push_back
using namespace std;
#define pi acos(-1.0)

int main()
{

	int n;
	cin >> n;
	
	vector<int> ans(n+9);
	
	for(int x=1;x<=100;x++)
	
		for (int y = 1; y <= 100; y++)
		
			for (int z = 1; z <= 100; z++) {
				int s = x * x + y * y + z * z + x * y + y * z + z * x;
				if (s > n)
					break;
				ans[s]++;
			}
			
	for (int i = 1; i <= n; i++)
		cout << ans[i] << endl;
    
    return 0;
}

Measured memory_bytes: 3548
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val s = sc.nextLine

  def judge(s: String) = {
    val n = s.length
    val splitPos = n / 2

    val a = s.substring(0, splitPos)
    val b = s.substring(splitPos + (if (n % 2 == 0) 0 else 1)).reverse

    a == b
  }

  val n = s.length
  println(
    if (judge(s) && judge(s.substring(0, (n - 1) / 2)) && judge(s.substring((n + 3) / 2 - 1))) "Yes"
    else "No"
  )
}


Measured memory_bytes: 25664
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int n1,s;
int counter = 0;
int dfs(int num,int c,int sum){
    if(sum == s && c == n1 && num<=10){counter++; return 0;}
    if(sum > s || c > n1 || num >9){return 0;}
    dfs(num+1,c+1,sum+num);
    dfs(num+1,c,sum);
    return 0;
}
int main(){
    while(cin >> n1 >> s,n1+s){
        counter = 0;
        dfs(0,0,0);
        cout << counter <<endl;
    }
    
}

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

int main() {
    int k, x; cin >> k >> x;
    int l = max(x - k + 1, -1000000);
    int r = min(x + k - 1, 1000000);
    for (int i = l; i <= r; ++i) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

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

long long f(long long n, long long x){
  long long y = x / n;
  if(x < n){
    return 0;
  } else {
    return y * (n + y * n) / 2;
  }
}

int main(void){
  long long n;
  cin >> n;
  cout << f(1,n) - f(3,n) - f(5,n) + f(15,n) << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
  int N;
  cin >> N;
  
  long long ans = 1;
  long long a;
  int flag = 0;
  
  for(int i = 0; i < N; ++i){
    cin >> a;
    ans *= a;
    if(a == 0){
      flag = 1;
    }
  }
  if(ans > 1000000000000000000){
    ans = -1;
  }
  if(ans == 0){
    ans = -1;
  }
  if(flag == 1){
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
#define per(i, a, b) for (int i = a; i >= b; -- i)
using namespace std;
int n, A, B, a[100010];
int main() {
	scanf("%d%d%d", &n, &A, &B);
	rep(i, 1, n) scanf("%d", &a[i]);
	ll ans = 0;
	rep(i, 2, n) 
		ans += min((ll) (a[i] - a[i - 1]) * A, (ll) B);
	printf("%lld\n", ans);
	return 0;
}

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

int main(void)
{	
	int i=0, j=0, k, m, cnt=0, zure=0, x=0;
	char str[100], str1[81][81], word[80];
	
	for( ; ; ){
	 //while(feof( stdin )!=NULL){
		cnt=0; zure=0; x=0; i=0; j=0; k=0; m=0;	
	
		//scanf(" %s", &str);
		if(fgets(str, sizeof(str), stdin)==NULL) break;
		while(i < strlen(str)){
			if(str[i]=='\0') break;
			j=0;
			while(str[i]!=' '){
				str1[cnt][j] = str[i];
				j++;
				i++;
				if(str[i]==' ') break;
			}
			str1[cnt][j] = '\0';
			cnt++;
			i++;
			//printf("i->%d\n", i);
			//printf("%s\n", str1[cnt-1]);
		}


	while(zure < 25){	
		for(k=0; k<cnt; k++){
			//printf("%s ", str1[k]);
			x=0;
			for(m=0; m<strlen(str1[k]); m++){
				if(isalpha(str1[k][m])){
					if((int)str1[k][m]-zure < 97 ){
						//word[x] = (char)(96 + ((int)str1[k][m]+zure-122 ));
						word[x] = (char)(123 - (97 - ((int)str1[k][m]-zure) ));
						x++;
					}else{
						word[x] = (char)((int)str1[k][m]-zure );
						x++;
					}
				}
			}
			word[x] = '\0';
			//printf("%s\n", word);
			if(!(strcmp(word, "this")) || !(strcmp(word, "that")) || !(strcmp(word, "the") )) goto label;
		}	
		zure++;
	}
	label:
		for(i=0; i<cnt; i++){
			for(m=0; m<strlen(str1[i]); m++){
				if(str1[i][m]=='.') { printf("."); continue; }
				if(str1[i][m]=='\n') { continue; }
				if(((int)str1[i][m]-zure) < 97 ){
					//printf("%c", (((int)str1[i]+zure-1) - 122 ) + 96  );
					printf("%c", (char)(123 - (97 - ((int)str1[i][m]-zure) )) );
				}else{
					//printf("%c", (int)str1[i]+zure-1);
					printf("%c",(char)((int)str1[i][m]-zure ) );
				}
			}
			if(i<cnt-1)printf(" ");
		}	
		printf("\n");
	}
	

	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;
struct state{
    LL s,a;
    state(LL s,LL a): s(s),a(a){};

};
struct comp{
    bool operator() (state &a ,state &b){
        return a.s <b.s;
    }
};

struct Problem{
    LL n,q,a,b;
    vector<LL> x;
    vector<state> v;
    Problem(LL n, LL q):n(n),q(q),x(q){};

    void solve(){
        cin >> a >> b;
        for(int i=0; i<q; ++i){
            cin >> x[i];
        }
        v.emplace_back(abs(x[0]-a),b);
        v.emplace_back(abs(x[0]-b),a);
        if(q==1){
            cout << min(abs(a-x[0]),abs(b-x[0])) <<"\n";;
            return;
        }
        for(int i=1; i<q; ++i){
            vector<state> tmp;
            for(auto &j: v){
                tmp.emplace_back(j.s+abs(x[i]-x[i-1]),j.a);
                tmp.emplace_back(j.s+abs(x[i]-j.a),x[i-1]);
            }
            v.clear();
            sort(tmp.begin(),tmp.end(),comp());
            unordered_map<LL,LL> um;
            for(auto &j: tmp){
                if(abs(j.a-tmp[0].a)>=j.s-tmp[0].s and(um.find(j.a)==um.end() or um[j.a]>j.s)){
                    v.push_back(j);
                    um[j.a]=j.s;
                }
            }
            DBG(i,tmp[0].s,tmp.size())
            if(i==q-1)cout << tmp[0].s <<"\n";
        }
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0,q;
    cin >> n >> q;
    Problem p(n,q);
    p.solve();
    return 0;
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 99999999999999
#define MAX_V 100010
#define MAX_E 2019

    /*Solve*/

int main(){
    ll a[3]={},b[3]={};
    int cnt[10]={};
    rep(i,3){
        ll x,y;
        cin >> x >> y;
        a[i]=x;
        b[i]=y;
        cnt[a[i]-1]++;
        cnt[b[i]-1]++;
    }
    sort(cnt,cnt+4,greater<>());
    if(cnt[0]==3)cout << "NO" <<endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef list<int> li;

#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define FAST     ios_base::sync_with_stdio(false); cin.tie(NULL)


const int INF=INT_MAX;
const ld PI=acos(-1);//3.1415926535897932384626433
const ld E=2.71828183;
const int MOD=1e9+7;

struct segment_tree{

    vector<ull>tree;
    int size;
    ll DEF;
    void init(int n){
        size=1;
        DEF=INF;
        while(size<n)size*=2;
        tree=vector<ull>(2*size,0);
    }

    ull merge(ull a,ull b){return a|b;}
    bool search(ull x,int l,int r){
        int m=(l+r)/2;
        if(size<=l || size<=r || l>r) return false;
        if(tree[m]==x)
            return true;
        else if(tree[m]>x)
            return search(x,l,m);
        else
            return search(x,m,r);
    }
    bool search(ull x){
        return search(x,0,size);
    }
    void set(int i,int x,ull v,int lx, int rx){
        if(rx-lx==1){
            tree[x]=v;
            return;
        }
        int m=(rx+lx)/2;
        if(i<m){
            set(i,2*x+1,v,lx,m);
        }
        else{
            set(i,2*x+2,v,m,rx);
        }
        tree[x]=merge(tree[2*x+1],tree[2*x+2]);
    }
    void set(int i,ull v){
        set(i,0,v,0,size);
    }
    ull sum(int l,int r,int x,int lx,int rx){
        if(r<=lx || rx<=l) return 0;//change
        else if(l<=lx && rx<=r)return tree[x];
        int m=(lx+rx)/2;
        return merge(sum(l,r,2*x+1,lx,m),sum(l,r,2*x+2,m,rx));
    }
    ull sum(int l,int r){
        return sum(l,r,0,0,size);
    }
    void print(){
        for(int i=0; i<tree.size(); i++)
            cout << to_string(tree[i]) << " ";
        cout << "\n";
    }
};


ll gcd(ll a,ll b){ return (a%b==0? b: gcd(b,a%b)) ;}
ld log (ld a,ld b){return log(b)/log(a);}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

ll power(ll base, ll exp,ll M=LLONG_MAX){//(base^exp)%M
    ll res=1;
    while(exp){
        if(exp%2==1)res=((res%M)*(base%M))%M;
        base=((base%M)*(base%M))%M;
        exp/=2;
    }
    return res;
}


void solve();
int main(){
    FAST;
    int t=1;
    //   cin >> t;
    while(t--)
        solve();
    return 0;
}
list<char>ans;
vector<bool>vis;
bool ok;
void dfs(int src,vector<vector<char>>adj){
    vis[src]=true;
    for(char nbr:adj[src-'a']){
        if(!vis[nbr])
            dfs(nbr,adj);
        else
            ok=false;
    }
    ans.push_back(src);
}
void solve(){
    int n;
    cin >> n;
    for(int i=3; i<=10; i++){
        if(n<=200*i -1) out(11-i)
    }
}

Measured memory_bytes: 3616
using System;
using System.IO;
namespace aoj{
    class program{
     
    static void Main() {
		
		BinarySearch bs = new BinarySearch(
			int.Parse(Console.ReadLine()), Console.ReadLine());
		bs.getKey(int.Parse(Console.ReadLine()), Console.ReadLine());
		bs.bs();
		bs.show();
	    
    }
}
class BinarySearch{
	int[] list;
	int[] keyList;
	int count=0;
	public BinarySearch(int length,string rl){
		list = new int[length];
		string[] tmp = rl.Split(' ');
		for(int i=0; i<length; i++)
			list[i] = int.Parse(tmp[i]);
	}
	public void getKey(int length,string rl){
		keyList = new int[length];
		string[] tmp = rl.Split(' ');
		for(int i=0; i<length; i++)
			keyList[i] = int.Parse(tmp[i]);
	}
	public void bs(){
		foreach( int k in keyList)
			count += search(k);
	}
	int search(int key){
		int left = 0;
		int right = list.Length;
		while(left<right){
			int mid = (left+right)/2;
			if(key==list[mid])
				return 1;
			else if(key<list[mid])
				right=mid;
			else
				left=mid+1;
		}
		return 0;
	}
	public void show(){
		Console.WriteLine("{0}",count);
	}
}
		
}

Measured memory_bytes: 17904
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);


#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;

double dp[3030][3030];
int main(){
    ll n;
    cin >>n;
    double p;
    dp[0][0]=1;
    for (int j = 0; j <n ; ++j) {
        cin >> p;
        for (int i = 0; i <j+1 ; ++i) {
            dp[j+1][i] += dp[j][i]*(1-p);
            dp[j+1][i+1] += dp[j][i]*p;
        }
    }
    double res =0;
    for (int i = 0; i <n+1 ; ++i) {
        if(i > n-i)res+=dp[n][i];
    }
    printf("%.12lf",res);
    return 0;
}




    /*

    int gcd(int a, int b) {
        while (a > 0 && b > 0)
            if (a > b) a %= b;
            else b %= a;
        return a + b;
    }

    int lcm(int a, int b) {
        return a*b / gcd(a,b);
    }
    long long fast_exp(long long n,long long k){
        if(k == 0)
            return 1;
        if(k==1)
            return n;

        long long temp = fast_exp(n,k>>1);
        if((k&1)==1)
            return (n*temp*temp);
        return (temp*temp);

    }

     */

Measured memory_bytes: 70272
N = int(input())
S = []
for i in range(N):
    S.append(input())
MAX = 0

import collections
c =  collections.Counter(S)
MAX = max(c.values())
SET = []
for i in range(N):
    if c[S[i]]==MAX:
        SET.append(S[i])
SET = list(set(SET))
SET.sort()
for item in SET:
    print(item)

Measured memory_bytes: 118304
from collections import deque


def solve(n, ab_list):
    g = [[] for _ in range(n + 1)]
    for a, b in ab_list:
        g[a].append(b)
        g[b].append(a)
    # start from 1
    d_list = [-1] * (n + 1)
    d_list[1] = 0
    queue = deque([1])
    while len(queue) > 0:
        p = queue.popleft()
        for q in g[p]:
            if d_list[q] == -1:
                d_list[q] = d_list[p] + 1
                queue.append(q)
    # print(d_list)
    cnt_2 = [0] * 6
    for i in range(1, n + 1):
        cnt_2[d_list[i] % 2] += 1

    if cnt_2[0] <= cnt_2[1]:
        min_01 = 0
    else:
        min_01 = 1

    min_sum = cnt_2[min_01]
    if min_sum <= n // 3:
        res_list = [0] * n
        list_3 = [3 * (k + 1) for k in range(min_sum)]
        list_other = [k for k in range(1, n + 1) if k % 3 != 0] + [3 * (k + 1) for k in range(min_sum, n // 3)]
        for i in range(1, n + 1):
            if d_list[i] % 2 == min_01:
                res_list[i - 1] = list_3.pop()
            else:
                res_list[i - 1] = list_other.pop()
    else:
        res_list = [0] * n
        add_1 = min_sum - (n + 2) // 3
        list_1 = [k + 1 for k in range(n) if k % 3 == 0] + [3 * (k + 1) for k in range(add_1)]
        list_2 = [k + 1 for k in range(n) if k % 3 == 1] + [3 * (k + 1) for k in range(add_1, n // 3)]
        for i in range(1, n + 1):
            if d_list[i] % 2 == min_01:
                res_list[i - 1] = list_1.pop()
            else:
                res_list[i - 1] = list_2.pop()

    return " ".join([str(r) for r in res_list])


def main():
    n = int(input())
    ab_list = [list(map(int, input().split())) for _ in range(n - 1)]
    res = solve(n, ab_list)
    print(res)


def test():
    # print(solve(5, [[1, 2], [1, 3], [3, 4], [3, 5]]))
    assert solve(5, [[1, 2], [1, 3], [3, 4], [3, 5]]) == "3 4 1 5 2"


if __name__ == "__main__":
    # test()
    main()


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

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

    int a, b;
    cin >> a >> b;
    int d = b - a;
    int t = d * (d + 1) / 2;
    cout << t - b << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
# 4 * h * n * w == N * (h * n + n * w + w * h)
for i in range(3501):
    for j in range(3501):
        num = N * i * j
        den = 4 * i * j - N * (i + j)
        if den <= 0:
            continue
        if num % den == 0:
            print(i, j, num // den)
            exit()


Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mx = 1e18;
int main() {
	int n;
	cin >> n;
	vector<ll>v(n);
	ll mul = 1;
	for (auto& x : v) {
		cin >> x;
	}
	int cnt = count(v.begin(), v.end(), 0);
	if (cnt) {
		cout << 0 << endl;
		return 0;
	}
	for (auto& c : v) {


		ll temp = (mx / mul);
		if (c > temp) {
			cout << -1 << endl;
			return 0;
		}
		mul *= c;

	}
	cout << mul << endl;
	return 0;
}

Measured memory_bytes: 4052
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	char s[32];
	int len;

	scanf("%s", s);
	len = strlen(s);

	vector<bool> used(26);

	for(int i = 0; i < len; ++i)
		used[s[i] - 'a'] = true;

	for(int i = 0; i < 26; ++i) {
		if(!used[i]) {
			printf("%s%c\n", s, 'a' + i);
			return 0;
		}
	}

	char t[32];

	for(int i = 0; i < len + 1; ++i)
		t[i] = s[i];

	if(next_permutation(t + 0, t + len)) {

		int it = 0;

		while(it < len && t[it] == s[it])
			it += 1;
		t[it + 1] = '\0';
		printf("%s\n", t);

	} else {
		printf("-1\n");
	}

	return 0;
}

/* waffle */


Measured memory_bytes: 256