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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, K;
    cin >> N >> K;
    ll A[N];
    REP(i, N) cin >> A[i];
    const int digit = 40;
    ll countDigit[digit] = {0};
    REP(i, N)
    {
        ll num = A[i];
        int count = 0;
        while(num > 0)
        {
            if (num % 2 == 1) countDigit[count]++;
            count++;
            num /= 2;
        }
    }

    ll num = K + 1;
    bool binaryK[digit] = {false};
    int count = 0;
    while(num > 0)
    {
        if (num % 2 == 1) binaryK[count] = true;
        count++;
        num /= 2;
    }

    ll score[digit] = {0};
    REP(i, digit)
    {
        if (binaryK[i])
        {
            for (int j = 0; j < i; ++j) score[i] += (ll)pow(2, j) * max(countDigit[j], N - countDigit[j]);
            score[i] += (ll)pow(2, i) * countDigit[i];
            for (int j = i + 1; j < digit; ++j)
            {
                if (binaryK[j]) score[i] += (ll)pow(2, j) * (N - countDigit[j]);
                else score[i] += (ll)pow(2, j) * countDigit[j];
            }
        }
    }

    ll ans = 0;
    REP(i, digit) ans = max(ans, score[i]);
    cout << ans << endl;
}


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

using namespace std;

const int N = 3e5;  // limit for array size
int n;  // array size
int t[2 * N];

void build() {  // build the tree
  for (int i = n - 1; i > 0; --i) t[i] = t[i<<1] + t[i<<1|1];
}

void modify(int p, int value) {  // set value at position p
  for (t[p += n] = value; p > 1; p >>= 1) t[p>>1] = t[p] + t[p^1];
}

int query(int l, int r) {  // sum on interval [l, r)
  int res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l&1) res += t[l++];
    if (r&1) res += t[--r];
  }
  return res;
}

int main()
{
  int m;
  scanf("%d", &n);
  cin>>m;
  // for (int i = 0; i < n; ++i) //scanf("%d", t + n + i);
       // t[n+i]=0;
  build();
  for(int i=1;i<=m;i++)
    {
      int op,x,y;
      cin>>op>>x>>y;
      if(op==0)
	modify(x-1,y+t[n+x-1]);
      else
	cout<<query(x-1,y)<<endl;
    }
  // modify(0, 1);
  //printf("%d\n", query(3, 11));
  return 0;
}

Measured memory_bytes: 2024
import sys
input = sys.stdin.readline


def inpl():
    return list(map(int, input().split()))


def factor(n):
    ret = {}
    p = 2
    root_n = int(n**0.5)
    while n > 1:
        if n % p == 0:
            n //= p
            ret[p] = ret.get(p, 0) + 1
        elif p <= root_n:
            p += 1
        else:
            p = n
    return ret


def gcd(a, b):
    # greatest common divisor
    while b > 0:
        a, b = b, a % b

    return a


def backtrack(pn_list, k=1):
    if (not pn_list) and k != 1 and k != N:
        factor_N.append(k)
    elif pn_list:
        # print(pn_list, k)
        p, v = pn_list[0]
        pn_list = pn_list[1:]
        # print(pn_list)
        for i in range(v + 1):
            backtrack(pn_list, k * (p**i))


def check(k):
    t = N
    while t % k == 0:
        t //= k
    return t % k == 1


factor_N = []


def solve():
    pn = factor(N)
    ans = 0
    a = 1
    for v in pn.values():
        a = gcd(a, v)
    for v in factor(a).values():
        a *= v + 1
    ans += a

    a = 1
    for v in factor(N - 1).values():
        a *= v + 1
    ans += a - 1

    pn_list = list(pn.items())
    # print(pn_list)
    backtrack(pn_list)
    for k in factor_N:
        if check(k):
            ans += 1

    return ans


N = int(input())

print(solve())


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,K;
ll ans;
int main(){
	scanf("%d %d",&N,&K);
	if(K%2==1){
		ll k = N/K;
		cout << k*k*k << endl;
	}else{
		ll k = N/(K/2);
		ll even = k/2;
		ll odd = k-even;
		cout << odd*odd*odd+even*even*even << endl;
	}
	return 0;
}

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

int main() {
  string S;
  int K;
  cin >> S >> K;
  
  int i,e=0;
  for(i=0;i<K;i++){
    if(S.at(i)!='1'){
      e++; break;
    }
  }
  if(e!=0){
    cout << S.at(i) << endl;
  }else{
    cout << 1 << endl;
  }
}



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

int main() {
	// your code goes here
	long long int n, d;
	cin >> n >> d;
	d *= d;
	vector<long long int> a(n);
	long long x,  y, ans = 0;
	for (int i = 0; i < n; ++i) {
		cin >> x >> y;
		if (x * x + y * y <= d)
			++ans;
	}
	cout << ans;
	
}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define long long long // for codeforces

