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

using namespace std;

#define	EPS	1e-9

int n;
vector<pair<long long, long long> > p, m;

double calc(double t)
{
	double minx = 1e18, miny = 1e18, maxx = -1e18, maxy = -1e18;
	for (int i = 0; i < n; i++) {
		double x = p[i].first + t * m[i].first, y = p[i].second + t * m[i].second;
		minx = min(minx, x); maxx = max(maxx, x);
		miny = min(miny, y); maxy = max(maxy, y);
	}
	return (maxx - minx) * (maxy - miny);
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin >> n;
	for (int i = 0; i < n; i++) {
		long long x, y;
		string s;
		cin >> x >> y >> s;
		p.resize(n), m.resize(n);
		p[i] = make_pair(x, y);
		if (s[0] == 'R')      m[i] = make_pair(1, 0);
		else if (s[0] == 'L') m[i] = make_pair(-1, 0);
		else if (s[0] == 'U') m[i] = make_pair(0, 1);
		else if (s[0] == 'D') m[i] = make_pair(0, -1);
	}

	double l = 0, r = 1e9, ans = 1e18;
	for (int k = 0; k < 200; k++) {
		double m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
		double r1 = calc(m1), r2 = calc(m2);
		ans = min(ans, r1);
		ans = min(ans, r2);
		if (r1 > r2) l = m1;
		else r = m2;
	}
	cout << fixed << setprecision(15) << ans << endl;

	return 0;
}


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

using namespace std;

const int INF = 1 << 30;

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

  int dp[1001][1001];
  fill_n(*dp, 1001 * 1001, INF);
  for(int i = 0; i < 1001; i++) dp[i][0] = dp[0][i] = i;

  for(int i = 1; i <= S.size(); i++) {
    for(int j = 1; j <= T.size(); j++) {
      dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
      dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
      dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + (S[i - 1] != T[j - 1]));
    }
  }

  cout << dp[S.size()][T.size()] << endl;
}

