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

using namespace std;
using ll = long long;
using Matrix = vector<vector<ll>>;

const ll INF = numeric_limits<ll>::max() / 2;
Matrix dist;
int N, M, R;

void warshallFloyd() {
    for (int k = 1; k <= N; k++) {
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                if (dist[i][k] + dist[k][j] < dist[i][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];
                }
            }
        }
    }
}

ll r[9];
bool visiting[9];
ll res = INF;

void dfs(int cnt, int p, ll d) {
    if (d >= INF) { return; }
    
    if (cnt == R + 1) {
        if (d < res) { res = d; }
        return;
    }

    for (int i = 1; i <= R; i++) {
        if (visiting[i] == false) {
            visiting[i] = true;
            if (p == -1) { dfs(cnt + 1, i, 0); }
            else { dfs(cnt + 1, i, d + dist[r[p]][r[i]]); }
            visiting[i] = false;
        }
    }
}

int main() {
    cin >> N >> M >> R;
    for (int n = 1; n <= R; n++) { cin >> r[n]; }

    dist = Matrix(201, vector<ll>(201, INF));
    for (int n = 1; n <= N; n++) { dist[n][n] = 0; }
    for (int n = 1; n <= M; n++) {
        int A, B;
        ll C;

        cin >> A >> B >> C;

        dist[A][B] = C;
        dist[B][A] = C;
    }

    warshallFloyd();
    dfs(1, -1, 0);

    cout << res << endl;

    return 0;
}

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

const int maxn = 10010;
int n, a[maxn], b[maxn];
bool chk[maxn];

int main() {
    scanf("%d", &n);
    int g = 0;
    for (int i = n; ~i; i--) {
        scanf("%d", &a[i]), g = __gcd(g, abs(a[i]));
    }
    for (int i = 2; i <= n; i++) if (!chk[i]) {
        for (int j = i + i; j <= n; j += i) chk[j] = 1;
    }
    vector<int> ans;
    for (int i = 2; 1LL * i * i <= g; i++) if (!(g % i)) {
        ans.push_back(i);
        while (!(g % i)) g /= i;
    }
    if (g > 1) ans.push_back(g);
    auto solve = [&](int p) {
        if (a[0] % p) return 0;
        copy(a, a + n + 1, b);
        for (int i = n; i >= p - 1; i--) {
            (b[i - p + 1] += b[i]) %= p, b[i] = 0;
        }
        for (int i = 0; i <= n; i++) {
            if (b[i] % p) return 0;
        }
        return 1;
    };
    for (int i = 2; i <= n; i++) {
        if (!chk[i] && solve(i)) ans.push_back(i);
    }
    sort(ans.begin(), ans.end());
    ans.resize(unique(ans.begin(), ans.end())- ans.begin());
    for (int x : ans) printf("%d\n", x);
    return 0;
}

Measured memory_bytes: 384
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k,q = LI()
    c = collections.Counter([I() for _ in range(q)])
    r = []
    for i in range(1,n+1):
        if q-c[i] >= k:
            r.append("No")
        else:
            r.append("Yes")

    return JA(r, "\n")


print(main())





Measured memory_bytes: 14020
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  vector<vector<ll>> dp(n+1, vector<ll>(4));
  dp[0][0] = 1;
  rep(i, n) {
    rep(j, 4) (dp[i+1][j] += dp[i][j]*(s[i]=='?' ? 3 : 1)) %= mod;
    switch(s[i]) {
    case 'A':
      (dp[i+1][1] += dp[i][0]) %= mod;
      break;
    case 'B':
      (dp[i+1][2] += dp[i][1]) %= mod;
      break;
    case 'C':
      (dp[i+1][3] += dp[i][2]) %= mod;
      break;
    default:
      (dp[i+1][1] += dp[i][0]) %= mod;
      (dp[i+1][2] += dp[i][1]) %= mod;
      (dp[i+1][3] += dp[i][2]) %= mod;
    }
  }
  cout << dp[n][3] << endk;
  return 0;
}


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