char s[60][60];
int h,w;

int v(int x,int y){
  if(x<0 || y<0 || x>=h || y>=w) return 0;
  else return s[x][y]=='#';
}

int cnt(int x, int y){
  int ret = 0;
  rep(i,-1,2) rep(j,-1,2){
    ret += v(x+i, y+j);
  }
  return ret;
}

int main(){
  cin>>h>>w;
  rep(i,h) cin>>s[i];

  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#') printf("#");
      else printf("%d", cnt(i,j));
    }
    printf("\n");
  }

  return 0;
}


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

using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
//using u64 = double;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;

struct edge
{
    int v;
    u64 weight;
    edge (int v = 0, u64 weight = 0): v(v), weight(weight) {}
    bool operator<(const edge &e) const { return weight > e.weight; }
};
const int MAXV = 100010;
vector<vector<edge>> edges;
u64 distToTree[MAXV];
int n, parent[MAXV], intree[MAXV];

u64 prim(int u)
{
    u64 minSumOfWeight = 0;

    for (int i = 1; i <= n; i++)
        parent[i] = -1, intree[i] = 0, distToTree[i] = Inf;

    priority_queue<edge> q;
    q.push(edge(u, 0));

    while (!q.empty()) {
        edge e1 = q.top();
        q.pop();
        if (intree[e1.v]) continue;
        intree[e1.v] = 1, minSumOfWeight += e1.weight;
        for (auto e2 : edges[e1.v])
            if (!intree[e2.v] && distToTree[e2.v] > e2.weight) {
                distToTree[e2.v] = e2.weight;
                parent[e2.v] = e1.v;
                q.push(edge(e2.v, e2.weight));
            }
    }

    return minSumOfWeight;
}

struct point1 {
    u64 x, y;
    int idx;
    bool operator<(const point1 &e) const {
        return x < e.x;
    }
} towns1[MAXV];

struct point2 {
    u64 x, y;
    int idx;
    bool operator<(const point2 &e) const {
        return y < e.y;
    }
} towns2[MAXV];

struct point {
    u64 x, y;
} towns[MAXV];

int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> towns[i].x >> towns[i].y;
        towns1[i] = point1{towns[i].x, towns[i].y, i};
        towns2[i] = point2{towns[i].x, towns[i].y, i};
    }
    
    sort(towns1 + 1, towns1 + n + 1);
    sort(towns2 + 1, towns2 + n + 1);
    
    edges.resize(n + 1);
    
    for (int i = 1; i < n; i++) {
        u64 weight1 = min(abs(towns[towns1[i + 1].idx].x - towns[towns1[i].idx].x), abs(towns[towns1[i + 1].idx].y - towns[towns1[i].idx].y));
        u64 weight2 = min(abs(towns[towns2[i + 1].idx].x - towns[towns2[i].idx].x), abs(towns[towns2[i + 1].idx].y - towns[towns2[i].idx].y));
        edges[towns1[i + 1].idx].push_back(edge{towns1[i].idx, weight1});
        edges[towns1[i].idx].push_back(edge{towns1[i + 1].idx, weight1});
        edges[towns2[i + 1].idx].push_back(edge{towns2[i].idx, weight2});
        edges[towns2[i].idx].push_back(edge{towns2[i + 1].idx, weight2});
    }
    
    cout << prim(1) << endl;
    
    return 0;
}


Measured memory_bytes: 24088
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#define rep(i,n) for(int i=0; i<n; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int N;
	cin >> N;
	vi A(N);
	map<int,ll> mp;
	rep(i,N){
		cin >> A[i];
		if(mp[A[i]]==0){
			mp[A[i]]=1;
		}else{
			mp[A[i]]++;
		}
	}

	ll ans=0;
	for(pair<int,ll> item : mp){
		ans += item.second * (item.second-1) / 2;
	}

	rep(i,N){
		cout << ans - (mp[A[i]]-1) << endl;
	}

	return 0;
}

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

