akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std ;

#define N 5000010
#define inf 0x3f3f3f3f

int head[ N ] , cnt ;
int d[ N ] , vis[ N ] , q[ N ] ;
int n , m ;
struct node {
	int to , nxt , v ;
}e[ N ] ; 

void ins( int u , int v , int w ) {
	e[ ++ cnt ].to = v ;
	e[ cnt ].nxt = head[ u ] ;
	e[ cnt ].v = w ;
	head[ u ] = cnt ;
} 

map<pair<int,int>,int>mp;

int tot = 0 ;

int get_num( int x , int y ) {
	if( !mp.count( make_pair( x , y ) ) ) mp[ make_pair( x , y ) ] = ++tot ;
	return mp[ make_pair( x , y ) ] ;
}

void spfa() {
	for( int i = 1 ; i <= tot ; i ++ ) d[ i ] = inf ;
	vis[ 1 ] = q[ 1 ] = 1 ;
	d[ 1 ] = 0 ;
	int l = 1 , r = 2 ;
	while( l < r ) {
		int u = q[ l ++ ] ;
		vis[ u ] = 0 ;
		for( int i = head[ u ] ; i ; i = e[ i ].nxt ) {
			int v = e[ i ].to ;
			if( d[ v ] > d[ u ] + e[ i ].v ) {
				d[ v ] = d[ u ] + e[ i ].v ;
				if( !vis[ v ] ) vis[ v ] = 1 , q[ r ++ ] = v ;
			}
		}
	}
	if( d[ n ] == inf ) puts( "-1" ) ;
	else printf( "%d\n" , d[ n ] / 2 ) ;
}

int main() {
	scanf( "%d%d" , &n , &m ) ;
	tot = n ;
	for( int i = 1 ; i <= m ; i ++ ) {
		int x , y , c ;
		scanf( "%d%d%d" , &x , &y , &c ) ;
		int n1 = get_num( x , c ) , n2 = get_num( y , c ) ;
		ins( x , n1 , 1 ) ;
		ins( n1 , x , 1 ) ;
		ins( n1 , y , 1 ) ;
		ins( y , n1 , 1 ) ;
		ins( n1 , n2 , 0 ) ;
		ins( n2 , n1 , 0 ) ;
	}
	spfa() ;
}

Measured memory_bytes: 55936
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define in insert
#define mp make_pair
using namespace std;
const int N = 1e5+123;
int a[N];
int n,m,k;
string s;
set<int>setik;


bool ok(int x)
{
	if(x % 2 == 0)return 0;
	int c = 0;
	for(int i = 1; i <= x; i++)
	{
		if(x % i == 0)
			c++;
	}
	return c == 8;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int ans = 0;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		int t = i;
		if(ok(t))ans++;
	}
	cout << ans;

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 998244353; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;

bool is_prime(int x) {
	for (int i = 2; i*i <= x; i++) {
		if (x%i == 0)return false;
	}
	return true;
}
void solve() {
	int X; cin >> X;
	for (int i = X; i <= 1e9; i++) {
		if (is_prime(i)) {
			print(i); return;
		}
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 256
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mss map <string,string>
#define msl map <string,ll>
#define mll map <ll,ll>
#define mcl map <char,ll>
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}

int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);
  
  string s;
  cin>>s;
  mcl m;
  for(int i=0;i<sz(s);i++) {
    m[s[i]]++;
  }
  cout<<2*min(m['0'],m['1']);
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define LL long long
using namespace std;
const int N=1e5+10;
int n;
LL e,t,x[N],dp[N],tt=1e18;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
template<typename I>inline I mi(const I&a,const I&b){return a<b ? a : b;}
int main()
{
//	freopen("Shik and Game.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n,e,t);
	for(int i=1;i<=n;i++) read(x[i]), dp[i]=2e9;
	for(int i=1,j=0;i<=n;i++)
	{
		while(2*(x[i]-x[j+1])>=t) 
		{
			tt=mi(tt,dp[j]-2*x[j+1]);
			j++;
		}
		dp[i]=mi(dp[j]+t,tt+2*x[i]);
	}
	printf("%lld\n",dp[n]+e);
	//fclose(stdin); fclose(stdout);
	return 0;
}

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

