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

int main() {
  int N, x=0;
  cin >> N;
  for (int i=0; i<N; i++){
    string s;
    cin >> s;
    
    if (s=="P"||s=="W"||s=="G"){
    }
    if (s=="Y"){
      x += 1;
    }
  }
  
  if (x==0){
    cout << "Three" << endl;
  }
  
  else {
    cout << "Four" << endl;
  }     
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>

int main(){
    int d;
    std::cin >> d;
    std::vector<int> c(26);
    for(int i = 0; i < 26; i++){
        std::cin >> c[i];
    }
    std::vector<std::vector<int>> s(d, std::vector<int>(26));
    for(int j = 0; j < d; j++){
        for(int i = 0; i < 26; i++){
            std::cin >> s[j][i];
        }
    }
    std::vector<int> t(d);
    for(int j = 0; j < d; j++){
        t[j] = 26 - (j % 26);
    }

    // int m;
    // std::cin >> m;
    // std::vector<int> d_c(m);
    // std::vector<int> q(m);
    // for(int k = 0; k < m; k++){
    //     std::cin >> d_c[k];
    //     std::cin >> q[k];
    // }

    std::vector<int> l(26);
    for(int i = 0; i < 26; i++){
        l[i] = 0;
    }

    // int old = 0;

    int v;
    // for(int k = 0; k < m; k++){
        v = 0;
        for(int i = 0; i < 26; i++){
            l[i] = 0;
        }
        // old = t[d_c[k] - 1];
        // t[d_c[k] - 1] = q[k];

        for(int j = 0; j < d; j++){
            for(int i = 0; i < 26; i++){
                if(i == t[j] - 1){
                    v = v + s[j][i];
                    l[i] = j + 1;
                }
                else{
                    v = v - c[i]*(j + 1 - l[i]);
                }
            }
        }
        // std::cout << v << std::endl;
        // t[d_c[k] - 1] = old;
    // }
    for(int j = 0; j < d; j++){
        std::cout << t[j] << std::endl;
    }
}

Measured memory_bytes: 3668
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<climits>
#define ll long long int
#define mod 1000000007
#define pi acos(-1)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n , m;
  cin>>n>>m;
  for(int i=1;i<=max(m,n);i++)
  {
      cout<<min(m,n);
  }
  cout<<endl;
  
    return 0;
}

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

int N,M;
int par = 1;

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < M; i++)par *= 2;
    printf("%d\n",par * (1900 * M + (N - M) * 100));
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