int main() {
  ll N,ans=0,r,w;
  cin >> N;
  string c;
  cin >> c;
  rep(i,N){
    if(c[i]=='R') r++;
    else w++;
  }
  rep(i,r){
    if(c[i]=='W') ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;
typedef long long ll;

#define N 1005
const int INF = 0x3f3f3f3f;

int a, b, c, x, y;

int main()
{
    cin >> a >> b >> c >> x >> y;
    int res1 = a * x + b * y;
    int res2 = min(x, y) * 2 * c;
    if (x > y)
    {
        res2 += (x - y) * a;
    }
    else
    {
        res2 += (y - x) * b;
    }
    int res3 = max(x,y)*2*c;
    cout<<min(res1,min(res2,res3))<<endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
cnt = sum([1 for i in a if i < 0])
if cnt%2:
  r = 10**9
  for i in range(n):
    r = min(r,abs(a[i]))
  print(sum([abs(x) for x in a])-2*r)  
else:
  print(sum([abs(x) for x in a]))

Measured memory_bytes: 20048
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
int cmp3(T lhs, T rhs) { return (lhs == rhs) ? 0 : (lhs > rhs) ? 1 : -1; }

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

void solve(lli N, lli M, lli X, vector<lli> const &C, vector<vector<lli>> const &A) {
  lli ans = infty<lli>;
  for (lli s = 0; s < (1LL << N); ++s) {
    vector<lli> score(M, 0);
    bitset<14> S(s);
    lli val = 0;
    REP(i, N) {
      if (!S[i]) { continue; }
      val += C[i];
      REP(j, M) {
        score[j] += A[i][j];
      }
    }
    if (all_of(begin(score), end(score), [X](lli x) { return x >= X; })) {
      chmin(ans, val);
    }
  }
  cout << (ans == infty<lli> ? -1 : ans) << endl;
}

int main() {
  // cout << fixed << setprecision(10);

  lli N, M, X;
  cin >> N >> M >> X;
  vector<lli> C;
  vector<vector<lli>> A;
  REP(i, N) {
    lli c; cin >> c; C.push_back(c);
    vector<lli> row;
    REP(j, M) {
      lli a; cin >> a;
      row.push_back(a);
    }
    A.push_back(row);
  }
  solve(N, M, X, C, A);
  return 0;
}


Measured memory_bytes: 3636
N = int(input())
A = list(map(int,input().split()))
A.sort()
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
input = sys.stdin.readline # 文字列の入力のとき'/n'まで受け取るので注意!!!
sys.setrecursionlimit(500000)
mod = 10**9+7
D = Counter(A)
if N%2==0:
    ans = 1
    for i,k in enumerate(D.keys()):
        if D[k]==2:
            ans = ans*2%mod
        else:
            ans = 0
            break
    print(ans)


else:
    ans = 1
    for i,k in enumerate(D.keys()):
        if i==0 and D[k]==1:
            continue
        elif i==0:
            ans = 0
            break
        elif D[k]==2:
            ans = ans*2%mod
        else:
            ans = 0
            break
    print(ans)






Measured memory_bytes: 55532
#include <stdio.h>

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

    int x, y, z;
    for (int i = 0; i < times; i++)
    {
        scanf("%d %d %d", &x, &y, &z);
        if (x * x + y * y == z * z ||
            y * y + z * z == x * x ||
            z * z + x * x == y * y)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};


int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;
    string s; cin>>s;
    ll q; cin>>q;

    vint ruiM(n+1, 0);
    rep(i,n) ruiM[i+1] = ruiM[i] + (ll)(s[i] == 'M');



    while(q-->0){
        ll k; cin>>k;
        ll left = -k;
        ll right = 0;
        vint cnt(2,0);
        ll ans = 0;

        while(right < n){
            if(left >= 0){
                if(s[left] == 'D'){
                    cnt[0]--;
                    cnt[1] -= ruiM[right] - ruiM[left+1];
                }
            }
            if(s[right] == 'D'){
                cnt[0]++;
            }else if(s[right] == 'M'){
                cnt[1] += cnt[0];
            }else if(s[right] == 'C'){
                ans += cnt[1];
            }
            left++;
            right++;
        }
        cout<<ans<<endl;
    }

    return 0;

}

Measured memory_bytes: 9220
q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]
Q = 10**5 + 1

# エラトステネスの篩
prime = [False] * Q
like2017 = [0] * Q
for i in range(2, Q):
    if not prime[i]:
        for j in range(i*2, Q, i):
            prime[j] = True

# 2017っぽい数
for i in range(3, Q, 2):
    if not prime[i] and not prime[(i+1)//2]:
        like2017[i] += 1
for i in range(3, Q):
    like2017[i] += like2017[i-1]

for i in range(q):
    print(like2017[lr[i][1]] - like2017[lr[i][0]-1])

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}
const int FACT_SIZE=1111111;
int fact[FACT_SIZE];
int inv[FACT_SIZE];
struct fact_exec{
    fact_exec(){
        fact[0]=1;
        for(int i=1;i<FACT_SIZE;i++)fact[i]=fact[i-1]*i%mod;
        inv[FACT_SIZE-1]=mpow(fact[FACT_SIZE-1],mod-2);
        for(int i=FACT_SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    }
}factexec;
int nCk(int n,int k){
    return fact[n]*inv[k]%mod*inv[n-k]%mod;
}
int nPk(int n,int k){
    return fact[n]*inv[n-k]%mod;
}

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

    if(B%2){
        cout<<0<<endl;
        return 0;
    }

    int ans=0;
    for(int i=0;i<=A;i++){
        for(int l=0;l*3<=C;l++){
            int j=B/2;
            int k=A-i;

            int x=C-k-3*l;
            if(x<0)continue;
            if(j==0&&x>0)continue;
            int tmp=fact[i+j+k+l]*inv[i]%mod*inv[j]%mod*inv[k]%mod*inv[l]%mod;
            if(j)tmp=tmp*nCk(x+j-1,j-1)%mod;
            add(ans,tmp);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{

  int n;
  cin>>n;

  if(n%2!=0)
  {
    double ans=(n/2+1)/(double)n;
    cout<<ans<<endl;
  }
  else
  {
    double ans=(n/2)/(double)n;
    cout<<ans<<endl;
  }
    
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int a,b,c;

int main(){
    cin>>a>>b>>c;
    out((a+b)*c/2);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

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

typedef pair<int, int> P;

int main(){
    int n;
    cin >> n;
    vector<P> red(n), blue(n);
    for (int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        red[i] = P(a, b);
    }
    for (int i = 0; i < n; i++){
        int c, d;
        cin >> c >> d;
        blue[i] = P(c, d);
    }
    
    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());

    bool used[110];
    fill(used, used + 110, false);
    int ans = 0;
    for (int i = 0; i < n; i++){
        int maxy = -1, index = -1;
        for(int j = 0; j < n; j++){
            if (red[j].first >= blue[i].first) break;

            if (red[j].second < blue[i].second && !used[j]){
                if (red[j].second > maxy){
                    maxy = red[j].second;
                    index = j;
                }
            }
        }
        if (index != -1){
            ans++;
            used[index] = true;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 *    Author:  "Robin Singh" !!!!    
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     // 0 -> n-1 (i,0,n)
#define bk(i, j, k) for(int i = j-1; i >= k; i--)  // n-1 -> 0 (i,n,0)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0 //
#define rtn return 
#define itt(a)   __typeof((a).begin())
#define RT  (cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n")  // Run Time
#define nl "\n"  // New Line
#define dbg(x) (cerr << #x << " = " << x << "  ")
#define enl (cerr << "\n")
#define dbgg(x,y) (cerr << #x << " = " << x << " -> " << #y << " = " << y << "\n")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const ld eps = 1e-9;
const int inf = (1<<30);
const ll INF = (1LL<<61);

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll n, ans = 0;
    cin >> n;
    ll a[n+1];
    for(int i=1; i<=n; i++){
        cin >> a[i];
        a[i] -= i;
    }
    // min deviation
    // mean is not the answer, median is the answer
    // if n is even both n/2 and n/2+1 are median, take any
    sort(a+1, a+n+1);
    ll b = a[n/2 + 1];
    for(int i=1; i<=n; i++)
        ans += abs(a[i]-b);
    cout << ans;
    return 0;
}

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

void lcs( string X, string Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  
   int index = L[m][n]; 
  
   char lcs[index+1]; 
   lcs[index] = 0; 
  
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; 
          i--; j--; index--;     
      } 
  
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
   cout <<lcs; 
} 
int main() 
{ 
    string x,y;
    cin>>x>>y;
  
    int m = x.length(); 
    int n = y.length(); 
  
    lcs(x, y, m, n); 
  
    return 0; 
} 

Measured memory_bytes: 35456
#include <iostream>
#include <string>
using namespace std;
int main() {
    int N, cnt = 0, ans = 0;
    string S;
    cin >> N >> S;
    for (char c : S) {
        if (c == 'I') cnt++;
        else cnt--;
        if (cnt > ans) ans = cnt;
    }
    cout << ans << endl;
}


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

struct fun
{
    int a;
    int b;
    int c;
};

int main()
{
    int n;
    cin >> n ;
    fun arr[n];
    int x,y,z;
    for(int i=0;i<n;++i)
    {
        cin >> x >> y >> z;
        arr[i].a = x;
        arr[i].b = y;
        arr[i].c = z;
    }

    int dp[n][3];
    dp[0][0] = arr[0].a;
    dp[0][1] = arr[0].b;
    dp[0][2] = arr[0].c;

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

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


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int l = (s[0] - '0') * 10 + (s[1] - '0');
    int r = (s[2] - '0') * 10 + (s[3] - '0');
    if(l > 12 || l == 0)
    {
        if(r > 12 || r == 0)
        {
            cout << "NA" << endl;
            return 0;
        }
        else
        {
            cout << "YYMM" << endl;
            return 0;
        }
    }
    else
    {
        if(r > 12 || r == 0)
        {
            cout << "MMYY" << endl;
        }
        else
        {
            cout << "AMBIGUOUS" << endl;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
  int n;cin>>n;
  
  vector<int> vec(n);
  
  rep(i,n) cin>>vec[i];
  
  vector<int> dp(n);
  dp[0]=0;dp[1]=abs(vec[1]-vec[0]);
  
  for (int i=0;i<n-2;i++) {
    dp[i+2]=min(dp[i]+abs(vec[i+2]-vec[i]),dp[i+1]+abs(vec[i+2]-vec[i+1]));
  }
  
  cout<<dp[n-1]<<endl;
  
}

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

int main(void) {
	int a,b,c;
	int res = 0;
  cin >> a >> b >> c;
	int min = 0;
	if(a <= b && a <= c){
		if(b < c) res += b-a + c-b;
		else res += c-a + b-c;
	}else if(b <= a && b <= c){
		if(a < c) res += a-b + c-a;
		else res += c-b + a-c;
	}else{
		if(a < b) res += a-c + b-a;
		else res += b-c + a-b;
	}
	cout << res << "\n";
	return 0;
}


Measured memory_bytes: 256
c = [list(map(int,input().split())) for _  in range(3)]
l = []
for i in c:
  l += i
if l[0]+l[4]==l[1]+l[3] and l[1]+l[5]==l[2]+l[4] and l[3]+l[7]==l[4]+l[6] and l[4]+l[8]==l[5]+l[7]:
  print('Yes')
else:
  print("No")

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

N=int(input())
S=input().strip()

# Rolling Hash
LEN=len(S)

p=26# 文字の種類
mod=(1<<50)+1# Hashがぶつからない, pと互いに素な数を適当に指定

TABLE=[0]# Rolling Hashのテーブル. 最初は0

for i in range(LEN):
    TABLE.append((p*TABLE[-1]%mod+ord(S[i])-97)%mod)# テーブルを埋める

def hash_ij(i,j): # [i,j)のハッシュ値を求める
    return (TABLE[j]-TABLE[i]*pow(p,j-i,mod))%mod


MIN=0
MAX=LEN//2

from collections import defaultdict

while MIN!=MAX:
    x=(MIN+MAX+1)//2
    DICT=defaultdict(list)

    for i in range(LEN-x+1):
        DICT[hash_ij(i,i+x)].append(i)

    #print(DICT,MIN,MAX,x)

    for l in DICT:
        if max(DICT[l])-min(DICT[l])>=x:
            MIN=x
            break
    else:
        MAX=x-1

print(MIN)
        
        


Measured memory_bytes: 4596
import java.util.*;

public class Main {

    static int MOD = 1000000007;
    public static void main(String[] args) {

        int ans=0;
        Scanner sc = new Scanner(System.in);
      //  int a=sc.nextInt(),b=sc.nextInt();
        int n=sc.nextInt(),m=sc.nextInt();
      //  String s=sc.next();



        System.out.println(n==m?"Yes":"No");

    }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,c=0;
    string s;
    cin>>n;
    getchar();
    getline(cin,s);
    for(i=0;i<n;i++)
    {
        if(s[i]==s[i+1])
        {
            s[i]='0';
        }
    }
    for(i=0;i<n;i++)
    {
        if(s[i]!='0')
        {
         c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 512
p=0
q=0
t=0
while line = STDIN.gets
  line.chomp!
  if line == '0,0' then break end
  x,y = line.split(',').map { |item| item.to_i }
  n = t * Math::PI / 180.0
  p += x * Math.sin(n)
  q += x * Math.cos(n)
  t += y.to_i
end

puts p.to_i
puts q.to_i

Measured memory_bytes: 8840
#include<bits/stdc++.h>
using namespace std;
char a[4]={'A','T','G','C'};
string s;
bool ok(char c){
	for(int i=0;i<4;i++) if(c==a[i]) return true;
	return false;
}
int main(){
	cin>>s;    
	int cnt=0,maxn=0;
	for(int i=0;i<=s.size()-1;i++){
		cnt=0;
		while(ok(s[i])){
			cnt++;
			i++;
		}
		maxn=max(maxn,cnt);
	}
	cout<<maxn<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int intersection_single(double p[])
{
    if (p[0] <= p[2] && p[2] <= p[1]){
        return 1;
    }
    if (p[0] <= p[3] && p[3] <= p[1]){
        return 1;
    }
    if (p[2] <= p[4] && p[4] <= p[3]){
        return 1;
    }
    if (p[2] <= p[4] && p[4] <= p[3]){
        return 1;
    }
    return 0;
}

int main(void)
{
    double x[4], y[4];

    while (~scanf("%lf %lf", x, y)){
        int i;

        for (i = 1; i < 4; i++) scanf("%lf %lf", x + i, y + i);
        puts(intersection_single(x) && intersection_single(y) ? "YES" : "NO");
    }

    return 0;
}

Measured memory_bytes: 612
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;
const int MAX = 200000;
const int MOD = 1000000007;

map<int, int> prime_factors(int n) {
    map<int, int> res;
    if(n == 1) { // n=1 の素因数分解は n^1
        res[n] = 1;
        return res;
    }
    for(int i = 2, _n = n; i*i <= _n; ++i) {
        while(n % i == 0) {
            ++res[i]; // 素数i^{res[i]}
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
   int N, M;
   cin >> N >> M;
   COMinit();
   
   map<int, int> res = prime_factors(M);
   long long ans = 1;
   if (M == 1) {
      cout << ans << endl;
      return 0;
   }
   for(map<int, int>::iterator it = res.begin(), end = res.end(); it != end; ++it) {
      // cout << it->first << "^" << it->second << endl;
      int tmp = it->second;
      ans *= COM(tmp + N - 1, N - 1);
      ans %= MOD;
   }
   cout << ans << endl;
   return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define PI (acos(-1))

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = 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; }

int L[2005][2005];
int R[2005][2005];
int D[2005][2005];
int U[2005][2005];

signed main()
{
  int h,w; cin>>h>>w;
  vector<string> S(h+1);
  rep(i,h) {
    cin>>S[i];
    S[i].push_back('#');
  }
  
  // L
  rep(i,h){
    rep(j,w){
      if(S[i][j]=='#') L[i][j]=0;
      else if(j==0) L[i][j]=1;
      else L[i][j]=L[i][j-1]+1;
    }
  }
  
  // R
  rep(i,h){
    for(int j=w-1;j>=0;j--){
      if(S[i][j]=='#') R[i][j]=0;
      else if(j==w-1) R[i][j]=1;
      else R[i][j]=R[i][j+1]+1;
    }
  }
  
  // D
  rep(i,w){
    rep(j,h){
      if(S[j][i]=='#') D[j][i]=0;
      else if(j==0) D[j][i]=1;
      else D[j][i]=D[j-1][i]+1;
    }
  }
  
  // U
  rep(i,w){
    for(int j=h-1;j>=0;j--){
      if(S[j][i]=='#') U[j][i]=0;
      else if(j==h-1) U[j][i]=1;
      else U[j][i]=U[j+1][i]+1;
    }
  }
  
  int ans=0;
  rep(i,h){
    rep(j,w){
      chmax(ans, R[i][j]+L[i][j]+D[i][j]+U[i][j]-3);
    }
  }
  cout<<ans<<endl;
  
}


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

int main() {	
	int N;
	cin >> N;
	vector<vector<vector<int>>> data(4, vector<vector<int>>(3, vector<int>(10)));
	for (int i = 0; i < N; i++)
	{
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		data.at(b - 1).at(f - 1).at(r - 1) += v;
	}
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
				cout << ' ' << data.at(i).at(j).at(k);
			cout << endl;
		}
		if (i < 3)
			cout << "####################" << endl;
	}
}



Measured memory_bytes: 3176
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

now = 1
visited = []
visited_set = set()

for i in range(1, K+1):
    visited.append(now)
    visited_set.add(now)
    now = A[now]
    if now in visited_set:
        loop_start = visited.index(now)
        loop_length = i - loop_start
        print(visited[loop_start + (K - loop_start) % loop_length])
        break
else:
    print(now)


Measured memory_bytes: 122796
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    void Calc()
    {
        cin = new Scanner();

        int n = cin.nextInt();

        //int[] c = new int[n + 1];
        int[] colorFound = new int[200001];
        int[] jumpPoint = new int[n + 1];
        int[] pointUp = new int[n + 1];

        for (int i = 1; i <= n; ++i)
        {
            int color = cin.nextInt();
            //c[i] = color;

            if (colorFound[color] != 0 &&
                colorFound[color] != i - 1)
            {
                jumpPoint[colorFound[color]] = i;
            }
            colorFound[color] = i;
        }

        int dp = 0;

        for (int i = 1; i <= n; ++i)
        {
            dp += pointUp[i];
            dp %= 1000000007;

            if (jumpPoint[i] != 0)
            {
                int dp_ = (pointUp[jumpPoint[i]] + dp + 1) % 1000000007;
                pointUp[jumpPoint[i]] = dp_;
            }
        }

        dp += 1;
        dp %= 1000000007;

        Console.WriteLine(dp);
    }

}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 17376
# coding: utf-8

N, X = map(int, input().split())
L_list =  [int(i) for i in input().split()]
total_dis = 0
counter = 1

for i in range(1, N + 1):
    total_dis += L_list[i - 1]
    if total_dis <= X:
        counter += 1
    else:
        break
print(counter)


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

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> con(M);

  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int A;
      cin >> A;
      con.at(A - 1)++;
    }
  }

  int ans = 0;

  for (int i = 0; i < M; i++) {
    if (con.at(i) == N) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];} 
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";} cout<<endl;
#define S second
#define F first
#define SZ(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const int  MOD = 1e9 + 7;
const int  N = 1e6 + 7;
const int  M = 1e4 ;

void solve(){
    ll n , d , a;
    cin>>n>>d>>a;
    vector<pair < ll , ll > > v(n);
    for(int i = 0 ; i < n ; i++){
        cin>>v[i].F>>v[i].S;
    }
    sort(v.begin(), v.end());
    queue< pair< ll , ll > > q;
    ll sum = 0;
    ll res = 0;
    for(int i = 0 ; i < n; i++){
        while(q.size() > 0 && q.front().F < v[i].F){
            sum -= q.front().S;
            q.pop();
        }
        v[i].S -= a * sum;
        if(v[i].S <= 0) continue;

        ll tmp = (v[i].S + a - 1) / a;
        res += tmp;
        q.push({v[i].F + 2 * d, tmp});
        sum += tmp;
    }
    cout<<res<<endl;
}	
 
int main(){
    ios::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

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

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;



int main() {
	speed;
	cout << fixed << setprecision(6);
	/*start*/
	int m;
	cin >> m;
	m = 24-m;
	abs(m);
	m += 24;
	c(m);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 1000
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}

#define rank Asdfiasofsad
class UF{
public:
  int V;
  vector<int> par,rank;
  UF(){}
  UF(int V):V(V),par(V),rank(V,0){for(int i=0;i<V;i++)par[i]=i;}
  
  int find(int x){
    assert(x < V);
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
  }
  
  void unite(int x,int y){
    x=find(x), y=find(y);
    if(x==y)return;
    if(rank[x]<rank[y])par[x]=y;
    else{
      par[y]=x;
      if(rank[x]==rank[y])rank[x]++;
    }
  }

  bool same(int x,int y){return find(x)==find(y);}
};

int n,m;
vector<int> G[N];

int used[N];
int dfs(int pos){
  if(used[pos]++) return 0;
  int res = G[pos].size() - 1;
  for(int to:G[pos]) res += dfs(to);
  return res;
}

signed main(){
  cin>>n>>m;
  UF uf(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b; a--,b--;
    G[a].push_back(b);
    uf.unite(a,b);
  }
  
  map<int,int> val;
  for(int i=0;i<n;i++){
    memset(used,0,sizeof(used));
    int v = dfs(i);
    if(val.count(uf.find(i))) Min(val[uf.find(i)],v);
    else val[uf.find(i)] = v;
  }

  int sum = 0;
  typedef pair<int,int> P;
  for(P p:val) sum += p.second+1;
  cout<<sum<<endl;
  
  return 0;
}

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

int main(){
  int N,c;
  c=0;
  cin>>N;
  double ans;
  for(int i=1;i<N+1;i++){
    if(i%2==1)c++;
  }
  ans=(double)c/(double)N;

  cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
 
namespace  Rextester 
{
    public class Program
    {
       public static void Main(string[] args)
      {
           int s, h, m;
           s = int.Parse(Console.ReadLine());
           h = s / 3600;
           s = s % 3600;
           m = s / 60;
           s = s % 60;
           Console.WriteLine(h + ":" + m + ":" + s);          
       }
    }
 }


Measured memory_bytes: 17948
#include <iostream>

using namespace std;
using ll = long long int;

int main(){
  ll N;
  cin>>N;
  
  ll ans = 1LL;
  for(ll i=2;i*i<=N;i++){
    if (N%i==0)
      ans = i;
  }
  cout<<(ans + N/ans - 2)<<endl;
 }


Measured memory_bytes: 384
import { isRegExp } from "util";

class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;

  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n:number):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n:number):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
  f(roop:number, callback:any){
    for(let i=0;i<roop;i++){
      callback(i);
    }
  };
  Yes(){
    console.log('Yes');
  }
  No(){
    console.log('No');
  }
  YES(){
    console.log('YES');
  }
  NO(){
    console.log('NO');
  }
}
const m = () => {
  const o = new AtCoder();
  let obj:any ={}
  let obj2:any ={}
  for(let i=0;i<9;i++){
    obj[o.n()] = i;
  }
  // 0 1 2
  // 3 4 5
  // 6 7 8
  let n=o.n()
  for(let i=0;i<n;i++){
    let t = o.n()
    if(obj[t] !== undefined){
      
      obj2[obj[t]] = 1;
    }
  }
  if(obj2[0]&&obj2[1]&&obj2[2]
    || obj2[3]&&obj2[4]&&obj2[5]
    || obj2[6]&&obj2[7]&&obj2[8]
    || obj2[0]&&obj2[3]&&obj2[6]
    || obj2[1]&&obj2[4]&&obj2[7]
    || obj2[2]&&obj2[5]&&obj2[8]
    || obj2[0]&&obj2[4]&&obj2[8]
    || obj2[2]&&obj2[4]&&obj2[6]
    ){
      o.Yes()
    }else{
      o.No()
    }
}
m();

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

int main () {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  
  ll n, k;
  cin >> n >> k;
  ll d = n / k;
  cout << min(abs(d*k-n), abs(k*(d+1)-n)) << endl;
}

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

int main() 
{
	int n,a,i;
	double p;
	scanf("%d",&n);
	a=0;
	for(i=1;i<=n;i++)
	{
		if(i%2==1)
		{
			a++;
		}
	}
	p=(double)a/n;
	printf("%.10lf",p);
	return 0;
}

Measured memory_bytes: 128
def main():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(2)]

    ans = 0
    for i in range(0, N):
        tmp = sum(A[0][:i+1])
        tmp += sum(A[1][i:])
        if tmp > ans:
            ans = tmp
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}

long long com(long long n,long long k){
	
}
long long getDigit(long long n){
	if(n==1)return 1;
	else return log10(n)+1;
}
class G{
	long long node;
	long long w;
	
};
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	long long K;
	cin>>s>>K;
	long long ans=0;
	long long ans2=0;
	if(s[0]==s[s.length()-1]){
		string ss=s;
		for(int i=1;i<s.length();i++){
			if(s[i]==s[i-1]){
				ans++;
				for(int q=0;q<27;q++){
						if(s[i+1]!=s[i]+q){
							s[i]+=q;
							break;
						}
				}
			}
		}
		//cout<<ans;
		ss+=ss;
		//ss+=ss[0];
		//cout<<ss;
		for(int i=1;i<ss.length();i++){
			if(ss[i]==ss[i-1]){
				ans2++;
				for(int q=0;q<27;q++){
						if(ss[i+1]!=ss[i]+q){
							ss[i]+=q;
							break;
						}
				}
			}
		}
		//cout<<ans<<ans2<<endl;;
		//if(K==1)cout<<ans<<endl;
		//cout<<ans2<<K<<ans;
		/*if(K%2==0){
			return -1;
		}*/
		if(K%2==1){
			cout<<ans2*(K/2)+ans;
			return 0;
		}
		cout<<(ans2-ans)*(K-1) + ans<<endl;
		return 0;
	}
	for(int i=1;i<s.length();i++){
		if(s[i]==s[i-1]){
			ans++;
			for(int q=0;q<27;q++){
					if(s[i+1]!=s[i]+q){
						s[i]+=q;
						break;
					}
			}
			//if(i+1==s.length())b=true;
		}
	}
	/*if(b){
		//cout<<"b"<<endl;
		long long an=0;
		sss+=sss;
		sss += sss[0];
		//cout<<sss<<endl;
		for(int i=0;i<sss.length();i++){
			if(sss[i]==sss[i-1]){
				an++;
				for(int q=0;q<27;q++){
					if(sss[i+1]!=sss[i]+q){
						sss[i]+=q;
						break;
					}
				}
				
			}
		}
		//cout<<sss;
		if(K%2==0)cout<<an*(K/2)<<endl;
		else cout<<an*(K/2) + ans-1<<endl;
		return 0;
	}*/
	ans*=K;
	cout<<ans<<endl;
}

	


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

int n, a, b, c, d;
string s;

int main() {
    cin >> n >> a >> b >> c >> d >> s;
    s = "#" + s + "#";
    auto chk = [&](int l, int r) {
        for (int i = l; i < r; i++) {
            if (s[i] == '#' && s[i + 1] == '#') return 0;
        }
        return 1;
    };
    if (!chk(a, c) || !chk(b, d)) {
        cout << "No\n"; return 0;
    }
    if (c < d) {
        cout << "Yes\n"; return 0;
    }
    bool flag = 0;
    for (int i = b; i <= d; i++) {
        if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
            flag = 1; break;
        }
    }
    cout << (flag ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 772
int a[10010];
int main(){
 int n,m;
 scanf("%d%d",&n,&m);
 for(int i=0;i<m;i++)scanf("%d",&a[i]);
 int s=0;
 for(int i=0;i<m;i++)s+=a[i];
 if(s>n){
 printf("-1\n");
 }else{
 printf("%d\n",n-s);
 }
 }


Measured memory_bytes: 1708
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))

unsigned GetDigit(unsigned num){
    return std::to_string(num).length();
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = 0;
    string ans2;
    int N,X;
    cin >> N >> X;
    int a[N];
    for(int i = 0;i < N;i++){
        cin >> a[i];
    }
    for(int i = 0;i < N;i++){
        if(X <= 0 || X - a[i] < 0){
            break;
        }
        X = X - a[i];
        ans++;
    }
    int i = 1;
    int *b = min_element(a,a + N);
    while(i > 0){
        if(X - *b < 0)
            break;
        X = X - *b;
      //  cout << X << endl;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256