int main()
{
	string S;
	cin >> S;

	int N = S.size();
	vector<int> zero;
	for( int i = 0; i < N; i++ ) {
		if( i == 0 ) {
			if( S[i] == '>' && S[i + 1] == '<' ) zero.push_back( i + 1 );
			else if( S[i] == '<' ) zero.push_back( i );
		}
		if( i == N - 1 ) {
			if( S[i] == '>' ) zero.push_back( i + 1 );
		}
		else {
			if( S[i] == '>' && S[i + 1] == '<' ) zero.push_back( i + 1 );
		}
	}
	vector<int> a( N + 1 );
	for( int i = 0; i < zero.size(); i++ ) {
		int z = zero[i];
		int n = 0;
		for( int j = z - 1; j >= 0; j-- ) {
			if( S[j] == '<' ) break;
			n++;
			a[j] = max( a[j], n );
		}
		n = 0;
		for( int j = z + 1; j < N + 1; j++ ) {
			if( S[j - 1] == '>' ) break;
			n++;
			a[j] = max( a[j], n );
		}
	}
	long long ans = 0;
	for( int i = 0; i < N + 1; i++ ) {
		ans += a[i];
	}

	cout << ans << endl;
}


Measured memory_bytes: 3456
a = list(input())
k = int(input())
l = []
for i in range(len(a)):
    # print(i)
    for j in range(1,k+1):
        # print(j)
        if(len(a) >= i+j):
            t = ''.join(a[i:i+j])
            l.append(t)
            # print(l)
l = list(set(l))
l.sort()
# print(l)
print(l[k-1])


Measured memory_bytes: 5084
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

const ll INF = 1LL << 60;

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
int main() {
    ll a, b;
    cin >> a >> b;
    primeFactors(a);
    ll ans = 0;
    for (auto x : cnt) {
        if (b % x.first == 0) {
            ans++;
        }
    }
    cout << ans + 1 << endl;
}

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

vector<int> sieve(int n);

vector<int> sieve(int n){
    vector<int> primes(n);
    for(int i=2; i<n; i++){
        primes[i] = i;
    }
    for(int i=2; i*i<n; i++){
        if(primes[i]){
            for(int j=i*i; j<n; j+=i){
                primes[j] = 0;
            }
        }
    }
    return primes;
}