Measured memory_bytes: 7088
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b != c) {
        cout << "Yes" << endl;
    } else if (a == c && b != c ) {
        cout << "Yes" << endl;
    } else  if (b == c && a != b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main(int argc, char** argv) {
  int a[5]{};
  for (int i = 0; i < 5; ++i) cin >> a[i];
  
  vector<int> v(5);
  iota(v.begin(), v.end(), 0);
  int ret = INT32_MAX;
  do {
    int t = 0;
    for(int i = 0; i < 5; ++i) {
      t += (t % 10) ? (10 - (t % 10)) : 0;
      t += a[v[i]];
    }
    ret = min(ret, t);
  } while(next_permutation(v.begin(), v.end()));
  cout << ret << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<vector<int> >  vec2int;
typedef vector<ll >     vecll;
typedef vector<string > vecstr;
typedef vector<bool > vecbool;
typedef vector<bool > vecbool;
////////////////////////////////////////////////
int main()
{
  int n, k; cin >> n >> k;
  int j = 0;
  double ans = 0;
  for(int i = 1; i <= n; i ++){
    if(k/i == 0){
      j = 0;
    }else{
      j = log2(k/i);
      j += (i*pow(2,j) != k);
    }
    // cout << j << endl;
    ans += 1/(double)(n*pow(2,j));
  }
  cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 256
import sys
import math
datasets = []
ans = []
while 1:
    n = int(input())
    if n == 0:
        break
    datasets.append(n)
for n in datasets:
    facts = []
    for x in range(1, int((math.sqrt(2*n)))+1 ):
        if 2*n%x == 0:
            facts.append(x)
    for x in reversed(facts):
        y = 2*n // x
        if (y-x)%2 == 1:
            ans.append((x, y))
            break
for i in range(len(datasets)):
    x = ans[i][0]
    y = ans[i][1]
    print("{} {}".format((y-x+1)//2, x))
    


Measured memory_bytes: 5872
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;


long long N, M,ans,A[100000],AA[100000];
string S,s;
bool h,k[101];

int main() {
	cin >> N;
	if(N%2==0)cout << (N/2)*(N/2) << endl;
	else cout<< ((N+1)/2)*(((N+1)/2)-1)<<endl;
	return 0;

}




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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int):
    for i in range(1,10):
        for j in range(i,10):
            if N == i*j:
                print(YES)
                return
    print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
H, W = map(int, input().split())
l = []
temp_l = [0]*H
for i in range(H):
    l.append(list(str(input())))

for i in range(H):
    flag = 1
    for j in range(W):
        if l[i][j] == '#':
            flag = 0
    if flag == 1:
        temp_l[i] = 1
        for j in range(W):
            l[i][j] = 0

for i in range(W):
    flag = 1
    for j in range(H):
        if l[j][i] == '#':
            flag = 0
    if flag == 1:
        for j in range(H):
            l[j][i] = 0


for i in range(H):
    for j in range(W):
        if temp_l[i] == 0:
            if not l[i][j] == 0:
                print(l[i][j], end='')
    if temp_l[i] == 0:
        print('')

Measured memory_bytes: 4724
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int m; cin >> m;
  long long ans = 0;
  vector<int> amari;
  while (m--) {
    int d; long long c; cin >> d >> c;
    while (c > 0) {
      if (c & 1) {
        amari.emplace_back(d);
        --c;
      }
      if (c == 0) break;
      ans += (c / 2) * (d + d >= 10 ? 2 : 1);
      d = d + d;
      if (d >= 10) d = (d / 10) + (d % 10);
      c /= 2;
    }
  }
  while (amari.size() > 1) {
    int a = amari.back();
    amari.pop_back();
    int b = amari.back();
    amari.pop_back();
    a += b;
    ++ans;
    if (a >= 10) {
      ++ans;
      a = (a / 10) + (a % 10);
    }
    amari.emplace_back(a);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 18664
from collections import defaultdict

n, s = map(int, input().split())
aa = tuple(sorted(map(int, input().split())))

MOD = 998244353
dp = [[0 for i in range(s + 1)] for j in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in range(s + 1):
        # 選ばない場合
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= MOD

        # j + a[i]を選んだ場合
        if j + aa[i] <= s:
            dp[i + 1][j + aa[i]] += dp[i][j]
            dp[i + 1][j + aa[i]] %= MOD
print(dp[n][s])

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

int main()
{
    string s;
    cin >> s;
    set<char> st;
    for (int i = 0; i < s.size(); i++)
        st.insert(s[i]);
    if (s.size() != st.size())
        cout << "no" << endl;
    else
        cout << "yes" << endl;

    return 0;
}

Measured memory_bytes: 256
def Hit(an_list,bn_list):
    n = 0
    for a in enumerate(an_list):
        for b in enumerate(bn_list):
            if a == b:
                n +=1
    return n

def Blow(an_list,bn_list):
    n = 0
    for an in an_list:
        for bn in bn_list:
            if an == bn:
                n +=1
    return n

while True:
    try:
        [a1,a2,a3,a4] = map(int,raw_input().split())
        [b1,b2,b3,b4] = map(int,raw_input().split())
    except EOFError:
        break
    
    an_list = [a1,a2,a3,a4]
    bn_list = [b1,b2,b3,b4]
    hit = Hit(an_list,bn_list)
    blow = Blow(an_list,bn_list)
    
    print "%d %d" % (hit,blow-hit)

Measured memory_bytes: 4236
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <climits>
using namespace std;

int mcm(vector<int>& p)
{
    vector<vector<int> > m(p.size() - 1, vector<int>(p.size() - 1));
    for (int i = 0; i < m.size(); i++) {
        m[i][i] = 0;
    }
/*
 * l == number of targets
 * i == left most of targets
 */
    for (int l = 2; l <= m.size(); l++) {
        for (int i = 0; i < m.size() - l + 1; i++) {
            int j = i + l - 1;
            m[i][j] = INT_MAX;
            for (int k = i; k < j; k++) {
                m[i][j] =
                    min(m[i][j],
                        m[i][k] + m[k + 1][j] + p[i] * p[k + 1] * p[j + 1]);
            }
        }
    }
    return m[0][m.size() - 1];
}

int main()
{
    int n;
    cin >> n;
    vector<int> p(n + 1);
    for (int i = 1; i < n + 1; i++) {
        cin >> p.at(i - 1) >> p.at(i);
    }
    cout << mcm(p) << endl;
    return 0;
}

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

n,m = map(int, input().split())
edge = [[] for i in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    a,b = a-1, b-1
    edge[a].append(b)
    edge[b].append(a)

s = set()
left = right = 0
s.add(0)

from collections import deque
q = deque()
q.append(0)

f_left = True
f_right = True
while f_left or f_right:
    if f_left:
        m = -1
        for to in edge[left]:
            if to not in s:
                m = to
        if m >= 0:
            left = m
            s.add(m)
            q.appendleft(m)
        else:
            f_left = False
    if f_right:
        m = -1
        for to in edge[right]:
            if to not in s:
                m = to
        if m >= 0:
            right = m
            s.add(m)
            q.append(m)
        else:
            f_right = False

print(len(q))
print(*[i+1 for i in list(q)])


Measured memory_bytes: 32036
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
string S,T;
vector<ll> A;


ll N,K,M;
ll B[100005];
ll ans;

int main() {
    cin >> N >> M;
    for(ll i=0;i<N;i++){
        ll a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    ll r = 200002;
    ll l = 2;
    ll s=0;
    ll k=0;
    while(r-l>0){
        s=(r+l)/2;
        k=0;
        for(ll i=0;i<N;i++){
            B[i] = A.end() - lower_bound(A.begin(),A.end(),s-A[i]);
            k+=B[i];
        }
        if(k==M){
            l = s;
            break;
        }else if(k<M){
            r = s;
        }else{
            if(r-l==1){
                break;
            }
            l = s;
        }
    }
    for(ll i=0;i<N;i++){
        ans+=2*B[i]*A[i];
    }
    ans+=(M-k)*l;
    cout << ans << endl;
    
}


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


int main(void){
    // Your code here!
    int N;
    cin >> N;
    int a[N];
    int mx = 0;
    int mn = INT_MAX;
    map<int,int> mp;
    for(int i = 0; i < N;i++){
        cin >> a[i];
        
        mp[a[i]-1]++;
        mp[a[i]  ]++;
        mp[a[i]+1]++;
        
        mx = max(mx,a[i]+1);
        mn = min(mn,a[i]-1);
    
    }
    
    int mpm = 0;
    
    for(int i = mn; i <=mx;i++){
        
        if(mp[i]>mpm){
            mpm = mp[i];
        }
    }
    cout << mpm << endl;
    // int cont = 0;
    // for(int i = 0; i <N;i++){
        
    //     if(a[i]==mpm || a[i]-1==mpm||a[i]+1==mpm)cont++;
        
    // }
    
    // cout << cont << endl;
}


Measured memory_bytes: 5376
#include <stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    int a[n];
    int i, flag;
    flag = 0;
    for(i=1; i<=n; i++){
        scanf("%d",&a[i]);
        if(a[i]!=i){
            flag++;
        }
    }
    if(flag<=2){
        printf("YES");
    }else{
        printf("NO");
    }
    return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N, A[202020], B[202020];
priority_queue<pll> Bpq;
ll i,j,k,ans;


int main(){
    scanf("%lld",&N);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    fornum(i,0,N){
        scanf("%lld", &B[i]);
        Bpq.push({B[i], i});
    }
    ans = 0;
    while(!Bpq.empty()){
        
        pll bp = Bpq.top();
        Bpq.pop();
        ll bi = bp.second;
        if(bp.first==A[bi]){
            continue;
        }
        
        //printf("%lld,%lld ", B[bi], nb);
        
        ll a = A[bi];
        a = min(a, B[(bi + N - 1) % N]);
        a = min(a, B[(bi + 1) % N]);
        ll b = B[(bi + N - 1) % N] + B[(bi + 1) % N];
        if((B[bi]-A[bi])/b==0){
            printf("-1");
            return 0;
        }
        ans+=(B[bi] - A[bi]) / b;
        ll nb = (B[bi] - A[bi]) % b + A[bi];
        B[bi] = nb;
        Bpq.push({nb, bi});
        
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 8944
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, z = 0;
    string s[22] = {};
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> s[i], s[i] = '#' + s[i] + '#';
    for (int i = 0; i <= m + 1; i++) s[0] += '#', s[n + 1] += '#';
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) if (s[i][j] == '.') {
        for (int k = 1; k <= n; k++) for (int l = 1; l <= m; l++) if (s[k][l] == '.') {
            int d[22][22] = {};
            d[i][j] = 1;
            queue<pii> q;
            q.push({i, j});
            while (!q.empty()) {
                int x = q.front().first, y = q.front().second;
                q.pop();
                if (s[x - 1][y] == '.' && !d[x - 1][y]) d[x - 1][y] = d[x][y] + 1, q.push({x - 1, y});
                if (s[x + 1][y] == '.' && !d[x + 1][y]) d[x + 1][y] = d[x][y] + 1, q.push({x + 1, y});
                if (s[x][y - 1] == '.' && !d[x][y - 1]) d[x][y - 1] = d[x][y] + 1, q.push({x, y - 1});
                if (s[x][y + 1] == '.' && !d[x][y + 1]) d[x][y + 1] = d[x][y] + 1, q.push({x, y + 1});
            }
            if (d[k][l]) z = max(z, d[k][l] - 1);
        }
    }
    cout << z;
}


Measured memory_bytes: 3612
import sys

sys.setrecursionlimit(10 ** 6)

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

dp = [float('inf')] * n


def rec(i):
    if i == 0:
        return 0
    if dp[i] < 100000000000:
        return dp[i]
    else:
        res = min(dp[i], rec(i - 1) + abs(h[i] - h[i - 1]))
        if i > 1:
            res = min(res, rec(i - 2) + abs(h[i] - h[i - 2]))
        dp[i] = res
        return res


print(rec(n - 1))

Measured memory_bytes: 94100
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n==1)
	cout<<"1"<<endl;
	else if(n>=2&&n<=3)
	cout<<"2"<<endl;
	else if(n>=4&&n<=7)
	cout<<"4"<<endl;
	else if(n>=8&&n<=15)
	cout<<"8"<<endl;
	else if(n>=16&&n<=31)
	cout<<"16"<<endl;
	else if(n>=32&&n<=63)
	cout<<"32"<<endl;
	else if(n>=64&&n<=100)
	cout<<"64"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long n,i,r,r1,t1,t2,t3,j;
	scanf("%lld",&n);
	r=n/500;
	t1=n%500;
	t2=t1/5;
	t3=r*1000+t2*5;
	printf("%lld",t3);
return 0;
}
	

Measured memory_bytes: 128
//Robs Code
/***********HEADER***************/
#include<bits/stdc++.h>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 10000007
#define mxval 1e9
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/***********MAIN******************/
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
    string s;
    cin>>s;
    cin>>k;
    for(i=0;i<n;i++){
        if(s[k-1]!=s[i]){
            cout<<"*";
        }else cout<<s[i];
    }
	return 0;
}
//.........


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono; 
#define ll long long
#define fo(i,v,e) for(v=i;v<e;v++)
#define pb(x) push_back(x)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first 
#define se second
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define sz(x) (int)x.size()
#define ull unsigned long long
#define vvi vector<vi>
#define vvl vector<vl>
#define vpi vector<pii>
#define vpl vector<pll>
ll mod = 1000000007;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x);
#else
#define deb(x...)
#endif
vector<ll> sieveOfErthnosis(ll n)
{
    vector<bool>flag(n+5,false);
    vector<ll>primes;
    for(int i=2;i*i<=n;i++)
    {
        if(!flag[i])
        {
            for(int j=i*i;j<=n;j+=i)
            {flag[j]=true;}
        }
    }
    for (int  i = 2; i < n+1; i++)
    {
        if(!flag[i])primes.pb(i);
    }
    return primes;
}
void init()
{
    
}
void solve()
{
   ll n,i,j,som = 0,p=1,fans=0;
   string s;cin>>s;
   n = sz(s);
   vl ans(2020,0);
   ans[0]++;
   for(int i=n-1;i>=0;i--)
   {
       som = (som + (s[i]-'0')*p)%2019;
       p*=10;
       p%=2019;
       ans[som]++;
   }
   for(auto x:ans)
   {
       fans += (x*(x-1));
   }
   cout<<fans/2<<endl;
}
int main()
{
    init();
    #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    #endif
    auto start = high_resolution_clock::now(); 
    int T = 1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
    auto stop = high_resolution_clock::now(); 
    auto duration = duration_cast<milliseconds>(stop - start); 
    #ifndef ONLINE_JUDGE
    // cout << "time taken : "<<duration.count()<<" ms" << endl;
     #endif
}


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

int main(){
  int n;std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  int ans=-1,tmp=1;
  for (int i = 0; i < n; i++) {
    if (tmp == 2) {
      ans = i;
      break;
    }
    tmp = a[tmp-1];
  }
  std::cout << ans << '\n';
}


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

using namespace std;
typedef long long ll;

const int N=3e5+10;
const int mod=998244353;
int n;
int k,m;
int a[N];
int b[N];

map<int,int> mp;
struct pp{
    int x;
    int y;
    int index;
}p[N];

int cmp(pp a, pp b){
    return a.x<b.x;
}
int num[N];
int ans[N];
int parent[N];
stack<int> s;
void Init()
{
    for(int i = 1;i <= n+10;i++){
        parent[i] = i;
        num[i]=1;
    }
    return;
}

int get_boss(int v)
{
    if(parent[v] == v)
        return v;
    else
    {
        //路径压缩(使搜索祖宗的过程中，路径中搜索的结点的父亲的变为祖宗)
        parent[v] = get_boss(parent[v]);
        return parent[v];
    }
}

void Merge(int v,int u) //u合并到v
{
    int t1 = get_boss(v);
    int t2 = get_boss(u);
    parent[t2] = t1;
    num[t1]+=num[t2];
    return;
}

int main()
{
    cin>>n;
    Init();
    for(int i=1;i<=n;i++){
        cin>>p[i].x>>p[i].y;
        p[i].index=i;
    }

    sort(p+1,p+1+n,cmp);
    for(int i=1;i<=n;i++){
        mp[p[i].y]=i;
    }



    for(int i=1;i<=n;i++){
        int mn=p[i].y;
        while(!s.empty()&&s.top()<p[i].y){
            Merge(mp[s.top()],mp[p[i].y]);
            mn=min(mn,s.top());
            s.pop();
        }
        p[i].y=mn;
        s.push(mn);
    }

    for(int i=1;i<=n;i++){
        ans[p[i].index]=num[get_boss(mp[p[i].y])];
    }
    for(int i=1;i<=n;i++)cout<<ans[i]<<endl;


}



Measured memory_bytes: 17648
n=gets.to_i
a=gets.split.map &:to_i
b=gets.split.map &:to_i
c=gets.split.map &:to_i
ans=b.sum
for i in 0..n-2
if a[i]+1 ==a[i+1]
  ans+=c[a[i]-1]
end
end
puts ans


Measured memory_bytes: 14332
from collections import Counter


n = int(input())
s = []
t = []
for i in range(n):
    s.append(input())
m = int(input())
for i in range(m):
    t.append(input())
s_cnt = Counter(s)
t_cnt = Counter(t)
ans_dict = {}
for key in s_cnt.keys():
    ans_dict[key] = s_cnt[key] - t_cnt[key]
print(max(max(ans_dict.values()), 0))

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

// 1-indexed
template <class T>
struct BIT {
  vector<T> lst;
  int treesize;
  // constructor
  BIT(int newn = 0) {
    treesize = newn;
    lst.resize(treesize + 1);
    for(int i = 0; i <= treesize; ++i) lst[i] = 0;
  }
  // a_place += num
  bool add(int place, T num) {
    while(place <= treesize) {
      lst[place] += num;
      place += place & -place;
    }
    return 1;
  }
  // add wide ver.(add num between l and r)
  bool addw(int left, int right, T num) {
    while(left <= right && left >= 1 && right <= treesize)
      add(left++, num);
    return 1;
  }
  // sum between [1,place]
  T calcsum(int place) {
    T answer = 0;
    while(place > 0) {
      answer += lst[place];
      place -= place & -place;
    }
    return answer;
  }
  // sum [l,r]
  T calcsumw(int left, int right) {
    return calcsum(right) - calcsum(left - 1);
  }
};

struct data {
  int q, x;
};

int q, lim;
vector<int> v;
BIT<int> bit;
map<int, int> mp;
vector<data> query;

void solve();
int bsearch(int x);

int main() {
  while(1) {
    cin >> q >> lim;
    if(q + lim == 0) break;
    query.resize(q);
    v.assign(1, -1);
    for(int i = 0; i < q; ++i) {
      cin >> query[i].q >> query[i].x;
      if(query[i].q == 0) {
        mp[query[i].x] = v.size();
        v.push_back(query[i].x);
      }
    }
    solve();
  }
  return 0;
}

void solve() {
  int sum = 0;
  bit = BIT<int>(v.size());
  for(int i = 0; i < q; ++i) {
    if(query[i].q == 0) {
      bit.add(mp[query[i].x], 1);
      if(bit.calcsum(v.size()) > lim + sum) ++sum;
    }
    else if(query[i].q == 1)
      bit.add(bsearch(query[i].x + sum), -1);
    else if(query[i].q == 2)
      cout << v[bsearch(query[i].x + sum)] << endl;
    else
      bit.add(mp[query[i].x], -1);
  }
  cout << "end" << endl;
}

int bsearch(int x) {
  int l = 0, r = v.size();
  while(r - l > 1) {
    int now = (l + r) / 2;
    if(bit.calcsum(now) >= x)
      r = now;
    else
      l = now;
  }
  return r;
}


Measured memory_bytes: 39492
#include <stdio.h>

int main(void)
{
	long a, b, d, r;
	double f;

	scanf("%ld %ld", &a, &b);
	
	d = a / b;
	r = a % b;
	f = (double) a / (double) b;

	printf("%ld %ld %lf\n", d, r, f);
}



Measured memory_bytes: 2100
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    string s;
    map<char, int> m;
    cin >> s;
    for (char c='a'; c<='z'; c++) {
        m[c] = 0;
    }
    for (char c: s) {
        m[c]++;
    }
    for (char c='a'; c<='z'; c++) {
        if (m[c] == 0) {
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(int a, int n) {//aのn乗を計算します。
	int x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;
vector<int> v;
map<int, int>mp;
int main() {
	int N;
	cin >> N;
	REP(i, N) {
		int A;
		cin >> A;
		v.push_back(A);
		mp[A]++;
	}
	VSORT(v);
	ll ans = 0;
	for (int i = 32; i > 0; i--) {
		REP(j, N) {
			if (mp[v[j]] > 0) {
				ll x = pow2(2, i) - v[j];
				if (binary_search(v.begin(), v.end(), x)) {
					if (v[j] == x) {
						if (mp[x] >= 2) {
							ans++;
							mp[x] -= 2;
						}
					}
					else {
						if (mp[x] >= 1) {
							ans++;
							mp[x]--;
							mp[v[j]]--;
						}
					}
				}
			}
		}
	}
	int cnt = 0;
	REP(i, 1000000000)cnt++;
	cout << ans << endl;
}

Measured memory_bytes: 10356
#include <iostream>
    using namespace std;
    #define rep(i,x,to) for(int i=x+1;i<=to;i++) 
     
    int main() {
    	int n,b,f,r,v,H[5][4][11]={};
    	cin>>n;
    	rep(i,0,n){
    		cin>>b>>f>>r>>v;
    		H[b][f][r] += v;
    	}
    	rep(i,0,4){
    		rep(j,0,3){
    			rep(k,0,10){
    				cout<<" "<<H[i][j][k];
    			}
    			cout << endl;
    		}
    		if(i!=4) cout<<"####################"<<endl;
    	
    	}
    	return 0;
    }


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

/**
 * 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);
        AButtons solver = new AButtons();
        solver.solve(1, in, out);
        out.close();
    }

    static class AButtons {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int ans1 = a + a - 1;
            int ans2 = b + b - 1;
            int ans3 = a + b;
            int max = Math.max(Math.max(ans1, ans2), ans3);
            out.println(max);
        }

    }

    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 int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define  all(A)         (A).begin() , (A).end()
#define  pb             push_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  forn(i, n)     for (int i = 0; i < int(n); i++)
#define  forr(i, n)     for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  deb(x)       cout << #x << ':' << x << endl;
double distance(int x1, int y1, int x2, int y2) 
{
    return (double)sqrt(pow(x2 - x1, 2) +  
                pow(y2 - y1, 2) * 1.0); 
} 
ll fact(int n)
{
    if(n==0)return 1;
    return n*fact(n-1);
}
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);

    
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        vector<int> v;
        map<int,pair<int,int> >m;
        fora(i,1,n)
        {
            v.pb(i);
            int a,b;
            cin>>a>>b;
            m[i]={a,b};
        }
        long double ans=0;
        do
        {

            forn(i,n-1)
            {
                ans+=distance(m[v[i]].first,m[v[i]].second,m[v[i+1]].first,m[v[i+1]].second);
            }
        }while(next_permutation(all(v)));
        ans=(double)ans/fact(n);
        cout<<fixed<<setprecision(10)<<ans<<endl;
    }
    
}

Measured memory_bytes: 384
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  constexpr auto none = numeric_limits<int>::max() / 2;
  int N, M, L;
  cin >> N >> M >> L;
  vector<vector<int>> graph(N + 1, vector<int>(N + 1, none));
  for (int i = 0; i < M; ++i) {
    int A, B, C;
    cin >> A >> B >> C;
    graph[A][B] = graph[B][A] = C;
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      for (int k = 1; k <= N; ++k) {
        graph[j][k] = min(graph[j][k], graph[j][i] + graph[k][i]);
      }
    }
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      graph[i][j] = graph[i][j] <= L ? 1 : none;
    }
  }
  for (int i = 1; i <= N; ++i) {
    graph[i][i] = 0;
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      for (int k = 1; k <= N; ++k) {
        graph[j][k] = min(graph[j][k], graph[j][i] + graph[k][i]);
      }
    }
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; ++i) {
    int s, t;
    cin >> s >> t;
    cout << (graph[s][t] == none ? -1 : graph[s][t] - 1) << endl;
  }
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF INT_MAX
#define LINF 1LL<<60

struct SegTree {
	int N;
	ll init_v = 0;
	vector<ll> node, lazy;

	SegTree(int _N) {
		N = 1;
		while (N < _N) N *= 2;
		node.resize(2 * N - 1, init_v);
		lazy.resize(2 * N - 1, init_v);
	}

	void lazy_evaluate(int k) {
		if (k >= N - 1)node[k] += lazy[k];
		if (k < N - 1) {
			lazy[2 * k + 1] += lazy[k] / 2;
			lazy[2 * k + 2] += lazy[k] / 2;
		}
		lazy[k] = 0;
	}

	/* [a,b) ?????°??????????????¨???!! s~t?????§?????´??°???update(s,t+1,~) */
	void update(int a, int b, int x) { update(a, b, 0, 0, N, x); }
	void update(int a, int b, int k, int l, int r, int x) {
		if (r <= a || b <= l) return;
		if (a <= l && r <= b) {
			lazy[k] += (r - l)*x;
			lazy_evaluate(k);
		}
		else {
			lazy_evaluate(k);
			update(a, b, 2 * k + 1, l, (l + r) / 2, x);
			update(a, b, 2 * k + 2, (l + r) / 2, r, x);
		}
	}

	/* [a,b) ?????°??????????????¨???!! */
	ll query(int a, int b) { return query(a, b, 0, 0, N); }
	ll query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return init_v;
		if (a <= l && r <= b) {
			lazy_evaluate(k);
			return node[k];
		}
		else {
			lazy_evaluate(k);
			ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
			ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
			return max(vl, vr);
		}
	}
};

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	SegTree ST(n);
	for (int i = 0; i < q; i++) {
		int com; cin >> com;
		if (com == 0) {
			int s, t, x; cin >> s >> t >> x;
			s--; t--;
			ST.update(s, t + 1, x);
		}
		else {
			int j; cin >> j; 
			j--;
			cout << ST.query(j, j + 1) << endl;
		}

		//cout << "-----------------------------------" << endl;
		//for (auto X : ST.node) {
		//	cout << X << " ";
		//}
		//cout << endl;
		//for (auto Y : ST.lazy) {
		//	cout << Y << " ";
		//}
		//cout << endl;
		//cout << "==================================" << endl;
	}
}

Measured memory_bytes: 7060
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, n;
  cin >> a >> b >> n;
  int count = 0;
  for (int i = a; i <= b; i++) {
    if (i % n == 0) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
  int N[2];
  cin >> N[0] >> N[1];

  int sum = 0;
  sort(N, N+2);
  sum += N[1]--;
  sort(N, N+2);
  sum += N[1]--;




  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <utility>
#include <tuple>
using namespace std;

using Graph = vector< vector<int> >;

void read_field(vector<char> &board, Graph &G) {
  int N, M; cin >> N >> M;
  board.resize(N);
  G.resize(N);

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

  for(int i=0; i<M; i++) {
    int u, v; cin >> u >> v;
    u--; v--;

    // directed !!!
    G[u].push_back(v);
  }
}

int rec[110][110];
struct Elem {
  int u1, u2, cost;
};

int main() {
  vector<char> A_char, B_char;
  Graph A_Graph, B_Graph;
  read_field(A_char, A_Graph);
  read_field(B_char, B_Graph);

  bool operate_inf = false;
  int N1 = A_char.size(), N2 = B_char.size();

  queue< Elem > que;

  // equal
  for(int i=0; i<N1; i++) {
    for(int j=0; j<N2; j++) {
      if(A_char[i] == B_char[j]) {
        rec[i][j] = 1;
        que.push(Elem{i, j, 1});
      }
    }
  }

  while(que.size()) {
    int u1, u2, p_cost;

    u1 = que.front().u1;
    u2 = que.front().u2;
    p_cost = que.front().cost;
    que.pop();
    
    if(p_cost < rec[u1][u2]) continue;
    if(rec[u1][u2] > N1 + N2) {
      operate_inf = true;
      break;
    }
    else {
      // move (both)
      for(auto v1 : A_Graph[u1]) {
        for(auto v2 : B_Graph[u2]) {
          char c1 = A_char[v1], c2 = B_char[v2];

          int cost = 0;
          if(c1 == c2) {
            cost = p_cost + 1;
          }
          else {
            cost = p_cost;
          }

          if(rec[v1][v2] < cost) {
            rec[v1][v2] = cost;
            que.push(Elem{v1, v2, cost});
          }
        }
      }

      if(A_char[u1] != B_char[u2]) {  
        // move (A)
        for(auto v1 : A_Graph[u1]) {
          int v2 = u2;

          char c1 = A_char[v1], c2 = B_char[v2];

          int cost = 0;
          if(c1 == c2) {
            cost = p_cost + 1;
          }
          else {
            cost = p_cost;
          }

          if(rec[v1][v2] < cost) {
            rec[v1][v2] = cost;
            que.push(Elem{v1, v2, cost});
          }
        }

        // move (B)
        for(auto v2 : B_Graph[u2]) {
          int v1 = u1;

          char c1 = A_char[v1], c2 = B_char[v2];

          int cost = 0;
          if(c1 == c2) {
            cost = p_cost + 1;
          }
          else {
            cost = p_cost;
          }

          if(rec[v1][v2] < cost) {
            rec[v1][v2] = cost;
            que.push(Elem{v1, v2, cost});
          }
        }
      }
    }
  }

  if(operate_inf) {
    cout << -1 << endl;
    return 0;
  }
  
  int ans = 0;
  for(int i=0; i<N1; i++) {
    for(int j=0; j<N2; j++) {
      // printf("%d ", rec[i][j]);
      ans = max(ans, rec[i][j]);
    }
    // cout << endl;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3308
#include<stdio.h>
 
int main(){
	int a[3], b, i, j, e = 0, f = 0, g = 0, h = 0;
	while(scanf("%d %d %d", &a[0], &a[1], &a[2]) != EOF){
		for(i = 0; i < 2; i++){
			for(j = i + 1; j < 3; j++){
				if(a[i] < a[j]){
					b = a[i];
					a[i] = a[j];
					a[j] = b;
				}
			}
		}
		if(a[0] >= a[1] + a[2]) break;
		else e++;
		if(a[0] * a[0] > a[1] * a[1] + a[2] * a[2]) f++;
		else if(a[0] * a[0] == a[1] * a[1] + a[2] * a[2]) g++;
		else h++;
	}
	printf("%d %d %d %d\n", e, g, h, f);
	return 0;
}

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

using namespace std;
using llint = long long;
using pint = pair<int,int>;

#define LOG(x) cout << "# " << #x <<" => "<< (x) <<endl

const int INF = 1<<28;
const llint LLINF = 1LL<<60;

string s;
bool flag;

int main() {
    // Input
    cin >> s;

    if (((s.at(0)==s.at(1) && s.at(2)==s.at(3)) || (s.at(0)==s.at(2) && s.at(1)==s.at(3)) || (s.at(0)==s.at(3) && s.at(1)==s.at(2))) 
        && !(s.at(0)==s.at(1) && s.at(1)==s.at(2) && s.at(2)==s.at(3)))
    {
        flag = true;
    } else {
        flag = false;
    }
    
    // Output
    if (flag)
    {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define ll long long
#define sz size()
#define all(x) x.begin(), x.end()
#define forn(x) for(int i=1;i<=x;i++) 
#define sforn(x, y) for(int i=1;i<=x;i++)for(int j=1;j<=y;j++)
#define pii pair<int, int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

/*
    LOL KEK CHEBUREK
 
    PIHALITI
 
 */

int main(){ speed;
    int n;
    cin >> n;
    if(n%2 == 0){
        cout << fixed << setprecision(10) <<  0.5 << endl;
    } else {
        cout << fixed << setprecision(10) <<  double(((n)/2) + 1) / double(n) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt(), a[] = new int[n], sum = 0, cnt = 0;
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            sum += a[i];
        }
        if (sum % (4 * m) == 0)
            sum /= (4 * m);
        else {
            sum = sum / (4 * m) + 1;
        }
        for (int i = 0; i < n; i++) {
            if (a[i] >= sum)
                cnt++;
        }
        if (cnt >= m)
            System.out.println("Yes");
        else {
            System.out.println("No");
        }
    }

}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

const int N_MAX = 105;

class Stack
{
    int array[N_MAX];
    int top;

public:
    Stack() : top(0) {}

    void push(int value)
    {
        if (top > N_MAX - 1)
        {
            cout << "Full!" << endl;
        }
        array[top++] = value;
    }

    int pop()
    {
        if (top == 0)
        {
            cout << "The size is 0!" << endl;
            return -1;
        }
        return array[--top];
    }

    int size()
    {
        return top;
    }
};

int main()
{
    char c[10];
    int v1, v2;
    Stack stack;
    while (scanf("%s", &c) != EOF)
    {
        if (c[0] == '+')
        {
            v2 = stack.pop();
            v1 = stack.pop();
            stack.push(v1 + v2);
        }
        else if (c[0] == '-')
        {
            v2 = stack.pop();
            v1 = stack.pop();
            stack.push(v1 - v2);
        }
        else if (c[0] == '*')
        {
            v2 = stack.pop();
            v1 = stack.pop();
            stack.push(v1 * v2);
        }
        else
        {
            stack.push(atoi(&c[0]));
        }
    }

    cout << stack.pop() << endl;
}


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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
#define int long long

signed main(){
    string n; cin >> n;
    cout << (n[0]=='9' || n[1]=='9' ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#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>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e6+26;

//write function from here ...

vector <  int > arr;



void prime () {
	
	bool vis[maxx];
	memset ( vis, 0 , sizeof (vis) );
	
	for (  ll i = 2; i*i <=maxx; i++){
		
		
		if( vis[i] == 0 ){
			
			for( ll j = i*i; j<maxx ; j+= i){
				
				vis[j] =1 ;
				
			}
			
		} 
		
		
	}
	
	for ( int i= 2; i < maxx; i++){
		
		if( vis[i]== 0){
			arr.pb( i);
		}
		
	}
	
	
}




int Main(){

prime();
ll  a,b;
cin>>a>>b;


int nn = arr.size();


ll temp  =a;
int  i = 0 ;
set < ll > st ;
map< ll , int   > mp1 ,mp2;

//int j = 0 ;
 //for(auto it : arr ) {
	 //if( j > 100)
	 //break;
     //else
     //{cout<<it<<" ";j++;
	 //}
	//}
while(i < nn  && temp > 1){
	if( temp%arr[i]==0)
	{
		mp1[arr[i]]= 1;
		st.insert( arr[i]);
	}
	while(temp%arr[i] == 0 )
	{
		
		temp/=arr[i];
		
	}
	
	i++;
	
	
}
if(temp > 1)
{
	mp1[temp ] = 1;
	st.insert(temp);
} 

temp = b;
i =0 ;

while(i < nn && temp > 1){
	if( temp%arr[i]==0){
	mp2[arr[i]]= 1;
	st.insert(arr[i]);
}
	
	while(temp%arr[i] == 0 )
	{
		
		temp/=arr[i];
		
	}
	
	i++;
	
	
}
if(temp > 1)
{
	mp2[temp ] = 1;
	st.insert(temp);
}

int cnt =1;

for( auto it : st ) {
	
	
	if(mp1 [it]  && mp2[it] ){
	cnt++;
	} 
	
}


cout<<cnt<<endl;


return 0;

}






int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 6140
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long  t,r=1,r1=0,r2=0,k=0,a,b,c=0,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    vector<tuple<string,int,
           int>>mp;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    //cin>>a>>b>>c>>d>>e>>k;
    l(i,0,5)
    {
        cin>>a;
        v.pb(a);
    }
    cin>>k;
    l(i,0,5)
    {
        l(j,i,5)
        {
            u.pb(abs(v[i]-v[j]));
        }
    }
    hi(u);
    (u[0]>k)?cout<<":(":cout<<"Yay!";


}


Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}

vector<vector<char>> a;
int h,w;

bool check(int i,int j){
	rep(x,4){
		if(i+dx[x]>=0 && i+dx[x]<h && j+dy[x]>=0 && j+dy[x]<w){
			if( a[i+dx[x]][j+dy[x]]=='#')return 1;
		}
	}
	return 0;
}


int main(){
	cin>>h>>w;
	a.resize(h);
	rep(i,h){
		a[i].resize(w);
		rep(j,w){
			cin>>a[i][j];
		}
	}
	rep(i,h){
		rep(j,w){
			if(a[i][j]=='#'){
				if(!check(i,j)){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256