int main() {
  ll h, w;
  cin >> h >> w;
  ll ans;
  if (h == 1 || w == 1) ans = 1;
  else if (h * w % 2 == 0) ans = h * w / 2;
  else ans = (h * w + 1) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,M,V,P; cin>>N>>M>>V>>P;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    sort(ALL(A),greater<ll>());
    vector<ll> sum(N+1,0);
    sum[0]=0;
    rep(i,N) sum[i+1]=sum[i]+A[i];
    ll ans=P;
    reps(i,P,N){
        if(A[P-1]>A[i]+M) break;
        ll summ=sum[i+1]-sum[P-1];
        //cout<< "summ "<< summ <<"\n";
        summ-=A[i]*(i-P+2);
        /*
        cout<< "i "<< i <<"\n";
        cout<< "summ "<< summ <<"\n";
        cout<< "(N-V)*M "<< (N-V)*M <<"\n";
        */
        if(summ>(N-V)*M) break;
        ++ans;
    }
    cout<< ans <<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1920
import collections # deque, Counter
# import itertools   # accumulate, compress, permutations(nPr), combinations(nCr)
# import bisect      # bisect_left(insert位置), bisect_right(slice用)
# import math        # factorical（階乗) # hypot(距離)
# import heapq
# from fractions import gcd # >=Python3.5 # lcm（最小公倍数） = (a*b)//gcd(a,b)
# from fractions import Fraction
# from math import gcd # <Python3.5
# --------------------------------------------------------------

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n,m = map(int,input().split())
lis = [list(map(int,input().split())) for _ in range(m)]

road = [[] for i in range(n)] # 頂点vと隣接する頂点のリスト
 
for i in lis:
    i[0]-=1
    i[1]-=1
    road[i[0]].append(i[1])
    road[i[1]].append(i[0])

cmax  = 0
 
uf = UnionFind(n)

for i in lis:
    uf.union(i[0],i[1])

for i in range(n):
    cmax = max(cmax, uf.size(i))

print(cmax)

Measured memory_bytes: 68012
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! p {
    ($($x:expr),*) => {
        $(println!("{:?}", $x);)*
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
#[allow(unused_imports)]
use std::cmp::*;
trait Each: Iterator{
    fn each<F>(self, mut f: F) where
        Self: Sized, F: FnMut(Self::Item),
    {
        self.fold((), move |(), item| f(item));
    }
}
impl<T:Iterator>Each for T{}

fn main(){
    input!{
        n:usize,
        mut v:[i32;n]
    }
    v.sort();
    let mut v = v.into_iter().map(|x|x as f64).collect::<Vec<f64>>();
    
    for i in 1..n{
        v[i] = (v[i] + v[i-1])/2.0;
    }
    p!(v[n-1]);
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N;
    cin >> N;
    vector<pair<ll,ll>> robot(N);
    bool isE[N];
    for(ll i = 0; i < N; i++){
        ll X,L;
        cin >> X >> L;
        robot[i] = make_pair(X + L,L);
        isE[i] = true;
    }
    sort(robot.begin(),robot.end());
    ll currentR = -(2ll << 50);
    ll count = 0;
    for(int i = 0; i < N; i++){
        if(currentR <= robot[i].first - 2 * robot[i].second){
            count++;
            currentR = robot[i].first;
        }
    }
    cout << count << endl;

}

Measured memory_bytes: 1920
N,M=map(int,input().split())#整数を複数の変数に格納
A=list(map(int,input().split()))#リストに整数を格納

A.sort(reverse=True)
S = sum(A)
if A[M-1] >= S/(4*M):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38256
n = int(input())
a = list(map(int, input().split()))
a = sorted([a[i] - (i + 1) for i in range(n)])

def sadness(index):
	return sum([abs(a[i] - a[index]) for i in range(n)])

if n % 2 == 1:
	print(sadness((n - 1) // 2))

else:
	print(min(sadness(n // 2), sadness(n // 2 - 1)))

Measured memory_bytes: 26708
#include<bits/stdc++.h>
using namespace std;
//<<setprecision(30)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  int N,M,X,Y; cin>>N>>M>>X>>Y;
  vector<int> x(N),y(M);
  rep(i,N)cin>>x.at(i);
  rep(i,M)cin>>y.at(i);
  sort(begin(x),end(x));
  sort(begin(y),end(y));
  int xm = x.at(N-1), ym = y.at(0);
  if(xm<=ym){
    if(min(ym,Y)-max(xm,X)>0){
      cout<<"No War"<<endl;
      return 0;
    }
  }
  cout<<"War"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] x = new int[n][2];
        int mod = 0;
        for(int i=0; i<n; i++){
            x[i][0] = sc.nextInt();
            x[i][1] = sc.nextInt();
            if(i == 0){
                mod = Math.abs(x[i][0] + x[i][1]) % 2;
            }else{
                if(Math.abs(x[i][0] + x[i][1]) % 2 != mod){
                    System.out.println(-1);
                    return;
                }
            }
        }
        sc.close();

        long[] pow3 = new long[25];
        pow3[0] = 1;
        for(int i=1; i<25; i++){
            pow3[i] = pow3[i-1] * 3;
        }

        int m;
        long[] arm;
        if(mod == 1){
            m = 40;
            arm = new long[m];
            for(int i=0; i<19; i++){
                arm[i*2] = pow3[19 - i];
                arm[i*2+1] = pow3[18-i]*2;
            }
            arm[38] = 1;
            arm[39] = 1;
        }else{
            m = 39;
            arm = new long[m];
            for(int i=0; i<19; i++){
                arm[i*2] = pow3[19-i];
                arm[i*2+1] = pow3[18-i]*2;
            }
            arm[38] = 1;
        }

        // Arrays.fill(arm, 1);

        System.out.println(m);
        for(int i=0; i<m-1; i++){
            System.out.print(arm[i] + " ");
        }
        System.out.println(arm[m-1]);
        
        for(int i=0; i<n; i++){
            long cx = 0, cy = 0;
            long tx = x[i][0], ty = x[i][1];
            String ans = "";
            for(int j=0; j<m; j++){
                if(Math.abs(tx-cx) > Math.abs(ty-cy)){
                    if(tx > cx){
                        ans += "R";
                        cx += arm[j];       
                    }else{
                        ans += "L";
                        cx -= arm[j];
                    }
                }else{
                    if(ty > cy){
                        ans += "U";
                        cy += arm[j];
                    }else{
                        ans += "D";
                        cy -= arm[j];
                    }
                }
            }
            System.out.println(ans);
            // System.out.println(ans + " " + cx + " " + cy);
        }
    }
}

Measured memory_bytes: 36480
a,b,c = input()
count = 0

if a == "R" and b == "R" and c == "R":
  count = 3
elif (a == "R" and b == "R") or(b == "R" and c == "R"):
  count = 2
elif a == "R"or b =="R" or c == "R":
  count = 1
else:
  count = 0
  
print(count)

Measured memory_bytes: 9044
N = int(input())
S = [input() for _ in range(N)]

mydict = {'M':1,'A':2,'R':3,'C':4,'H':5}
count = [0] * 6
for i in range(N):
    s = S[i][0]
    if s in mydict:
        count[mydict[s]] += 1
ans = 0
for i in range(1,6):
    for j in range(i+1,6):
        if i==j:continue
        for k in range(j+1,6):
            if i==k or j == k:continue
            ans += count[i] * count[j] * count[k]
            
            
print(ans)
            
            

Measured memory_bytes: 10132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,X,T;
  cin >> N >> X >> T;

  long long count1,count2;

  count1 = N / X;
  count2 = N % X;
  
  if (count2 != 0){
     cout << count1 * T + T <<endl;    
  }else{
      cout << count1 * T <<endl;
  } 
 
  
      
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
#include <functional>
#include <string.h>
#include <numeric>
#include <math.h>

#define LOOP(N) for(int i=0; i<(N); ++i)
#define REP(i, N) for(int i=0; i<(N); ++i)
#define FOR(i, start, end) for(int i=(start); i<(end); ++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using Graph = vector< vector<int> >;

const uint ALPHABET_NUM = 'z' - 'a' + 1;


int main() {
    string s, t; cin >> s >> t;
    vector< vector<int> > alphabet_pos(ALPHABET_NUM);
    REP(i, (int)s.length()) {
        alphabet_pos[s[i]-'a'].push_back(i);
    }
    
    // impossible
    REP(i, (int)t.length()) {
        if (alphabet_pos[t[i]-'a'].empty()) {
            cout << -1 << endl;
            return 0;
        }
    }

    ull result = 0;
    ull now = 0, next;
    auto next_pos = alphabet_pos[0].begin();
    REP(i, (int)t.length()) {
        auto index_p = &alphabet_pos[t[i]-'a'];
        if (i>0 && t[i-1] == t[i]) {
            next_pos = lower_bound(next_pos+1, index_p->end(), now);
        }
        else {
            next_pos = lower_bound(ALL(*index_p), now);
        }
        if (next_pos == index_p->end()) {
            next = (*index_p)[0];
            next_pos = index_p->begin();
            result += (ull)s.length() + next - now;
            // cout << "non " << now << " " << next << endl;
        }
        else {
            next = *next_pos;
            result += next - now;
            // cout << "find " << now << " " << next << endl;
        }
        now = next;
        // cout << result << endl;
    }
    cout << result+1;
}


Measured memory_bytes: 1216
#include <cstdio>
#include <iostream>

const long N=3000000;

int main(){
	//素数テーブル作成
	bool prime[N+1];
	for(long i=0; i<=N; ++i) prime[i]=true;
	prime[1]=false;
	prime[2]=true;
	
	for(long i=2; i<=N; ++i){
		if(prime[i]){
			for(long j=2; i*j<=N; ++j) prime[i*j]=false;	
		}
	}
	
	while(1){
		long a, d;
		int n;
		
		scanf(" %ld %ld %d", &a, &d, &n);
		if(a==0 && d==0) break;
		int count=0;
		long x=0;
		
		long num;
		while(count<n){
			num=a+d*x;
			if(prime[num]) ++count;	
			++x;
		}
		printf("%ld\n", num);
	}
	return 0;
}

Measured memory_bytes: 4116
#include<stdio.h>
#include<string.h>
int main(void){
    int i,s,count=0;
    char W[100]={},T[1000]={},E[13]={"END_OF_TEXT"};
    scanf("%s",W);
           s=strlen(W);
    for(i=0;i<=s;i++){
        if(65<=W[i] && W[i]<=90){
        W[i]=W[i]+32;
        printf("%c\n",W[i]);
        }
    }
    while(scanf("%s",T)==1){
        if(strcmp(T,E)==0) break;
          s=strlen(T);
    for(i=0;i<=s;i++){
        if(65<=T[i] && T[i]<=90)
        T[i]+=32;
    }
        if(strcmp(W,T)==0){
                count++;
            }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2052
import std.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;

void main() {
    int n;
    int a, b, c, d;
    readf("%d\n", &n);
    readf("%d %d\n", &a, &b); a--; b--;
    readf("%d %d\n", &c, &d); c--; d--;
    int ans = int.max;
    for (int w = 1; w <= n; w++) {
        int ax = a % w, ay = a / w;
        int bx = b % w, by = b / w;
        int cx = c % w, cy = c / w;
        int dx = d % w, dy = d / w;
        ans = min(ans, abs(ax - bx) + abs(ay - by) + abs(cx - dx) + abs(cy - dy));
    }
    ans.writeln;
}

Measured memory_bytes: 1060
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i++)

#include<stdio.h>
#include<iostream>
#include<vector>
#include<sstream>
#include<algorithm>
#include<limits.h>
#include<stack>
#include<queue>
#include<set>
//#pragma comment(linker, "/STACK:12822822 ")

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
const ll power = 17;
const ll inf = 9223372036854775807LL;

ll s[1000][1000];
ll n;
bool used[1000];
ll t = 1;

void dfs(ll v, ll co)
{
	used[v] = true;
	forn(i, 0, co)
	{
		if (v == i)
			continue;
		if (s[v][i] == 0)
		{
			s[v][i] = t;
			s[i][v] = t;
			t++;
		}
		if (used[i])
			continue;
		dfs(i, co);
	}
}

void adskaya_drochilna(ll co)
{
	forn(i, 0, co)
	{
		cout << co - 1 << ' ';
		forn(j, 0, co)
		{
			if (i == j)
				continue;
			cout << s[i][j] << ' ';
		}
		cout << endl;
	}
}

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

	/*
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	*/


	cin >> n;
	forn(i, 0, n+5)
	{
		if (i * (i - 1) == 2 * n)
		{
			dfs(0, i);
			if (t > n + 1)
				break;
			cout << "Yes" << endl;
			cout << i << endl;
			adskaya_drochilna(i);
			return 0;
		}
	}
	cout << "No";

	return 0;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int n,u,v;
    cin>>n>>u>>v;
    u--;
    v--;
    VVI e(n);
    REP(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        e[a].PB(b);
        e[b].PB(a);
    }

    queue<PII> q;

    VI d_u(n,INF);
    d_u[u] = 0;
    for(auto x : e[u]){
        q.push(MP(x,1));
    }

    while(!q.empty()){
        PII x = q.front();
        q.pop();
        int now = x.first;
        int dist = x.second;

        if(d_u[now] != INF){
            continue;
        }
        d_u[now] = dist;

        for(auto next : e[now]){
            if(d_u[next] == INF){
                q.push(MP(next,dist+1));
            }
        }
    }

    VI d_v(n,INF);
    d_v[v] = 0;
    for(auto x : e[v]){
        q.push(MP(x,1));
    }

    while(!q.empty()){
        PII x = q.front();
        q.pop();
        int now = x.first;
        int dist = x.second;

        if(d_v[now] != INF){
            continue;
        }
        d_v[now] = dist;

        for(auto next : e[now]){
            if(d_v[next] == INF){
                q.push(MP(next,dist+1));
            }
        }
    }

    int far_dist = 0;
    int far_point = 0;
    //int sa = d_v[u];
    REP(i,n){
        //dump(i)
        //dump(d_u[i])
        //dump(d_v[i])

        if(d_u[i]>=d_v[i]){
            continue;
        }
        if(d_v[i]>far_dist){
            far_dist = d_v[i];
            far_point = i;
        }

    }

    //dump(far_dist)
    //dump(far_point)
    
    int sa = d_v[far_point] - d_u[far_point];

    int result = d_u[far_point] + sa-1;

    cout << result <<endl;




	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
#define MAX 2005
typedef long long ll;
struct edge{ll to,cost;};
vector<ll> ans;
vector<edge> G[MAX];
ll A[MAX];
int n,m;
ll a,b,c;

ll dfs(int pos,int prev,int root,ll cost){
  vector<ll> res;
  for(int i=0;i<(int)G[pos].size();i++){
    edge e=G[pos][i];
    if(e.to==prev)continue;
    res.push_back(dfs(e.to,pos,root,cost)+e.cost*A[root]);
  }
  sort(res.begin(),res.end());
  reverse(res.begin(),res.end());
  for(int i=1;i<(int)res.size();i++)ans.push_back(res[i]);
  return (res.empty()?0LL:res[0]);
}

int main(){
  cin>>n>>m;
  for(int i=0;i<n-1;i++){
    cin>>a>>b>>c;
    a--,b--;
    G[a].push_back((edge){b,c});
    G[b].push_back((edge){a,c});
  }
  for(int i=0;i<n;i++)cin>>A[i];
  for(int i=0;i<n;i++)ans.push_back(dfs(i,-1,i,0));
  sort(ans.begin(),ans.end());
  reverse(ans.begin(),ans.end());
  for(int i=1;i<(int)ans.size();i++)ans[i]+=ans[i-1];
  cout<< ans[ min(m-1,(int)ans.size()-1) ] <<endl;
  return 0;
}

Measured memory_bytes: 35956
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+20;
string s;
int main()
{
	while(cin>>s)
	{
		int res=0;
		char now=s[0];
		for(int i=1;s[i];i++)
		{
			if(now!=s[i])
			{
				now=s[i];
				res++;
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int a, b;
bool ng[16][16];

int search(int x, int y) {
	int res1, res2;
	if (x == a && y == b) return 1;
	if (x + 1 <= a && !ng[y][x + 1]) res1 = search(x + 1, y);
	else res1 = 0;
	if (y + 1 <= b && !ng[y + 1][x]) res2 = search(x, y + 1);
	else res2 = 0;
	return res1 + res2;
}

int main() {
	int n;

	while (cin >> a, a) {
		fill(ng[0], ng[16], false);
		cin >> b >> n;
		--a; --b;
		int xi, yi;
		while (n--) {
			cin >> xi >> yi;
			ng[yi - 1][xi - 1] = true;
		}
		cout << search(0, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
r,c = gets.split(" ").map do |i| i.to_i end
spreadsheet = Array.new(r+1)
(0..r).each do |r|
    input = gets.to_s
    spreadsheet[r] = input.split(" ").map do |i| i.to_i end
    spreadsheet[r].push(spreadsheet[r].inject(:+))
end

spreadsheet[-1] = Array.new(c+1)
spreadsheet[-1].fill(0)

(0..c).each do |c|
    (0..r-1).each do |r|
        spreadsheet[-1][c] += spreadsheet[r][c]
    end
end

(0..r).each do |r|
    puts "#{spreadsheet[r].join(" ")}"
end

Measured memory_bytes: 9032
#include<stdio.h>

int main(void){

    int D,T,S;

    scanf("%d%d%d",&D,&T,&S);
    if(D%S==0){
    if(D/S<=T)printf("Yes");
    else printf("No");
    }
    else{
    if(D/S<T)printf("Yes");
    else printf("No");
    }
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

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

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//INSERT ABOVE HERE
signed main(){
  Int h,w;
  cin>>h>>w;
  auto a=make_v<Int>(h,w);
  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      cin>>a[i][j];

  using T = tuple<Int, Int, Int, Int>;
  vector<T> ans;
  for(Int i=0;i<h;i++){
    if(i&1){
      for(Int j=w-1;j;j--){
	if(a[i][j]&1){
	  ans.emplace_back(i,j,i,j-1);
	  a[i][j]--;
	  a[i][j-1]++;
	}
      }
      if(i+1<h){
	Int j=0;
	if(a[i][j]&1){
	  ans.emplace_back(i,j,i+1,j);
	  a[i][j]--;
	  a[i+1][j]++;	  
	}
      }
    }else{
      for(Int j=0;j+1<w;j++){
	if(a[i][j]&1){
	  ans.emplace_back(i,j,i,j+1);
	  a[i][j]--;
	  a[i][j+1]++;
	}
      }
      if(i+1<h){
	Int j=w-1;
	if(a[i][j]&1){
	  ans.emplace_back(i,j,i+1,j);
	  a[i][j]--;
	  a[i+1][j]++;	  
	}
      }
    }
  }
  
  cout<<ans.size()<<endl;
  for(auto t:ans){
    Int a,b,c,d;
    tie(a,b,c,d)=t;
    a++;b++;c++;d++;
    cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
  }

  if(0){
    int res=0;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	if(a[i][j]%2==0) res++;
    cout<<res<<endl;
  }
  return 0;
}


Measured memory_bytes: 8432
import java.io.*;
import java.util.*;

public class Main {
    public static long gcd(long B,long D){
        if(B<D)
            return gcd(D,B);
        if(B%D==0)
            return D;
        return gcd(D,B%D);
    }
    public static void main(String arg[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int T = Integer.parseInt(br.readLine());
        for(int i=1;i<=T;i++){
            StringTokenizer st = new StringTokenizer(br.readLine());
            long A = Long.parseLong(st.nextToken());
            long B = Long.parseLong(st.nextToken());
            long C = Long.parseLong(st.nextToken());
            long D = Long.parseLong(st.nextToken());
            
            if(B>A){
                System.out.println("No");
            }else if(B>D){
                System.out.println("No");
            }else if(B==D){
                if(C>=B){
                    System.out.println("Yes");
                }else{
                    long r = A%B;
                    if(r<=C){
                        System.out.println("Yes");
                    }else{
                        System.out.println("No");
                    }
                }
            }else{
                long g = gcd(B,D);
                long r = A % B;
                if (r > C) {
                    System.out.println("No");
                }else if(C<B-g){
                    System.out.println("No");
                }else if(D%C==0){
                    System.out.println("Yes");
                }else{
                    System.out.println("Yes");
                }
            }
        }
    }
}


Measured memory_bytes: 21460
#include <stdio.h>

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

  if(n < 105)
    printf("0");
  else if(n < 135)
    printf("1");
  else if(n < 165)
    printf("2");
  else if(n < 189)
    printf("3");
  else if(n < 195)
    printf("4");
  else
    printf("5");
  
  printf("\n");
  return(0);
}

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

int main() {
  int H, N;
  cin >> H >> N;
  
  vector<int> A(N);
  int sumA = 0;
  for (int i = 0; i < N; i++){
    cin >> A[i];
    sumA += A[i];
  }
  
  if (H > sumA){
    cout << "No" << endl;    
  } else {
    cout << "Yes" << endl;      
  }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


void solve() {
    ll i,j,k,l,r,x,y; string s;
    bool exit = false;
    ll N;
    vector<ll> a;
    cin >> N >> x;
    FOR(i,N){
        ll input;
        cin >> input;
        a.push_back(input);
    }
    sort(ALL(a));
    ll ret = 0;
    ll x_ = 0;
    FOR(i,N){
        x_ += a[i];
        //cout<<x_<<endl;
        if(N-1==i){
            if(x_==x){
                ret += 1;
            }else if(x_ > x){
            }else{
            }
            break;
        }else{
            if(x_==x){
                ret += 1;
                break;
            }else if(x_ > x){
                break;
            }else{
                ret+=1;
            }
        }
        
    }
    //if(ret<0) ret=0;
    cout<<ret<<endl;
    /*cin>>N;
    vector<ll> V;
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll x;
    cin >> x;
    ll a = x/500;
    ll b = x%500;
    ll c = b / 5;
    cout << a * 1000 + c * 5 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 100007
    
#define REP(i, N) for(int (i)=0; (i) < (N); (i)++)
#define PER(i, N) for(int (i)=(N)-1; (i) >= 0; (i)--)
    
using namespace std;
typedef long long ll;
typedef pair<ll, int> pii;

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

    int t = k/3;
    int f = k/5;
    int q = k/15;

    ll ans = k*(k+1LL)/2LL;
    ans -= ((3LL+(k-k%3))*t)/2LL;
    if(k >= 5){
        ans -= ((5LL+(k-k%5))*f)/2LL;
        if(k >= 15) ans += ((15LL+(k-k%15))*q)/2LL;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); ++i)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();++i) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();++i) vdeb(da[i]);
    std::cout << std::endl;
}

using namespace std;

const ll MOD = 1000000007;

ll modpow(ll a, ll b){
    if(b == 1) return a;
    if(b&1) return modpow(a, b-1) * a % MOD;
    ll tmp = modpow(a, b/2);
    return tmp*tmp%MOD;
}

int main(){
    ll n,k; cin >> n >> k;
    vector<ll> da(k+1);
    rip(i,k+1,1) da[i] = modpow(k/i, n);
    vector<bool> isPrime(k+1, true);
    rip(i,k+1, 2){
        if(isPrime[i]){
            int now = i;
            while(now <= k){
                isPrime[now] = false;
                da[now/i] -= da[now];
                now += i;
            }
        }
    }
    ll ans = 0;
    rip(i,k+1,1){
        ans += (da[i] * i)%MOD;
    }
    cout << (ans%MOD+MOD)%MOD << endl;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
const int MOD = 1e9+7;
int main() {
	int n;
	cin >> n;
	set<int> se;
	for(int i = 0; i < n;i++){
		int x;
		cin >> x;
		se.insert(x);
	}
	if(se.size() == n)
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <utility>
#include <set>

using llint = long long int;
using namespace std;

namespace CsF {
#define MIN_INT -2147483648
#define MAX_INT 2147483647

#define nfor(I,J,K) for(int I = 0;I < J;I+=K)


	string ConvertBit(int N, int e) {
		string s = "";
		int r = 0;
		while (N != 0) {
			r = N % e;
			s = to_string(r) + s;
			N -= r;
			N /= e;
		}
		return s;
	}

	int GCD(int a, int b) {
		if (a < b)swap(a, b);
		int r = a % b;
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		return b;
	}

	int LCM(int a, int b) {
		int n = a * b;
		return (n / GCD(a, b));
	}

	int Count(string s, char c) {
		int cou = 0;
		nfor(i, s.length(), 1) {
			if (s[i] == c)cou++;
		}
		return cou;
	}

	vector<int> SieveOfEratosthenes(int N) {
		vector<bool> memo(N + 1);
		vector<int> ret;
		memo[0] = true;
		memo[1] = true;
		for (int i = 2; i < N; i++) {
			if (memo[i])continue;
			ret.push_back(i);
			for (int b = 2; true; b++) {
				if (i*b <= N) {
					memo[i*b] = true;
				}
				else break;
			}
		}
		return ret;
	}
}

using namespace CsF;


int main() {
	int N;
	cin >> N;
	int count = 0;
	int ans = 0;
	for (int i = 1; i <= N; i += 2) {
		count = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0)count++;
		}
		if (count == 8) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

class unionFind {
public:
  vector<ll> data;
  
  unionFind(ll size) {
    data.assign(size, -1);
  }
  
  bool same(ll x, ll y) {
    return find(x)==find(y);
  }
  
  void unite(ll x, ll y) {
    x=find(x);
    y=find(y);
    if(x==y) return;
    if(data[x]>data[y]) swap(x, y);
    data[x]+=data[y];
    data[y]=x;
  }
  
  ll find(ll k) {
    if(data[k]<0) return k;
    return data[k]=find(data[k]);
  }
  
  ll size(ll k) {
    return -data[find(k)];
  }
  
};

int main(void) {
  ll i, j, k;
  ll N;
  cin >> N;
  
  unionFind uf=unionFind(MAX*2);
  
  for(i=0; i<N; i++) {
    ll x, y;
    cin >> x >> y;
    uf.unite(x, y+MAX);
  }
  
  map<ll, ll> mx, my;
  for(i=0; i<MAX; i++) mx[uf.find(i)]++;
  for(i=MAX; i<MAX*2; i++) my[uf.find(i)]++;
  
  ll ans=0;
  for(i=0; i<MAX*2; i++) ans+=mx[i]*my[i];
  ans-=N;
  pt(ans);
  
}





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

using namespace std;

int main() {
  int n, odd = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i % 2) odd++;
  }
  double ans = (double)odd / (double)n;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = input()
n = int(n)

count = 0
ans  = 0

for i in [x for x in range(n+1) if x % 2 != 0]:
    # print(i)
    count = 0
    for j in range(n):
        if i % (j+1) == 0:
            # print(j+1)
            count += 1
    # print(count)
    if count == 8:
        ans += 1
print(ans)


Measured memory_bytes: 2940
#include<stdio.h>

int main(void){
 int i,n;
 double debt=100;
 scanf("%d",&n);
 for(i=0;i<n;i++){
 	debt=debt*1.05;
	debt=debt+0.999;
	debt=(int)debt;
 }
 printf("%d\n",(int)(debt)*1000);

 return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << res << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

int main() {
	double L;
	cin >> L;
	double x = L / 3;
	double res = pow(x, 3);
	pvd(res);

	return(0);
}

Measured memory_bytes: 256
r,c = map(int, input().split())
ary = []


for i in range(r):
    ary.append(list(map(int, input().split())))

# 最後に各列の合計を書き加えるための行を追加。
ary.append([0]*c)

# 合計を出すための一時データとして変数tmpを初期化
tmp = 0

# 各列の合計を求めて、最終行に加えた数値を書き換える
for i2 in range(c):
    for i1 in range(r):
        tmp += ary[i1][i2]
    ary[i1+1][i2] = tmp
    tmp = 0


# 各行の行末に、各行の合計をappendで追加

for i1 in range(r+1):
    for i2 in range(c):
        tmp += ary[i1][i2]
    ary[i1].append(tmp)
    tmp = 0

for i1 in range(r+1):
    print(" ".join(map(str, ary[i1])))





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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

struct Point : public complex<double>
{
public:
  Point() { this->real(0);  this->imag(0); }
  Point(const double& x, const double& y) { this->real(x);  this->imag(y); }
  Point(const complex<double> w)  { this->real(w.real());  this->imag(w.imag()); }
  inline double dot(Point p){ return (conj(*this) * p).real(); }  // ??????
  inline double det(Point p){ return (conj(*this) * p).imag(); }  // ??????
};

namespace std
{
  bool operator < (const Point& a, const Point& b)
  {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
typedef vector<Point> Polygon;

template<typename T> T add(T x, T y){ if(abs(x+y) < EPS*(abs(x)+abs(y))) return 0; return x + y; }
template<typename T> inline bool semieq(T x, T y){ return abs(x - y) < EPS; }
template<typename T> inline bool semige(T x, T y){ return x - y > -EPS; }
template<typename T> inline bool semile(T x, T y){ return y - x > -EPS; }

double sx, sy;
double tx, ty;

int main()
{
  while(cin >> sx >> sy >> tx >> ty){
    Point AB = Point(tx, ty) - Point(sx, sy);
    cin >> sx >> sy >> tx >> ty;
    Point CD = Point(tx, ty) - Point(sx, sy);
    puts(semieq(AB.dot(CD), 0.0) ? "YES" : "NO");
  }

  return 0;
}

Measured memory_bytes: 1188
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int N, L[300], ans;

int main() {
	rd(N);
	repi(i, 0, 2 * N) rd(L[i]);
	sort(L, L + 2 * N);
	repi(i, 0, N) {
		ans += L[2 * i];
	}
	wrln(ans);
	return 0;
}

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

int main() {
	string s;
    cin>>s;
    int n = s.size();
    int k=0;
    if(s.size()==26){
      while(s.size()>1&&s[s.size()-2]>s[s.size()-1])s.pop_back();
      s.pop_back();
      if(s.size()==0){
        cout<<-1;
        return 0;
      }
      k=s[s.size()-1]-'a'+1;
      s.pop_back();
    }
       
    bool alp[26]={};
    rep(i,n) alp[s[i]-'a']++;
    for(int i=k;i<=26;i++)if(!alp[i]){
      cout<<s<<char('a'+i);
      return 0;
    }   
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
string s[10];
int lat[10][5];
int grid[5][5];
bool symmetory[10];
int dfs(int p, vector<bool> used){
  if(p < 5){
    int res = 0;
    for(int i = 0; i < 10; i++) if(!used[i]){
      used[i] = true;
      REP(j, 5) grid[j][p] = lat[i][j] ^ 1;
      res += dfs(p + 1, used);
      REP(j, 5) grid[4 - j][p] = lat[i][j] ^ 1;
      if(!symmetory[i])res += dfs(p + 1, used);
      used[i] = false;
    }
    return res;
  }else if(p < 10){
    int res = 0;
    for(int i = 0; i < 10; i++) if(!used[i]){
      used[i] = true;
      bool ok = true;
      REP(j, 5) if(grid[p - 5][j] != lat[i][j]) ok = false;
      if(ok) res += dfs(p + 1, used);
      ok = true;
      REP(j, 5) if(grid[p - 5][j] != lat[i][4 - j]) ok = false;
      if(ok && !symmetory[i]) res += dfs(p + 1, used);
      used[i] = false;
    }
    return res;
  }else{
    return 1;
  }
}

int main(){
  while(cin >> s[0]){
    if(s[0] == "END") break;
    REP(i, 9) cin >> s[i + 1];
    REP(i, 10){
      string t = s[i];
      reverse(t.begin(), t.end());
      symmetory[i] = (s[i] == t);
    }
    REP(i, 10) REP(j, 5) lat[i][j] = s[i][j] - '0';
    vector<bool> used(10);
    cout << dfs(0, used)/8 << endl;
  }
  return 0;
}

Measured memory_bytes: 1204