int main(){
    int n;
    vector<int> primes = sieve(250000);
    while(cin >> n, n != 0){
        int cnt = 0;
        for(int i = n+1; i<=2*n; i++){
            if(primes[i] != 0) cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

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

using namespace std;

void solve()
{
	int N, Q;
	cin >> N >> Q;
	vector<long> as(N), imos(N+1);
	for (int i = 0; i < N; i++)
	{
		cin >> as[i];
		imos[i+1] = imos[i] + as[i];
	}

	while(Q--)
	{
		long ans = 0, x;
		cin >> x;
		for (int l = 0; l < N; l++)
		{
			int ok = l, ng = N+1;
			while(ok+1<ng)
			{
				int mid = (ok + ng) / 2;
				(imos[mid] - imos[l] <= x ? ok : ng) = mid;
			}
			ans += ok - l;
		}
		cout << ans << endl;
	}

}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 4328
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll n;cin>>n;
    vector<ll>tri(100010);
    ll a=1;
    while(a*(a-1)/2<100010){
        tri[a*(a-1)/2]=a;
        a++;
    }
    if(tri[n]){
        ll k=tri[n];
        vector<vector<ll> >s(tri[n]);
        ll b=1;
        rep(i,k){
            REP(j,i+1,k){
                s[i].pb(b);
                s[j].pb(b);
                b++;
            }
        }
        cout<<"Yes"<<endl;
        cout<<k<<endl;
        rep(i,k){
            cout<<s[i].size();
            for(auto e:s[i])cout<<' '<<e;
            cout<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3968
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> perm(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> perm[i];
    }
    
    ll ans = 0;
    for (ll i = 0; i < N - 2; i++)
    {
        if (perm[i] > perm[i + 1] && perm[i + 1] > perm[i + 2]
         || perm[i] < perm[i + 1] && perm[i + 1] < perm[i + 2]) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]) = {
    var n = readLine.split(" ").map(_.toInt)

    while( n(0) != 0 || n(1) != 0) {
      for(i <- 0 to n(0)-1) {
        val str = if(i%2==0) "#."*n(1) else ".#"*n(1)
        println(str.take(n(1)))
      }
      println()
      n = readLine.split(" ").map(_.toInt)
    }
  }
}

Measured memory_bytes: 45360
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

  cin >> n;

  int ans = 0;

  REP(i, n) {
    int a;
    cin >> a;
    while (a % 2 == 0) {
      ans++;
      a /= 2;
    }
  }

  cout << ans << endl;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  while(cin >> N,N){
	map<string,int> country;
	vector<vector<string>> adj(N);
	VI bs(N);
	REP(i,N){
	  string s;
	  cin >> s;
	  country[s] = i;
	  cin >> bs[i];
	  int C; cin >> C;
	  REP(j,C){
		cin >> s;
		adj[i].EB(s);
	  }
	}
	if(N == 1){
	  cout << bs[0] << endl;
	  continue;
	}

	VVI G(N);
	REP(i,N){
	  for(auto& s: adj[i])
		G[i].PB(country[s]);
	}
	VL ban(N);
	REP(i,N){
	  for(int to: G[i])
		ban[i] = ban[i] | (1ll<<to);
	}

	int N2 = N / 2;
	int NR = N - N2;
	VI dp(1<<NR);
	REP(i,1<<NR){
	  int sum = 0;
	  LL x = (LL)(i) << N2;
	  REP(j,NR)
		if(i>>j&1){
		  sum += bs[j+N2];
		  if((ban[j+N2] & x) != 0){
			sum = -1e9;
			break;
		  }
		}
	  if(sum >= 0)
		dp[((1<<NR)-1)^i] = sum;
	}
	
	for(int i=0;i<NR;++i){
	  for(int b=0;b<(1<<NR);++b){
		if((b>>i&1) == 0)
		  maxi(dp[b], dp[b|(1<<i)]);
	  }
	}
	//REP(i,1<<N2) cout << bitset<4>(i) << ": " << dp[i] << endl;
	int ans = 0;
	for(int b=1;b<1<<N2;b+=2){
	  int sum = 0;
	  LL x = b;
	  LL b2 = 0;
	  REP(j,N2)
		if(b>>j&1){
		  b2 = b2 | ban[j];
		  sum += bs[j];
		  if((ban[j] & x) != 0){
			sum = -1e9;
			break;
		  }
		}
	  if(sum < 0) continue;
	  b2 = b2 >> N2;
	  ans = max(ans, sum + dp[b2]);
	}
	cout << ans << endl;
  }
 
  return 0;
}

Measured memory_bytes: 7376
s = input()
n = len(s)

a = [0] * (n + 1)

for i in range(n):
    if s[i] == '<':
        a[i + 1] = max(a[i + 1], a[i] + 1)

for i in range(n - 1, -1, -1):
    if s[i] == '>':
        a[i] = max(a[i], a[i + 1] + 1)

print(sum(a))


Measured memory_bytes: 46448
#include<bits/stdc++.h>
#include<cassert>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds; 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX

const int MAXN=2e5+1;
const int M=1e9+7;

ll fac[MAXN],infac[MAXN],dp[MAXN],dp1[MAXN],sz[MAXN];
 int n;

ll modexp(ll a,ll b){
	if(b==0)
		return 1;
	if(b%2==0){
		return modexp((a*a)%M,b/2);
	}
	else{
		return (a*modexp((a*a)%M,b/2))%M;
	}
}
 
ll modinver(ll num){
 
	return modexp(num,M-2);
}
 
void intialise(){
	fac[0]=1;
 
	for(int i=1;i<MAXN;i++){
		fac[i]=(fac[i-1]*i)%M;
	}
 
	infac[MAXN-1]=modinver(fac[MAXN-1]);
 
	for(int i=MAXN-2;i>=0;i--){
		infac[i]=(infac[i+1]*(i+1))%M;
		//cout<<i<<" "<<infac[i]<<endl;
	}
}
 
vector<int> v[MAXN];


void dfs(int node,int par){

	for(int x:v[node]){
		if(x==par) continue;

		dfs(x,node);
		sz[node]+=sz[x];
	}

	ll ans=fac[sz[node]];

	//cout<<node<<" "<<ans<<endl;

	for(int x:v[node]){
		if(x==par)
			 continue;

		ans=(ans*dp[x])%M;
		ans=(ans*infac[sz[x]])%M;
	}

	sz[node]++;

	dp[node]=ans;



}

void dfs1(int node,int par){

	if(node!=1){
		ll tempval=dp1[par];
		tempval=(tempval*infac[n-1])%M;
		tempval=(tempval*fac[n-1-sz[node]])%M;
		tempval=(tempval*modinver(dp[node]))%M;
		tempval=(tempval*fac[sz[node]])%M;

		
		ll ans=dp[node];
		ans=(ans*infac[sz[node]-1])%M;
		ans=(ans*fac[n-1])%M;
		ans=(ans*tempval)%M;
		ans=(ans*infac[n-sz[node]])%M;
		dp1[node]=ans;

	}

	for(int x:v[node]){
		if(x==par)
			continue;

		dfs1(x,node);
	}
}

int main(){	
	
	intialise();

	sfi(n)

	for(int i=0;i<n-1;i++){
		int x,y;
		sfi(x) sfi(y)
		v[x].push_back(y);
		v[y].push_back(x);
	}

	dfs(1,1);

	dp1[1]=dp[1];

	dfs1(1,1);
	for(int i=1;i<=n;i++)
	cout<<dp1[i]<<endl;
	
	return 0;	
}

Measured memory_bytes: 21748
#include <stdio.h>

int main(void)
{
	int a1,a2,a3,a4,a5,a6;
	char cmd[101] = {0};
	int i;
	scanf("%d%d%d%d%d%d",&a1,&a2,&a3,&a4,&a5,&a6);
	int x = a1;
	scanf("%s",cmd);
	
	for(i = 0 ; cmd[i] != 0 ; i++){
		
		if('N'==cmd[i]){
			 x = a1;
			a1 = a2;
			a2 = a6;
			a6 = a5;
			a5 =  x;
		}
		else if('S'==cmd[i]){
			 x = a1;
			a1 = a5;
			a5 = a6;
			a6 = a2;
			a2 =  x;
		}
		else if('W'==cmd[i]){
			 x = a1;
			a1 = a3;
			a3 = a6;
			a6 = a4;
			a4 =  x;
		}
		else if('E'==cmd[i]){
			 x = a1;
			a1 = a4;
			a4 = a6;
			a6 = a3;
			a3 =  x;
		}
		else {
			break;
		}
	}
	printf("%d\n",a1);
	
	return 0;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void _dump(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void _dump(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  _dump(s, forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  VAR(i64, N, X);

  vector<i64> x(N + 1);
  rep(i, N) {
    IN(x[i]);
  }
  x[N] = X;

  sort(all(x));

  i64 G = abs(x[0] - x[1]);
  for (int i = 1; i <= N - 1; ++i) {
    G = __gcd(G, abs(x[i] - x[i+1]));
  }

  OUTL(G);
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;

main(){
    string s;
    cin>>s;
    ll sum=0;
    int pre=-1;
    int tmp=0;
    rep(i,s.size()){
        if(s[i]=='>'){
            ll cnt=0;
            while(i<s.size()&&s[i]=='>'){
                cnt++;i++;
            }
            if(tmp<=cnt){
                sum-=tmp;
                sum+=cnt*(cnt+1)/2;
                tmp=0;
            }
            else{
                sum+=(cnt-1)*(cnt)/2;
                tmp=0;
            }
            i--;
        }
        else{
            pre=i;
            tmp++;
            sum+=tmp;
        }
    }
    cout<<sum;
}


Measured memory_bytes: 900
loop do
    ans = 0
    n, x = gets.chomp.split.map(&:to_i)
    break if (n+x).zero?
    (1..n).each do |a|
        (a+1..[n, x-a].min).each do |b|
            (b+1..[n, x-b].min).each do |c|
                ans += a+b+c==x ? 1 : 0
            end
        end
    end
    puts ans
end


Measured memory_bytes: 6868
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,ans=1;
    cin>>n;
    map<int,int>m;

    for(int i=2;i <=n;i++){
       int cpy = i;
       for(int j=2;j*j<=cpy;j++){
            if(cpy%j==0){
                while(cpy%j==0){
                    m[j]++;
                    cpy = cpy/j;
                }
            }
       }
    if(cpy!=1){
        m[cpy]++;
    }

    }
    int j =1;
    tr(it,m){
            j = (j*(it->second +1))%mod;
    }
    cout<<j<<endl;

    }




















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

#define ll long long
#define Ok puts("OK");

using namespace std;

const int N = (int)123;

int a[N];
int n;

main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  double ans;
  ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (1.0 / a[i]);
  }
  cout << fixed << setprecision(12) << 1.0 / ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w,n; cin >> h >> w >> n;
  int sr,sc; cin >> sr >> sc;
  string s,t; cin >> s >> t;

  // 左から落とす
  int x = sc;
  REP(i,n){
    if(s[i]=='L') x--;
    if(x==0){
      cout << "NO\n";
      return 0;
    }
    if(t[i]=='R' && x<w) x++;
  }

  // 右から落とす
  x = sc;
  REP(i,n){
    if(s[i]=='R') x++;
    if(x>w){
      cout << "NO\n";
      return 0;
    }
    if(t[i]=='L' && x>1) x--;
  }

  //　上から落とす
  int y = sr;
  REP(i,n){
    if(s[i]=='U') y--;
    if(y==0){
      cout << "NO\n";
      return 0;
    }
    if(t[i]=='D' && y<h) y++;
  }

  //　下から落とす
  y = sr;
  REP(i,n){
    if(s[i]=='D') y++;
    if(y>h){
      cout << "NO\n";
      return 0;
    }
    if(t[i]=='U' && y>1) y--;
  }

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


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ll<<62)-1)
#define cINFINT ((1<<30)-1)


template <typename T>
void calcFactional_mod( size_t size, 
	vector<T>& fac, vector<T>& inv, vector<T>& facInv, T mod )
{
	for( T i = 2; i < size; ++i )
	{
		fac[i] = fac[i - 1] * i % mod; // n! % mod
		inv[i] = mod - inv[mod % i] * ( mod / i ) % mod; // 逆元計算 (n)^-1 % mod
		facInv[i] = facInv[i - 1] * inv[i] % mod; // (n!)^-1 % mod
	}
}
template <typename T>
T pow_mod(T x, T n, T mod)
{
	T res = 1;
	while (n > 0)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

int main()
{
	const ll maxN = 1000010;
	vector<ll> fac( maxN, 1 ), inv( maxN, 1 ), facInv( maxN, 1 );
	calcFactional_mod<ll>( maxN, fac, inv, facInv, cMOD);
	auto mod = cMOD;
	auto add = [mod]      ( ll a, ll b ) { return ( a + b ) % mod; };
	auto sub = [mod]      ( ll a, ll b ) { return ( a + mod -b ) % mod; };
	auto mul = [mod]      ( ll a, ll b ) { return a * b % mod; };
	auto div = [&inv, mod]( ll a, ll b ) { return a * inv[b] % mod; };
	auto pow = [mod]      ( ll a, ll b ) { return pow_mod<ll>( a, b, mod ); };
	
	ll n,h,d; cin >> n>>h>>d;
	ll nsum = 0;
	REP(i,n) nsum = add( nsum, fac[i+1] ); 

	vector<ll> dp( h, 0 );
	dp[0]=1;
	REP(i,h) if(i!=0)
	{
		ll t = sub( dp[i-1], (i-1-d>=0 ? dp[i-1-d] : 0) );
		dp[i] = add( mul( t, nsum ), dp[i-1] );
	}

	ll ans = sub( dp[h-1], (h-1-d>=0 ? dp[h-1-d] : 0) );
	ans = mul( ans, fac[n] );
	cout << ans << endl;
	
	return 0;
}

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


int main(){

  
  while(1){
  int a,b;
  string op;
  cin >> a >> op >> b;
  if (op == "?") break;


  int ans;
  if (op == "+") ans = a + b;
  if (op == "-") ans = a - b;
  if (op == "*") ans = a * b;
  if (op == "/") ans = a / b;


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


Measured memory_bytes: 3152
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int a, b;
    cin >> a >> b;
    int g = 1;
    FOR(i, 1, 100001)
        if (a % i == 0 && b % i == 0)
            g = i;

    cout << a / g * 1LL * b << endl;
    return 0;
};

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<int,pii> pip;
int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


signed main(void) {
    int n;
    while(cin >> n,n){
        vi a(n);
        rep(i,n) cin >> a[i];
        int sum = 0;
        rep(i,n) sum += a[i];
        int ans = 0;
        rep(i,n)if(a[i]*n <= sum)ans++;
        cout << ans << endl;
    }
}



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

char F[102][102];
void DFSA(int y,int x){
	if(F[y][x]!='@')
		return;
	F[y][x]='.';
	DFSA(y-1,x  );
	DFSA(y  ,x+1);
	DFSA(y+1,x  );
	DFSA(y  ,x-1);
}
void DFSP(int y,int x){
	if(F[y][x]!='#')
		return;
	F[y][x]='.';
	DFSP(y-1,x  );
	DFSP(y  ,x+1);
	DFSP(y+1,x  );
	DFSP(y  ,x-1);
}
void DFSO(int y,int x){
	if(F[y][x]!='*')
		return;
	F[y][x]='.';
	DFSO(y-1,x  );
	DFSO(y  ,x+1);
	DFSO(y+1,x  );
	DFSO(y  ,x-1);
}
int main(){
	int n,m;
	while(1){
		cin>>n>>m;
		if(n==0&&m==0) break;
		for(int y=1;y<=n;y++){
			for(int x=1;x<=m;x++){
				cin>>F[y][x];
			}
		}		

		int c=0;
		for(int y=1;y<=n;y++){
			for(int x=1;x<=m;x++){
				if(F[y][x]=='@'){
					c++;
					DFSA(y,x);
				}
				if(F[y][x]=='#'){
					c++;
					DFSP(y,x);
				}
				if(F[y][x]=='*'){
					c++;
					DFSO(y,x);
				}
			}
		}
	cout<<c<<endl;
	}
	return 0;

}

Measured memory_bytes: 3468
#include <stdio.h>

int main()
{
  int n[5];
  int i, j;

  scanf("%d %d %d %d %d", &n[0], &n[1], &n[2], &n[3], &n[4]);

  for(i = 0; i < 5; i++)
    for(j = i + 1; j < 5; j++)
      if(n[i] < n[j])
	{
	  int tmp = n[i];
	  n[i] = n[j];
	  n[j] = tmp;
	}

  printf("%d %d %d %d %d\n", n[0], n[1], n[2], n[3], n[4]);

  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
using namespace std;
signed main() {
  int h,w;
  cin>>h>>w;
  if(h%3==0||w%3==0) {
    cout<<0<<endl;
  }
  else {
    int ans=inf;
    if(h%2==0) {
      rep(i,w-1) {
        ans=min(ans,max((i+1)*h,(w-i-1)*h/2)-min((i+1)*h,(w-i-1)*h/2));
      }
    }
    else {
      rep(i,w-1) {
        ans=min(ans,max({(i+1)*h,(w-i-1)*(h-1)/2,(w-i-1)*(h+1)/2})-min({(i+1)*h,(w-i-1)*(h-1)/2,(w-i-1)*(h+1)/2}));
      }
    }
    swap(h,w);
    if(h%2==0) {
      rep(i,w-1) {
        ans=min(ans,max((i+1)*h,(w-i-1)*h/2)-min((i+1)*h,(w-i-1)*h/2));
      }
    }
    else {
      rep(i,w-1) {
        ans=min(ans,max({(i+1)*h,(w-i-1)*(h-1)/2,(w-i-1)*(h+1)/2})-min({(i+1)*h,(w-i-1)*(h-1)/2,(w-i-1)*(h+1)/2}));
      }
    }
    cout<<min({ans,h,w})<<endl;
  }
}

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

long long n, l;
const int dsize = 2;
long long calc(long long x) {
  if(x == 0) return 0;
  if(x % 2 == 1) return 1;
  long long now = 63;
  while(now--) {
    if(x % (1 << now) == 0) return now;
  }
  return 0;
}
struct Trie {
  struct data {
    int num;
    data *child[dsize];
    data(int nnum = -1) {
      num = nnum;
      fill(child, child + dsize, (data *)0);
    }
  };
  data root;
  Trie() { root = data(0); }
  void make(string x) {
    data *now = &root;
    for(int i = 0; i < x.size(); ++i) {
      if(!now->child[x[i] - '0'])
        now->child[x[i] - '0'] = new data(now->num + 1);
      now = now->child[x[i] - '0'];
    }
  }
  bool solve() {
    long long ans = 0;
    if(root.child[0]) ans ^= recall(root.child[0]);
    if(root.child[1]) ans ^= recall(root.child[1]);
    if((!root.child[0]) || (!root.child[1])) ans ^= calc(l);
    return ans == 0;
  }
  long long recall(data *now) {
    long long ans = 0;
    if((!now->child[0]) && (!now->child[1])) return 0;
    if((!now->child[0]) || (!now->child[1]))
      ans = calc(l - now->num);
    if(now->child[0]) ans ^= recall(now->child[0]);
    if(now->child[1]) ans ^= recall(now->child[1]);
    return ans;
  }
};
void prians(bool answer) {
  if(answer)
    cout << "Bob" << endl;
  else
    cout << "Alice" << endl;
}
Trie trie;
int main() {
  cin >> n >> l;
  for(int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    trie.make(s);
  }
  prians(trie.solve());
  return 0;
}

Measured memory_bytes: 5632
n,m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]#2次元配列
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):#全てのスイッチの場合に対して
    check = True#全点灯かどうか調べる
    for j in range(m):#電球ごと
        light = 0#スイッチオンの数
        for k in range(1,len(l[j])):
            if((i>>l[j][k] -1) &1):#j番目の電球のk個目のスイッチが入ってるなら
                light +=1#スイッチオンの数+1
        if light%2 != p[j]:
            check = False#スイッチオフならfalse
    if check:
        ans +=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  int mx=0;
  for(auto p:mp) mx=max(p.second,mx);
  for(auto p:mp){
    if(p.second != mx) continue;
    else cout << p.first << endl;
  }
}

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

int main(){
   int N, p, q;
  
  cin>>N;
  
  p = N / 500;
  q = N % 500;  
  
  q = q / 5;
  
  cout<<1000*p + 5*q<<endl;
  
  
}


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

int N;
int a[200005];
long long minfront[200005];
long long minback[200005];
deque<int> front;
deque<int> back;
long long counter=0;

int main()
{
    cin>>N;

    for (int i=1; i<=N; i++)
    {
        cin>>a[i];
    }

    for (int i=1; i<=N; i++)
    {
        if (i==1)
        {
            front.push_back(a[i]);
            minfront[a[i]]=1;
        }

        else
        {
            minfront[a[i]]=1;
            while (!front.empty() && a[i]<front.back())
            {
                minfront[a[i]]+=minfront[front.back()];
                front.pop_back();
            }
            front.push_back(a[i]);
        }
    }


    for (int i=N; i>=1; i--)
    {
        if (i==N)
        {
            back.push_back(a[i]);
            minback[a[i]]=1;
        }

        else
        {
            minback[a[i]]=1;
            while (!back.empty() && a[i]<back.back())
            {
                minback[a[i]]+=minback[back.back()];
                back.pop_back();
            }
            back.push_back(a[i]);
        }
    }

    for (int i=1; i<=N; i++)
    {
        counter=counter+i*minfront[i]*minback[i];
    }

    cout<<counter<<endl;
}

Measured memory_bytes: 8340
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort()# ソート
hashi = [a[0], a[-1]]
total = abs(a[0] - a[-1])

s = 1
e = n - 2
if n == 2:
    print(total)
    exit()
while True:
    max_diff = 0
    point = "s"
    h = "s"
    if max_diff < abs(hashi[0] - a[s]):
        max_diff = abs(hashi[0] - a[s])
        point = "s"
        h = "s"
    if max_diff < abs(hashi[0] - a[e]):
        max_diff = abs(hashi[0] - a[e])
        point = "e"
        h = "s"
    if max_diff < abs(hashi[1] - a[s]):
        max_diff = abs(hashi[1] - a[s])
        point = "s"
        h = "e"
    if max_diff < abs(hashi[1] - a[e]):
        max_diff = abs(hashi[1] - a[e])
        point = "e"
        h = "e"
    total += max_diff
    if h == "s":
        if point == "s":
            hashi[0] = a[s]
        if point == "e":
            hashi[0] = a[e]
    if h == "e":
        if point == "s":
            hashi[1] = a[s]
        if point == "e":
            hashi[1] = a[e]
    if point == "s":
        s += 1
    if point == "e":
        e -= 1
    if s - 1 == e:
        break
print(total)

Measured memory_bytes: 7416
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL A, B, T;
	in >> A >> B >> T;
	out << (T / A) * B << std::endl;
}


Measured memory_bytes: 256
n, m = map(int,input().split())
a_list = list(map(int,input().split()))
a_list.sort(reverse=True)

total = sum(a_list)
count = 0
for i in range(m):
    vote = a_list[i]
    if vote*m*4 >= total:
        count += 1

if count==m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			double N = in.nextDouble();
			System.out.println((int)Math.ceil(N / 2));
		}
	}

	static boolean permutation_2(String s, String t) {
		if (s.length() != t.length()) {
			return false;
		}

		int[] letters = new int[256];

		char[] s_array = s.toCharArray();
		for (char c : s_array) {
			letters[c]++;
		}

		for (int i = 0; i < t.length(); i++) {
			int c = (int) t.charAt(i);
			if (--letters[c] < 0) {
				return false;
			}
		}
		return true;
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


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

int main(){
  int N, a, count, cmin;
  cin >> N;
  cmin = 0;
  for (int i=0; i<N; i++) {
    cin >> a;
    count = 0;
    while (a%2 == 0) {
      a /= 2;
      count++;
    }
    if (i == 0)
      cmin = count;
    if (cmin > count)
      cmin = count;
  }
  cout << cmin << endl;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    int l[N];
    int r[N];
    for (int i = 0; i < N; i++) {
        cin >> l[i] >> r[i];
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += (r[i] - l[i] + 1);
    }
    cout << sum << endl;
    return 0;
}


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

int jobs[200000][2];

int cmp(const void *a, const void *b) {
	const int *ap = a, *bp = b;
	return ap[1] - bp[1];
}

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

	for (int i = 0; i < n; i++) {
		scanf("%d%d", &jobs[i][0], &jobs[i][1]);
	}
	qsort(jobs, n, sizeof jobs[0], cmp);

	long long int time = 0;
	for (int i = 0; i < n; i++) {
		time += jobs[i][0];
		if (time > jobs[i][1]) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}


Measured memory_bytes: 3324
# Aizu Problem 0221: Fizz Buzz

import sys, math, os, struct

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def valid(k, a):
    if k % 15 == 0: 
        return a == "FizzBuzz"
    elif k % 3 == 0:
        return a == "Fizz"
    elif k % 5 == 0:
        return a == "Buzz"
    else:
        return a == str(k)

    
def fizz_buzz(m, n, A):
    players = list(range(1, m + 1))
    p = 0
    k = 0
    while len(A) > 0:
        k += 1
        a = A.pop(0)
        if valid(k, a):
            p = (p + 1) % m
        else:
            if len(players) == 0:
                print()
                return
            players.pop(p)
            if len(players) == 1:
                break
            m -= 1
            p %= m
    print(' '.join([str(p) for p in players]))
    
    
while True:
    m, n = [int(_) for _ in input().split()]
    if m == 0:
        break
    A = [input().strip() for _ in range(n)]
    fizz_buzz(m, n, A)

Measured memory_bytes: 9156
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> B(N-1),A(N);
    for(int i=0;i<N-1;i++) cin >> B.at(i);
    int ans=0;
    for(int i=0;i<N;i++){
        if(i==N-1) ans += B.at(i-1);
        else if(i==0) ans += B.at(i);
        else ans += min(B.at(i),B.at(i-1));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static boolean DEBUG_FLG = false;

    public static void main(String[] args) {
    	char[] S = sc.next().toCharArray();
    	int win = 0;
    	for(int i=0; i<S.length; i++) {
    		if(S[i] == 'o') {
    			win++;
    		}
    	}
    	win += (15 - S.length);
    	if(win >= 8) {
    		System.out.println("YES");
    	} else {
    		System.out.println("NO");
    	}
    }

    static void debug(long... args) {
    	if(!DEBUG_FLG) return;
    	boolean flg = false;
    	for(long s : args) {
    		if(flg) System.out.print(" ");
    		flg = true;
    		System.out.print(s);
    	}
    	System.out.println();
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 21204
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] l = new long[N];
        for (int i = 0; i < N; i++) {
            l[i] = scan.nextLong();
        }
        Arrays.sort(l);
        if (N <= 2) {
            System.out.println(0);
            return;
        }
        long ans = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                for (int k = j + 1; k < N; k++) {
                    if (l[i] == l[j] || l[i] == l[k] || l[j] == l[k]) {
                        continue;
                    }
                    if (l[k] < l[i] + l[j]) {
                        ans += 1;
                    }
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 36716
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N,K;
    int ans=0;
    cin >>N >>K;
    vector<int>vec(N);
    vector<int>preans(N-K+1);
    REP(i,N){
        cin >>vec[i];
      	vec[i]++;
    }
    REP(i,N-K+1){
        if(i==0){
            REP(j,K){
                preans[0]+=vec[j];
            }
        }
        else{
            preans[i]=preans[i-1]+vec[i+K-1]-vec[i-1];
        }
    }
    sort(preans.rbegin(),preans.rend());
    double d=(preans[0])/2.0;
    cout << fixed << setprecision(10);
    cout << d << endl;
}

Measured memory_bytes: 3328
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265359
using namespace std;



int main()
{
    SYNC
    //clock_t tStart = clock();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n; in(n);
    vl v; 
    ll temp;
    l(i,0,n)
    {
        in(temp);
        v.pb(temp);
    }
    ll ans=0;
    l(i,1,n)
    {
        if(v[i]<v[i-1])
        {
            ans+= (v[i-1]-v[i]);
            v[i]=v[i-1];
        }
    }
    o(ans);








    //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);   
}


Measured memory_bytes: 5324
#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

int main(){
    ll N,A,B;
    cin>>N>>A>>B;

    ll ans=0;
    ans+=N/(A+B)*A;
    N%=(A+B);
    if(N<A){
        ans+=N;
    }else{
        ans+=A;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3628
N, *rest = $stdin.read.split.map(&:to_i)
AS, BS, CS = rest.each_slice(N).to_a.map(&:sort!)
#pp [AS, BS, CS]

na = i = 0
NA = BS.map{|b|
  while i < N && AS[i] < b
    na += 1
    i += 1
  end
  na
}

na = nb = i = 0
NB = CS.map{|c|
  while i < N && BS[i] < c
    nb += 1
    na += NA[i]
    i += 1
  end
  na
}
p NB.inject(0, :+)


Measured memory_bytes: 29040