ans = float('inf')
for _ in range(2):
    for i in range(1, H):
        a = i*W

        b = ((H - i) // 2) * W
        c = ((H - i + 1)// 2) * W
        ans = min(ans, abs(max(a, b, c) - min(a, b, c)))

        b = (W // 2) * (H -i)
        c = ((W + 1) // 2) * (H - i)
        ans = min(ans, abs(max(a, b, c) - min(a, b, c)))
    H, W = W, H
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/perl
use Data::Dumper;

my ($N,$A,$B,$C) = map { $_ - 0 } split(/\s+/,<STDIN>);

my %n = ('A'=>$A,'B'=>$B,'C'=>$C);

my @res = ();

my @ss = ();
for(my $i=0;$i<$N;$i++){
  my $s = scalar(<STDIN>);
  push(@ss,substr($s,0,2));
}

for(my $i=0;$i<$N;$i++){
  my $c1 = substr($ss[$i],0,1);
  my $c2 = substr($ss[$i],1,1);
  if( $n{$c1} == 0 and $n{$c2} == 0 ){
    print "No\n";
    exit(0);
  }
  if( $n{$c1} == 0 or $n{$c2} == 0 ){
    if( $n{$c2} == 0 ){
      my $tmp = $c1; $c1 = $c2; $c2 = $tmp;
    }
  } elsif( $i<$N-1 and $n{$c1} == 1 and $n{$c2} == 1 ){
    if( index($ss[$i+1],$c2)>=0 ){
      my $tmp = $c1; $c1 = $c2; $c2 = $tmp;
    }
  } else {
    if( $n{$c2} < $n{$c1} ){
      my $tmp = $c1; $c1 = $c2; $c2 = $tmp;
    }
  }
  push(@res,$c1);
  $n{$c1} ++;
  $n{$c2} --;
  if( $n{$c2}<0 ){ print "No\n"; exit(0); }
}

print "Yes\n";
for(my $i=0;$i<$N;$i++){
  print "$res[$i]\n";
}



Measured memory_bytes: 21992
from scipy.sparse import*
i=lambda:tuple(map(int,input().split()))
f=csgraph.floyd_warshall
n,m,l=i()
d=eval('[0]*-~n,'*-~n)
exec('a,b,c=i();d[a][b]=c;'*m)
d=f(f(d,0)<=l)
d[d>n]=0
for _ in'_'*i()[0]:print(int(d[i()])-1)

Measured memory_bytes: 353252
#include <iostream>

using namespace std;

int main()
{
  string S;
  cin >> S;
  
  int count = 0;
  for (auto c: S) {
    if (c == 'x') {
      count++;
    }
  }
  
  if (count >= 8) {
    cout << "NO" << endl;
  } else {
  	cout << "YES" << endl;
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
        int n,m,x; cin>>n>>m>>x;
        int c[n]; int a[n][12],mi=0x3f3f3f3f;
        for(int i=0;i<n;i++){
                cin>>c[i];
                for(int j=0;j<m;j++) cin>>a[i][j];
        }
auto val=[&](int curr,int n,int m,int a[][12],int c[],int x){ int res=0; vector<int> dp(m,0); for(int i=0;i<n;i++){ if(curr&(1<<i)){ res+=c[i]; for(int j=0;j<m;j++) dp[j]+=a[i][j]; } } for(int i=0;i<m;i++) if(dp[i]<x) return -1; return res; };
        for(int i=0;i<(1<<n);i++){ int res=val(i,n,m,a,c,x); if(res!=-1) { mi=min(mi,res); }}
        if(mi==0x3f3f3f3f) { cout<<-1<<endl; return 0;}
        cout<<mi<<endl;
        return 0;
}



Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    int a,b,c,d;
    cin>>s;
    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';
    if(a+b+c+d==7)
        printf("%d+%d+%d+%d=7",a,b,c,d);
    else if(a+b+c-d==7)
        printf("%d+%d+%d-%d=7",a,b,c,d);
    else if(a+b-c+d==7)
        printf("%d+%d-%d+%d=7",a,b,c,d);
     else if(a-b+c+d==7)
        printf("%d-%d+%d+%d=7",a,b,c,d);
     else if(a+b-c-d==7)
        printf("%d+%d-%d-%d=7",a,b,c,d);
     else if(a-b+c-d==7)
        printf("%d-%d+%d-%d=7",a,b,c,d);
     else if(a-b-c+d==7)
        printf("%d-%d-%d+%d=7",a,b,c,d);
     else if(a-b-c-d==7)
        printf("%d-%d-%d-%d=7",a,b,c,d);
    return 0;
}


Measured memory_bytes: 256
//package Quarantine;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        int h=s.nextInt();
        int w=s.nextInt();
        int m=s.nextInt();
        int ans=0;
        int row[]=new int[h+1];
        int col[]=new int[w+1];
        HashSet<String> set=new HashSet<>();
        for(int i=1;i<=m;i++){
            int x=s.nextInt();
            int y=s.nextInt();
            StringBuilder t=new StringBuilder();
            t.append(x).append(" ").append(y);
            set.add(t.toString());
            row[x]++;
            col[y]++;
        }
        ArrayList<Athelp> rows=new ArrayList<>();
        ArrayList<Athelp> cols=new ArrayList<>();
        for(int i=1;i<=h;i++){
            rows.add(new Athelp(i,row[i]));
        }
        for(int i=1;i<=w;i++){
            cols.add(new Athelp(i,col[i]));
        }
        Collections.sort(rows,Collections.reverseOrder());
        Collections.sort(cols,Collections.reverseOrder());
        for(int i=0;i<rows.size();i++){
            for(int j=0;j<cols.size();j++){
                int temp=rows.get(i).count+cols.get(j).count;
                if(temp<=ans){
                    break;
                }
                StringBuilder t=new StringBuilder();
                t.append(rows.get(i).ind).append(" ").append(cols.get(j).ind);
                if(set.contains(t.toString())){
                    temp--;
                }
                ans=Math.max(ans,temp);
            }
        }
        System.out.println(ans);
    }
}

class  Athelp implements Comparable<Athelp>{
    int ind,count;
    public Athelp(int ind,int count){
        this.ind=ind;
        this.count=count;
    }

    @Override
    public int compareTo(Athelp o) {
        return this.count-o.count;
    }
}


Measured memory_bytes: 116412
#include<stdio.h>
#include<string.h>

int main()
{
  int i,n,d1[101],d2[101];
  
  scanf("%d", &n);
 
  for (i=1;i<=n;i++)
  {
  	scanf("%d %d",&d1[i],&d2[i]);
    //printf("%d %d\n",d1[i],d2[i]);
  }
  
  for (i=1;i<=n;i++)
  {
  	if (d1[i]==d2[i] && d1[i+1]==d2[i+1] && d1[i+2]==d2[i+2])
    {
    	printf("Yes");
      	return 0;
    }  
  }
   printf("No");
 
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

struct dat{
    int l;
    int r;
};

int main(){
    
    int N,M;cin>>N>>M;
    vector<dat> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i].l>>S[i].r;
    }
    
    int left=0,right=min(N,M)+1;
    sort(all(S),[](auto a,auto b){
        return a.l>b.l;
    });
    while(right-left>1){
        int mid=(left+right)/2;
        int siz=0,id=0;
        bool ok=true;
        for(int t=mid;t>=1;t--){
            while(id<N&&S[id].l>=t){
                siz++;
                id++;
            }
            
            siz--;
            if(siz<0) ok=false;
        }
        
        if(ok) left=mid;
        else right=mid;
    }
    
    priority_queue<int> PQ;
    int id=0;
    for(int t=left;t>=1;t--){
        while(id<N&&S[id].l>=t){
            PQ.push(S[id].r);
            id++;
        }
        PQ.pop();
    }
    while(id<N){
        PQ.push(S[id].r);
        id++;
    }
    
    int cnt=0,now=M;
    while(!PQ.empty()&&now>left){
        if(PQ.top()<=now){
            PQ.pop();
            cnt++;
            now--;
        }else PQ.pop();
    }
    
    cout<<N-(left+cnt)<<endl;
    
}


Measured memory_bytes: 2936
import Data.List
main=do
 [n,k,q]<-map read.words<$>getLine
 a<-sort.map read.lines<$>getContents
 putStr$unlines$map(\c->if c+k-q>0 then"Yes"else"No")$f 0 1 n a
f c i n []
 |i>n=[]
 |i<=n=c:f 0(i+1)n[]
f c i n(a:as)
 |i==a=f(c+1)i n as
 |i/=a=c:f 0(i+1)n(a:as)

Measured memory_bytes: 17916
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  cout << fixed << std::setprecision(10) << 1 - (1.0 * (n / 2)) / n << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int n,a,b,c,A,B,C;main(){cin>>n;for(;cin>>a>>b>>c,a+=max(B,C),b+=max(A,C),c+=max(A,B),n--;A=a,B=b,C=c);cout<<max({A,B,C});}

Measured memory_bytes: 256
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> myds;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define F first
#define S second
#define vec(x) vector<x> 
#define pi(x,y) pair<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repd(i,x,y,k) for(int i=x;i<y;i+=k)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define rev(x) reverse(all(x))
#define full(x,a) memset(x,a,sizeof(x))
#define lcm(x,y) ((x*y)/__gcd(x,y))
#define mod 1000000007
#define bitcount __builtin_popcountll
#define pb push_back
#define indexof order_of_key
#define valueat find_by_order

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


main(){
    fastio;
    int n;
    cin>>n;
    int arr[n+1];
    rep(i,1,n+1)
        cin>>arr[i];
    int dp[n+1],sum[n+1];
    dp[0]=dp[1]=0;
    sum[1]=arr[1];
    repd(i,3,n+1,2)
        sum[i]=sum[i-2]+arr[i];
    rep(i,2,n+1){
        if(i&1) //odd
            dp[i]=max(dp[i-1],dp[i-2]+arr[i]);
        else{   //even
            dp[i]=arr[i]+dp[i-2];
            dp[i]=max(dp[i],sum[i-1]);
        }
    }
    cout<<dp[n]<<endl;   
}


Measured memory_bytes: 8332
function Main(input) {
  reducer = (accumulator, currentValue) => accumulator + currentValue;
  input = input.split("\n");
  tmp = input[0].split(" ");
  tmpb = input[1].split(" ");
  N = parseInt(tmp[0]);
  M = parseInt(tmp[1]);
  C = parseInt(tmp[2]);
  aryb = new Array();
  counter = 0;
  for(var i = 0; i < M; i++ ) {
    aryb.push(tmpb[i]);
  }
  row = N + 2;
  for(var j = 2; j < row; j++ ) {
    a = input[j].split(" ");
    var arya = new Array();
    for(var k = 0; k < M; k++ ) {
      arya.push(a[k] * aryb[k]);
    }
    if(arya.reduce(reducer) + C > 0) {
      counter++;
    }
  }
  console.log(counter);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<stdio.h>
int main(){
	int N[33] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int K;
	scanf("%d\n",&K);
	printf("%d\n",N[K-1]);
}

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

namespace Task {

inline void solve() {
    std::ios::sync_with_stdio(false), std::cin.tie(NULL), std::cout.tie(NULL);
    register int n;
    std::cin >> n;
    std::streambuf *ob = std::cout.rdbuf(), *ib = std::cin.rdbuf();
    static int buc[26], f[26];
    memset(f, 127, sizeof(f));
    register char c;
    for (register int i = 0; i < n; i++) {
        memset(buc, 0, sizeof(buc));
        while (c = ib->sbumpc(), !isalpha(c))
            ;
        while (isalpha(c)) buc[c - 'a']++, c = ib->sbumpc();
        for (register int i = 0; i < 26; i++) f[i] = std::min(f[i], buc[i]);
    }
    for (register int i = 0; i < 26; i++)
        for (; f[i]--;) ob->sputc('a' + i);
}
}

int main() {
    Task::solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int n, m;
        cin >> n >> m;
        if (n == 0 and m == 0) {
            break;
        }
        vector<int> a(n);
        vector<int> b(m);
        int as = 0;
        int bs = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            as += a[i];
        }
        for (int i = 0; i < m; i++) {
            cin >> b[i];
            bs += b[i];
        }
        if (as % 2 != bs % 2) {
            cout << -1 << endl;
            continue;
        }
        int cs = (as - bs) / 2;
        sort(a.begin(), a.end());
        sort(b.begin(), b.end());
        vector<int> c(n * m);
        for (int i = 0; i < n * m; i++) {
            c[i] = a[i % n] - b[i / n];
        }
        int mini = numeric_limits<int>::max();
        int mini_i = 0;
        bool notfound = true;
        for (int i = 0; i < n * m; i++) {
            if (c[i] == cs) {
                notfound = false;
                if (mini > a[i % n] + b[i / n]) {
                    mini = a[i % n] + b[i / n];
                    mini_i = i;
                }
            }
        }
        if (notfound) {
            cout << -1 << endl;
        } else {
            cout << a[mini_i % n] << " " << b[mini_i / n] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

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

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	ll a, b, v, w, t;
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;

	const ll d = abs(b - a);
	bool ok = false;
	if(v > w and (v - w) * t >= d) {
		ok = true;
	}

	puts(ok ? "YES" : "NO");
	
	return 0;
}

Measured memory_bytes: 3632
n=int(input())
m=round(n/1.08)
if int(m*1.08)==n:
  print(m)
  exit()
else:
  if int((m-1)*1.08)==n:
    print(m-1)
    exit()
  elif int((m+1)*1.08)==n:
    print(m+1)
    exit()
  else:
    print(':(')
    exit()

Measured memory_bytes: 9072
#include<bits/stdc++.h>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         100009
#define inf         1e9+8
#define mp          make_pair
#define rep(i,n)    for(int i=0;i<n;i++)
#define repo(i,m,n) for(int i=m;i<=n;i++)
#define ll          long long
#define pii         pair<int,int >
#define sc(n)       scanf("%d",&n)
#define sc2(m,n)    scanf("%d%d",&m,&n);
#define MOD         4294967296
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define mem(x,i)    memset(x,i,sizeof x)
#define PI          acos(-1.0)
#define ff          first
#define ss          second
using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    double ans=0.0;
    for(int i=1;i<=n;i++)
    {
        double x=(log(k/(i*1.0)))/(log(2.0));
        //cout<<"x: "<<x<<endl;
        x=ceil(x);
        x=max(0.0,x);
        x=(1.0/n)*powl(0.5,x);
        //cout<<x<<'\n';
        ans+=x;
    }
    printf("%.9f\n",ans);
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <array>
#include <cstdio>

using namespace std;

const int nmax = 8;
array<array<bool, nmax>, nmax> graph;

int dfs(int v, int N, bool visited[nmax])
{
    bool all_visited = true;

    for (int i = 0; i < N; i++) if (visited[i] == false) all_visited = false;

    if (all_visited) return 1;

    int ret = 0;

    for(int i = 0; i < N; i++)
    {
        if (graph[v][i] == false) continue;
        if (visited[i]) continue;

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

int main(void)
{
    int N, M;
    if (scanf("%d%d", &N, &M) < 2) return 0;

    for(int i=0; i < M; i++)
    {
        int A, B;
        if (scanf("%d%d", &A, &B) < 2) return 0;

        A--;
        B--;
        graph[A][B] = graph[B][A] = true;
    }

    bool visited[nmax];
    for(int i = 0; i < N; i++) visited[i] = false;

    visited[0] = true;
    printf("%d\n", dfs(0, N, visited));
    return 0;
}


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

int main()
{
	int n,x,maks=0;
	cin >> n;
	map<int, int> m;
	for (int i=0;i<n;++i)
	{
		cin >> x;
		++m[x];
		++m[x-1];
		++m[x+1];
		if (m[x]>maks) maks = m[x];
		if (m[x-1]>maks) maks = m[x-1];
		if (m[x+1]>maks) maks = m[x+1];
	}
	cout << maks << endl;
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a[ohara],b[ohara],c[ohara],d,tmp,tmpp,m,h,w,x,y,pos,k,bit[ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
bool fl;
struct edge{int to,cost;};
map<ll,ll> ac;

//-------------------------↓↓↓↓↓↓------------------------

ll summ(ll i){
  ll s=0;
  while(i>0){
    s+=bit[i];
    i-=i&-i;
  }
  return s;
}

void add(ll i,ll x){
  while(i<=n){
    bit[i]+=x;
    i+=i&-i;
  }
}

bool check(ll res){
    ll sum[n+2]={};
    cnt=0;
    rep(i,n){
        if(a[i]<res)sum[i+1]=-1;
        else sum[i+1]=1;
    }
    sum[0]=n;
    rrep(i,0,n)sum[i+1]+=sum[i];
    rep(i,n+1)b[i]=sum[i];
    sort(b,b+n+1);
    tmpp=1;
    rep(i,n+1){
        ac[b[i]]=tmpp;
        if(b[i]!=b[i+1])tmpp++;
    }
    rep(i,n+1){
        sum[i]=ac[sum[i]];
    }
    fill(bit,bit+ohara,0LL);
    add(sum[0],1LL);
    rrep(i,1,n+1){
        cnt+=summ(sum[i]);
        add(sum[i],1LL);
    }
    pos=((n)*(n+1)/2)/2;
    if(((n)*(n+1)/2)%2==1)pos++;
    if(cnt>=pos)return true;
    else return false;
}

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

    cin>>n;
    rep(i,n)cin>>a[i],c[i]=a[i];
    ll le=0,ri=n-1,mid;
    sort(c,c+n);
    while(ri-le>1){
        mid=(le+ri)/2;
        if(check(c[mid])){
            le=mid;
        }
        else{
            ri=mid;
        }
    }
    if(n==1)Cout(a[0]);
    else{
    rrrep(i,min(ri+10,n-1),max(le-10,0LL)){
        tmp=c[i];
        if(check(tmp)){
            Cout(tmp);
            return 0;
        }
    }
    }
    return 0;
}


Measured memory_bytes: 23680
#include <stdio.h>
int n, m, l, g, e;
int a[15], b[15];
int x[15][15], y[15][15];
int ans;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
		for (int j = 0; j < a[i]; j++) {
			scanf("%d%d", x[i] + j, y[i] + j);
			x[i][j]--;
		}
	}
	m = 1;
	for (int i = 0; i < n; i++) {
		m *= 2;
	}
	for (int i = 0; i < m; i++) {
		l = i;
		g = 1;
		e = 0;
		for (int j = 0; j < n; j++) {
			b[j] = l % 2;
			l /= 2;
			e += b[j];
		}
		for (int j = 0; j < n; j++) {
			if (b[j]) {
				for (int k = 0; k < a[j]; k++) {
					if (b[x[j][k]] != y[j][k]) {
						g = 0;
					}
				}
			}
		}
		if (g) {
			if (ans < e)ans = e;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
#define INF (1000000000)
ll N;
struct E{
  ll a,t;
  E(){}
  E(ll a,ll t) :  a(a),t(t) {}
};
bool operator < (const E& s,const E& e){  
    ll sa = s.a+e.a;
    //    printf("%lld*%lld + %lld*%lld < %lld*%lld + %lld*%lld\n",
    //	   sa,t,e.a,e.t,sa,e.t,s.a,s.t);
    if(sa*s.t+e.a*(e.t+1) < sa*e.t+s.a*(s.t+1)){
      return true;
    }
    return false;
}  
struct st{
  ll h,a,d;
};
E En[40004];
st me;
ll ms;

ll rui[40004];

inline ll damage(ll a,ll d){
  return max(a-d,(ll)0);
}
inline ll kill_turn(ll h,ll a,ll d){
  a = damage(a,d);
  if(a==0) return INF;
  //  printf("%lld %lld return = %lld\n",h,a,(h-1)/a);
  return (h-1)/a;
}

ll solve(ll dm){
  if(dm >= me.h) return -1;
  sort(En,En+N);
  for(ll i=N-1;i>-1;i--){
    rui[i]=rui[i+1]+En[i].a;
  }
  for(ll i=0;i<N;i++){
    //            printf("id=%lld a=%lld t=%lld  rui=%lld\n",i,En[i].a,En[i].t,rui[i]);
    dm += (rui[i]*En[i].t);
    //    printf("damage = %lld\n",dm);
    if(i==N-1) break;
    
    if(dm >= me.h) return -1;
    dm += rui[i+1];

    if(dm >= me.h) return -1;
    //    printf("damage = %lld\n",dm);
  }
  if(dm >= me.h) return -1;
  return dm;
}

int main(){
  scanf("%d",&N);
  scanf("%lld %lld %lld %lld",&me.h,&me.a,&me.d,&ms);
  ll res = 0;
  bool end = false;
  for(ll i=0;i<N;i++){
    ll h,a,d;
    ll s;
    scanf("%lld %lld %lld %lld",&h,&a,&d,&s);
    En[i] = E(damage(a,me.d),kill_turn(h,me.a,d));
    //    if(En[i].t==-1) end = true;
    if(s>ms) res+=En[i].a;
  }
  //  if(end) printf("-1\n");
  // else
    printf("%lld\n",solve(res));
}

Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  for(char a = 'a'; a<='z'; a++){
    bool b = false;
    for(int i = 0; i<s.size(); i++){
      if(s.at(i) == a){
        b = true;
        break;
      }
    }
    if(!b){
      cout << a << endl;
      return 0;
      break;
    }
  }
    cout << "None" << endl;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

int main(){
	int n,m; cin >> n >> m;
	vector<pair<int, int> > p(m);
	vector<int> v;

	rep(i,m){
		int a, b;
		cin >> a >> b;
		if (a==1){
			v.push_back(b);
		}
		p[i] = make_pair(b,a);
	}
	sort(rall(p));
	sort(all(v));
	vector<int> g(200007), s(200007);
	rep(i,n){
		if (p[i].first != n) break;
		g[p[i].second]++;
	}
	rep(i,v.size()){
		s[v[i]]++;
	}
	rep(i,200007){
		if (g[i]>0 && s[i]>0){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a > b && a > c)cout << "A" << endl;
  else if(b > c)cout << "B" << endl;
  else cout << "C" << endl;
  return 0;
}



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

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            upper_divisors.append(n//i)
        i += 1
    return lower_divisors , upper_divisors

l,u=make_divisors(n)

print(len(str(u[-1])))

Measured memory_bytes: 39152
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rer(i, a, b) for(int i = a - 1; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<int, pi> ppi;
typedef vector<ll> vec;

const int MAX_N = 200010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;

void Debug() {cout << '\n'; }

template<class FIRST, class... REST> 
void Debug(FIRST arg, REST... rest) { cout << arg << " "; Debug(rest...); }

template<class T>
ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";
	if(!v.empty()) {
		rep(i, 0, (int)v.size() - 1) out << v[i] << ", ";
		out << v.back();
	}
	out << "]";
  return out;
}

template<class S, class T>
ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";
	return out;
}

///g++ -g3 -std=c++0x -DLOCAL -Wall -ftrapv -D_GLIBCXX_DEBUG -Wl,-stack,268435456 -o
///g++ -O2 -std=c++0x -DLOCAL -Wall -Wl,-stack,268435456 -o

////////////////////////////////////////////////////////////////////////

int A, B, C;

void solve() {
	cin >> A >> B >> C;
	if((B * 10 + C) % 4 == 0) cout << "YES\n";
	else cout << "NO\n";
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);	
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

struct AB {
    bool operator<(const AB &p) const {
        return b < p.b;
    }
    int a, b;
};

struct P {
    bool operator<(const P &p) const {
        return a < p.a;
    }
    int a, i;
};

bool solve() {
    int n;
    cin >> n;

    vector<AB> ab(n);
    for (int i = 0; i < n; i++) {
        cin >> ab[i].a;
    }
    for (int i = 0; i < n; i++) {
        cin >> ab[i].b;
    }
    sort(ab.begin(), ab.end());

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        p[i] = { ab[i].a, i };
    }
    sort(p.begin(), p.end());

    for (int i = 0; i < n; i++) {
        if (p[i].a > ab[i].b) return false;
    }

    int l = 0;
    for (int i = 0;;) {
        int &i1 = p[i].i;
        if (i1 < 0) break;
        i = i1;
        i1 = -1;
        l++;
    }
    if (l < n) return true;

    for (int i = 1; i < n; i++) {
        if (p[i].a <= ab[i - 1].b) return true;
    }

    return false;
}

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

    cout << (solve() ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;

	int cnt = 0;
	rep(i, 3) {
		if (s[i] == t[i]) cnt++;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
match = [0,2,5,5,4,5,6,3,7,6]
n,m = map(int,input().split())
a = [int(_) for _ in input().split()]
dp = [-1]*(n+10)
dp[0] = 0
for i in range(n+1):
    if dp[i]== -1:
        continue
    else:
        for j in a:
            dp[i+match[j]]= max(dp[i+match[j]],dp[i]*10+j)
print(dp[n])

Measured memory_bytes: 51036
# Rows and columns(行と列)
rac_count = 3
rac_all = [input() for a in range(rac_count)]

rac_0 = rac_all[0]
rac_1 = rac_all[1]
rac_2 = rac_all[2]

rac_0_0 = list(rac_0)
rac_1_1 = list(rac_1)
rac_2_2 = list(rac_2)

rac_0_0.extend(rac_1_1)
rac_0_0.extend(rac_2_2)

print(str(rac_0_0[0] + rac_0_0[4] + rac_0_0[8]))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	read(w);
	for (int i = 0; i <= sz(s) - 1; i += w) cout << s[i];
}

















Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

ll gcd(ll a, ll b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 }
   
// Function to return LCM of two numbers  
  ll lcm(ll a, ll b)  
 {  
    return (a/gcd(a, b))*b;  
 } 

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll fCnt, sCnt;
    fCnt = a/c + a/d - a/lcm(c,d);
    sCnt = b/c + b/d - b/lcm(c,d);
    if(a%c==0 || a%d==0)
        sCnt++;
    // cout << sCnt-fCnt+1 << endl;
    // cout << "fCnt: " << fCnt << endl;
    // cout << "sCnt: " << sCnt << endl;
    cout << (b-a+1)-(sCnt-fCnt);


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll x,y;
    cin >> x >> y;
    ll cnt=0;
    while(x<=y){
        x*=2;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;
import java.io.IOException;

class Main 
{
	public static void main(String[] args) throws IOException
	{
		int z, n = 3;
		Scanner sc = new Scanner(System.in);

		while(sc.hasNextInt())
		{
			z = sc.nextInt();
			
			if(z == 0)
			{
				break;
			}

			System.out.println(calc(z, n));
		}
	}

	private static long calc(int z, int n)
	{
		long min = Long.MAX_VALUE, tmp;

		for(int x = 1; mypower(x, n) <= mypower(z, n); x++)
		{
			for(int y = x; mypower(x, n) + mypower(y, n) <= mypower(z, n); y++)
			{
				tmp = mypower(z, n) - mypower(x, n) - mypower(y, n);
				
				if(tmp < min)
				{
					min = tmp;
				}
			}
		}
		
		return min;
	}

	private static long mypower(int base, int exp)
	{
		long p = 1;

		for(int i = 0; i < exp; i++)
		{
			p *= base;
		}

		return p;
	}
}

Measured memory_bytes: 20688
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        while (true)
        {
            sbyte[] l = Console.ReadLine().Split(' ').Select(x => sbyte.Parse(x)).ToArray();
            if (l[0] + l[1] + l[2] == -3) break;

            if (l[0] == -1 || l[1] == -1 || l[0] + l[1] < 30)
                Console.WriteLine("F");
            else if (l[0] + l[1] < 50 && l[2] < 50)
                Console.WriteLine("D");
            else if (l[0] + l[1] < 65)
                Console.WriteLine("C");
            else if (l[0] + l[1] < 80)
                Console.WriteLine("B");
            else
                Console.WriteLine("A");
        }
    }
}

Measured memory_bytes: 9380
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	static long solve(long a){
		if(a==0){
			return 0;
		}
		return 1l+solve(a/2l)*2l;
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		long a = scan.nextLong();
		System.out.println(solve(a));
		// your code goes here
	}
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        Map<String,String> cardMap = new HashMap<String,String>();
        String[] typeArray = {"S","H","C","D"};
        try {
        	int cardNum = Integer.parseInt(reader.readLine());
        	int cnt = 0;
        	//??\???
	        while(true){
				inputData = reader.readLine();
				cardMap.put(String.valueOf(cnt), inputData);
				cnt++;
	            if(cnt == cardNum){
	            	break;
	            }
	        }

	        //??????
	        for(int j=0;j<typeArray.length;j++){
		        for(int i=1 ;i < 14;i++){
		        	String checkString = typeArray[j]+" "+ i;
		        	if(!cardMap.containsValue(checkString)){
		        		System.out.println(checkString);
		        	}
		        }
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}

Measured memory_bytes: 24292
#include <iostream>
#include <cstring>
#include <bits/stdc++.h>
#include<algorithm>

using namespace std;

const int N = 1e5+6, M = 1e5+5, inf = 0x3f3f3f3f;
int input[3][N], mem[3][N], n;
void solve(){
for(int i = 1 ; i <= n ;i++ ){

  mem[0][i] = input[0][i] + max(mem[1][i-1] , mem[2][i-1]);
  mem[1][i] = input[1][i] + max(mem[0][i-1] , mem[2][i-1]);
  mem[2][i] = input[2][i] + max(mem[1][i-1] , mem[0][i-1]);
  }
}
int main(){
memset(mem , 0, sizeof mem);
scanf("%d",&n);
for(int i = 1 ; i<=n ; i++)
  scanf("%d%d%d",&input[0][i] ,&input[1][i],&input[2][i]);
solve();
int res = max(mem[0][n],max(mem[1][n],mem[2][n]));
printf("%d\n",res);

return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<math.h>
#include<cstdlib>
#include<assert.h>
#include<string>
#include<sstream>
#include<algorithm>
#include<ctime>
#include<iostream>
#define ll long long 
#define ld long double
#define pb push_back
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(j,n) for (j=1;j<=n;j++)
#define PI 3.14159265358979323846
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL) 
using namespace std;
/*void input(vector<int>& v,int n)
{
	int i,io;
	rep(i,n)
	{
		cin>>io;
		v.pb(io);
	}
}*/
/*bool binary_pred(int a,int b)
{
	return a==b;
}*/
int main()
{
	fastio;
	char ch;
	cin>>ch;
	if (isupper(ch))
		cout<<"A"<<endl;
	else 
		cout<<"a"<<endl;
}


Measured memory_bytes: 3636
from bisect import bisect_left, bisect_right

def solve(N, D):
    D = sorted(D)
    m = D[N//2]
    l = bisect_left(D, m)  # <
    r = bisect_right(D, m) # <=
    #print("l=%d, D[l]=%d %s"%(l, D[l], D[:l]))
    #print("r=%d, D[r]=%d %s"%(r, D[r], D[:r]))
    if l == N-l:
        return D[l] - D[l-1]
    else:
        return 0



N = int(input())
D = [int(x) for x in input().split()]
print(solve(N, D))


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  bool is_divided = true;
  for(int i = 0;i < N;i++)cin >> A[i];
  int cnt = 0;
  while(is_divided){
    for(int i = 0;i < N;i++){
      if(A[i] % 2 == 0){
        A[i] /= 2;
      }else{
        is_divided = false;
      }
    }
    if(is_divided){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()

int main(){
	int N;
	cin >> N;
	if (N % 2) {
		double n = N / 2;
		printf("%.10f\n", (n + 1) / N);
	}
	else {
		cout << "0.5000000" << endl;
	}
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	string s; cin >> s;
	if (s[0] == 'A') {
		cout << "T" << endl;
	}

	if (s[0] == 'T') {
		cout << "A" << endl;
	}

	if (s[0] == 'C') {
		cout << "G" << endl;
	}

	if (s[0] == 'G') {
		cout << "C" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int n,m; cin >> n >> m;
	n%=500;
	if(n<=m) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
def resolve():
  n, a, b, c, d = map(int, input().split())
  a -= 1
  b -= 1
  c -= 1
  d -= 1
  s = input()

  # a と c の間に ## があったらだめ
  for i in range(a, c):
    if s[i] == '#' and s[i+1] == '#':
      print('No')
      return
  # b と d の間に ## があったらだめ
  for i in range(b, d):
    if s[i] == '#' and s[i+1] == '#':
      print('No')
      return
  # a が b を飛び越えないと行けない場合  b - d の間に ... がないとだめ
  if b < c and d < c:
    flag = False
    for i in range(b-1, d):
      if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
        flag = True
    if not flag:
      print('No')
      return
  print('Yes')

  return

if __name__ == "__main__":
  resolve()


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int n, m; cin >> n >> m;
    if(n == 0 && m == 0) break;
    vector<P> p(n);
    REP(i, n) {
      cin >> p[i].se >> p[i].fi;
    }
    sort(ALL(p), greater<P>());
    ll ans = 0;
    REP(i, n) {
      if(m >= p[i].se) {
        m -= p[i].se;
      } else if(m > 0){
        p[i].se -= m;
        m = 0;
        ans += p[i].fi * p[i].se;
      } else {
        ans += p[i].fi * p[i].se;
      }
    }
    cout << ans << endl;
  }
  
}



Measured memory_bytes: 3124
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int A[3];

int main(){
    rep(i,3) cin>>A[i];
    
    sort(A,A+3);

    int ans=0;
    rep(i,2) abs(ans+=A[i+1]-A[i]);

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
n = I()
d = defaultdict(int)
a = LI()
for i in a:
    d[i] += 1
    d[i+1] += 1
    d[i-1] += 1
d = list(d.values())
print(max(d))
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 66576
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int main(){
  int N,Y;
  cin>>N>>Y;
  int M=Y/1000,m=Y/10000+Y%10000/5000+Y%5000/1000;
  if(N>M||m>N){
    cout<<"-1 -1 -1"<<endl;
  }else{
    FOR(x,0,Y/10000+1){
      FOR(y,0,(Y-x*10000)/5000+1){
        if(x+y+(Y-x*10000-y*5000)/1000==N){
          cout<<x<<" "<<y<<" "<<(Y-x*10000-y*5000)/1000<<endl;
          return 0;
        }
      }
    }
    cout<<"-1 -1 -1"<<endl;
  }
  return 0;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, m; cin >> n >> m;
    ll k; cin >> k;
    vector<ll> a(n + 1), b(m + 1);
    for (int i = 0; i < n; i++) {
        ll t; cin >> t;
        a[i + 1] = a[i] + t;
    }
    for (int i = 0; i < m; i++) {
        ll t; cin >> t;
        b[i + 1] = b[i] + t;
    }

    int ans = 0;
    for (int i = 0; i <= n; i++) {
        if (a[i] > k) break;
        int l = 0, r = m + 1;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (a[i] + b[mid] <= k) l = mid;
            else r = mid;
        }
        ans = max(ans, i + l);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6368
#include <stdio.h>

int main(void){
  int N;
  int a[1000];
  int i, j, key;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
    printf("%d",a[i]);
    if(i<N-1) printf(" ");
  }

  printf("\n");

  for(i=1;i<=N-1;i++){
    key = a[i];
    j = i - 1;
    while(j>=0 && a[j]>key){
      a[j+1] = a[j];
      j--;
    }
    
    a[j+1] = key;
    
    for(j=0;j<N;j++){
      printf("%d",a[j]);
      if(j < N-1) printf(" ");
    }
    printf("\n");

  }
  return 0;
}




Measured memory_bytes: 2140