akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<pair<int,int>> vip;

#define ZOOM ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


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 debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main(int argc,char* argv[])
{
    ZOOM
    //freopen("in.txt","r",stdin);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    map<char,ll> m;
    m['R']=0,m['B']=0,m['G']=0;
    rep(i,n)
    {
        ++m[s[i]];
    }
    ll mn=1;
    LOOP_IT(it,m)
    {
        mn*=ss;
    }
    for(ll i=0;i<n;++i)
    {
        for(ll j=i+1;j<=(i+(n-i-1)/2);++j)
        {
            if(s[i]!=s[j]&&s[j]!=s[j+(j-i)]&&s[i]!=s[j+j-i])
                --mn;
        }
    }
    cout<<mn;
    return 0;
}



Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

    int N; cin >> N;
    if(N == 1) {
        cout << "Hello World" << endl;
    } else {
        int A, B; cin >> A >> B;
        cout << A + B << endl;
    }

    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <list>

int main()
{
    std::string str;
    std::getline(std::cin, str);
    size_t black_count = 0;
    size_t total = 0;
    for (size_t i = 0; i < str.size(); i++) {
        if (str[i] == 'B') {
            black_count++;
        }
        if (str[i] == 'W') {
            total += black_count;
        }
    }
    std::cout << total << std::endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
int main()
{
    string S;
    cin >> S;

    if (S[0] == S[1] && S[1] == S[2] && S[2] == S[3]) { cout << "Yes" << endl; }
    else {
        if (S[0] == S[1] && S[1] == S[2]) { cout << "Yes" << endl; }
        else if (S[1] == S[2] && S[2] == S[3]) { cout << "Yes" << endl; }
        else { cout << "No" << endl; }
    }
}

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

int main(){
  string S, T;
  cin >> S >> T;
  
  int Tsize = (int)T.size();
  int N = (int)S.size();
  
  int ans = Tsize;
  
  if(Tsize == N){
    rep(i,N){
      if(S.at(i) == T.at(i))ans--;
    }
    cout << ans << endl;
    return 0;
  }
  
  // iからTsize文字の塊をみていき、Tと文字が一致していればカウントを増やす。
  rep(i,N - Tsize){
    int now = 0;
    int k = i;
    for(int j = 0; j < Tsize; j++){
      if(S.at(k) == T.at(j))now++;
      k++;
    }
    ans = min(ans,Tsize-now);
  }
  cout << ans << endl;
}

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

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

  int highest_bit_N = 0;
  for(; (1 << highest_bit_N) <= N - 1; highest_bit_N++){
  }
  // N = 4 -> 2
  // N = 5 -> 3
  // cout << highest_bit_N << endl;

  for(int i = 0; i < N - 1; i++){
    for(int j = i + 1; j < N; j++){
      if(j != i + 1){
        cout << ' ';
      }
      int highest_diff_bit = 10;
      while((i & (1 << highest_diff_bit)) == (j & (1 << highest_diff_bit))){
        highest_diff_bit--;
      }
      cout << highest_diff_bit + 1;
    }
    cout << endl;
  }
}


Measured memory_bytes: 512
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
	Scanner s = new Scanner(System.in);
	int a , b , c , max_num1, max_num2;
	int res_flg;
	//String n = s.next();
	int n = Integer.parseInt(s.nextLine());
	for(int i = 0;i<n;i++){
		String line = s.nextLine();
		String[] array = line.split(" ",0);
		a = Integer.parseInt(array[0]);
		b = Integer.parseInt(array[1]);
		c = Integer.parseInt(array[2]);
 
		if(a >= b && a >= c){
			if(a*a == b*b+c*c){
				res_flg = 1;
			}else{
				res_flg = 0;
			}
		}
		else if(b >= a && b >= c){
			if(b*b == a*a+c*c){
				res_flg = 1;
			}else{
				res_flg = 0;
			}
		}
		else if(c >= a && c >= b){
			if(c*c == b*b+a*a){
				res_flg = 1;
			}else{
				res_flg = 0;
			}
		}else{
			res_flg = 0;
		}
		if(res_flg == 0){
			System.out.println("NO");
		}else{
			System.out.println("YES");
		}
	}
  }
}

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

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

s = list(input())
t = list("abcdefghijklmnopqrstuvwxyz")

for i in range(len(t)):
    for j in range(len(s)):
        if t[i] == s[j]:
            break
    else:
        print(t[i])
        break
else:
    print("None")


Measured memory_bytes: 3956
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 105
using namespace std;
typedef long long ll;
int n,m,sum,ex,ey;
char s[MAXN][MAXN];
short int dp[MAXN][MAXN][MAXN][MAXN];
int addx[MAXN][MAXN][MAXN],addy[MAXN][MAXN][MAXN];
ll add1(int new1,int d,int l,int r){
	int l1=r-ey+1;
	int r1=l+m-ey;
	if(new1>d)
		return addx[new1][l1][r1];
	else
		return addx[new1][l1][l-1]+addx[new1][r+1][r1];
}
ll add2(int new1,int u,int l,int r){
	int l1=r-ey+1;
	int r1=l+m-ey;
	if(new1<u)
		return addx[new1][l1][r1];
	else
		return addx[new1][l1][l-1]+addx[new1][r+1][r1];
}
ll add3(int new1,int r,int u,int d){
	int u1=d-ex+1;
	int d1=u+n-ex;
	if(new1>r)
		return addy[new1][u1][d1];
	else
		return addy[new1][u1][u-1]+addy[new1][d+1][d1];
}
ll add4(int new1,int l,int u,int d){
	int u1=d-ex+1;
	int d1=u+n-ex;
	if(new1<l)
		return addy[new1][u1][d1];
	else
		return addy[new1][u1][u-1]+addy[new1][d+1][d1];
}
int min1(int x,int y){
	if(x==-1)
		return y;
	if(y==-1)
		return x;
	return min(x,y);
}
int dfs(int u,int d,int l,int r){
	if(dp[u][d][l][r]!=-1)
		return dp[u][d][l][r];
	if(u<ex){
		dp[u][d][l][r]=min1(dp[u][d][l][r],dfs(u+1,d,l,r)+add1(u+1+n-ex,d,l,r));
	}
	if(d>ex){
		dp[u][d][l][r]=min1(dp[u][d][l][r],dfs(u,d-1,l,r)+add2(d-ex,u,l,r));
	}
	if(l<ey){
		dp[u][d][l][r]=min1(dp[u][d][l][r],dfs(u,d,l+1,r)+add3(l+1+m-ey,r,u,d));
	}
	if(r>ey){
		dp[u][d][l][r]=min1(dp[u][d][l][r],dfs(u,d,l,r-1)+add4(r-ey,l,u,d));
	}
	//PF("[%d %d %d %d %d(%d)]\n",u,d,l,r,dp[u][d][l][r],addy[1][1][n]);
	return dp[u][d][l][r];
}
int main(){
	SF("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		SF("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			for(int k=j;k<=m;k++)
				addx[i][j][k]=addx[i][j][k-1]+(s[i][k]=='o');	
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)
			for(int k=j;k<=n;k++)
				addy[i][j][k]=addy[i][j][k-1]+(s[k][i]=='o');
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			if(s[i][j]=='E'){
				ex=i;
				ey=j;
			}
			if(s[i][j]=='o')
				sum++;
		}
	memset(dp,-1,sizeof dp);
	dp[ex][ex][ey][ey]=0;
	PF("%d\n",sum-dfs(1,n,1,m));
	
}

Measured memory_bytes: 246656
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("O3")
const int MOD = 1000000007;

int arr[21][21];
int dp[1 << 21];
bool sht[1 << 21];
int n;

int rec(int x, int mask)
{
    if (sht[mask]) return dp[mask];
    sht[mask] = 1;
    
    if (x == n) return dp[mask] = 1;
    
    for (int i = 0; i != n; ++i)
        if (arr[x][i] && !(mask & (1 << i)))
            (dp[mask] += rec(x + 1, mask | (1 << i))) %= MOD;
    
    return dp[mask];
}

int main()
{
    cin >> n;
    for (int i = 0; i != n; ++i)
        for (int j = 0; j != n; ++j)
            cin >> arr[i][j];
    
    cout << rec(0, 0) << endl;
    
    return 0;
}

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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}


// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));




int main()
{
    int n,W;cin>>n>>W;
    vec<int> weight(n+10,0),val(n+10,0);
    rep(i,n) cin>>weight[i]>>val[i];
    vec<ll> dp(W+10,0);

    rep(i,n){
        for(int w=W;w>=0;w--){
            if(w>=weight[i]) dp[w]=max(dp[w],dp[w-weight[i]]+val[i]);
        }
    }

    cout<<dp[W]<<endl;
    return 0;

}




Measured memory_bytes: 1024
#include<iostream>
#include<fstream>

using namespace std;

int main(){

    ifstream ifs("in1.txt");

    int i;
    int height[3]={};
    int tmp, tmp2;
    string str;

    //while(getline(ifs,str)){
    while(cin >> str){
        sscanf(str.c_str(),"%d",&tmp);
        if(0<=tmp && tmp <=10000){
            for(i=0;i<3;i++){
                if(height[i] < tmp){
                    tmp2 = height[i];
                    height[i] = tmp;
                    tmp = tmp2;
                }
            }
        }
    }

    for(i=0;i<3;i++){
        cout << height[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

int main(){
    int x;
    cin >> x;
    
    while(x>=0){
        if(x%4==0){
            cout << "Yes";
            return 0;
        }
        x-=7;
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	int N,Q,K;
	ArrayList<Edge>[] graph;

	class Edge{
		int b;
		long c;
		public Edge(int b,long c){
			this.b = b;
			this.c = c;
		}
	}

	@SuppressWarnings("unchecked")
	public void solve(){
		N = nextInt();
		graph = new ArrayList[N];
		for(int i = 0;i < N;i++){
			graph[i] = new ArrayList<>();
		}

		for(int i = 0;i < N-1;i++){
			int a = nextInt()-1;
			int b = nextInt()-1;
			int c = nextInt();
			graph[a].add(new Edge(b,c));
			graph[b].add(new Edge(a,c));
		}

		Q = nextInt();
		K = nextInt()-1;

		ArrayDeque<Edge> q = new ArrayDeque<Edge>();
		long[] dis = new long[N];
		Arrays.fill(dis, -1);
		q.add(new Edge(K,0));

		while(q.size() > 0){

			Edge e = q.poll();

			if(dis[e.b] != -1)continue;
			dis[e.b] = e.c;
			for(Edge next : graph[e.b]){
				if(dis[next.b] != -1)continue;
				q.add(new Edge(next.b,e.c + next.c));
			}

		}

		for(int i = 0;i < Q;i++){
			int x = nextInt()-1;
			int y = nextInt()-1;

			out.println(dis[x] +dis[y]);
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 80544
package main

import (
	"fmt"
	"sort"
)

type Datum struct {
	EraName      string
	EraBasedYear int64
	WesternYear  int64
}

const Unknown = "Unknown"

func lowerBound(data []*Datum, westernYearBorder int64) int {
	imin := -1
	imax := len(data)
	for imax-imin > 1 {
		imid := (imax + imin) / 2
		if data[imid].WesternYear >= westernYearBorder {
			imax = imid
		} else {
			imin = imid
		}
	}
	return imax
}

func solve(n, q int) {
	data := make([]*Datum, 0, n)
	for index := 0; index < n; index++ {
		datum := Datum{}
		fmt.Scan(&datum.EraName, &datum.EraBasedYear, &datum.WesternYear)
		data = append(data, &datum)
	}
	sort.Slice(data, func(i, j int) bool {
		return data[i].WesternYear < data[j].WesternYear
	})
	for cnt := 0; cnt < q; cnt++ {
		var query int64
		fmt.Scan(&query)
		var index int
		if index = lowerBound(data, query); index == n {
			fmt.Println(Unknown)
			continue
		}
		possibleDatum := data[index]
		if possibleDatum.WesternYear-query > possibleDatum.EraBasedYear-1 {
			fmt.Println(Unknown)
			continue
		}
		ans := possibleDatum.EraBasedYear - (possibleDatum.WesternYear - query)
		fmt.Println(possibleDatum.EraName, ans)
	}
}

func main() {
	for {
		var n, q int
		if fmt.Scan(&n, &q); n == 0 && q == 0 {
			break
		}
		solve(n, q)
	}
}



Measured memory_bytes: 5416
#include <iostream>
#include <vector>
using namespace std;
int main(){
    long N;
    long K;
    long h;
    long _min;
    long dif;
    cin >> N >> K;
    if (K >= N){
        K = N - 1;
    }
    vector<long> h_ls(N);
    vector<long> memo_ls(N);
    for(int i=0; i<N; i++){
        cin >> h;
        h_ls[i] = h;
    }
    for(int i=0;i<K+1;i++){
        memo_ls[N-i-1] = (long)abs((int)(h_ls[N-i-1] - h_ls[N-1]));
    }
    for(int i=K+1; i<N; i++){
        _min = 1e9;
        for(int j=1; j<K+1; j++){
            dif = (long)abs((int)(h_ls[N-i-1] - h_ls[N-1-i+j])) + memo_ls[N-1-i+j];
            if(dif<_min){
                _min = dif;
            }
        }
        memo_ls[N-i-1] = _min;
    }
    cout << memo_ls[0] << endl;
};


Measured memory_bytes: 1792
def run(N, S):
    num_l = [0]
    num_r = [0]
    for i in range(1, len(S)):
        cnt = num_l[i-1]
        if S[i-1] == 'W':
            num_l.append(cnt+1)
        else:
            num_l.append(cnt)
        cnt = num_r[i-1]
        if S[N-i] == 'E':
            num_r.append(cnt+1)
        else:
            num_r.append(cnt)
    ret = max(num_l) + max(num_r)
    for i in range(len(num_l)):
        ret = min(ret, num_l[i]+num_r[N-1-i])
    return ret


def main():
    N = int(input())
    S = input()
    print(run(N, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 18044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int gcd(int a,int b){
  return b ? gcd(b,a%b):a;
}
int main(){
  int n;
  string s;
  cin >> n;
  map<int,int> mp;
  int res;
  bool flag = false;
  rep(i,n){
    int x;
    cin >> x;
    if (i == 0) res = x;
    else res = gcd(res,x);
    for (int a=2;a*a <= x;a++){
      if (x%a == 0 && mp.count(a)){
          flag = true;
      }
      while(x%a == 0){
        mp[a]++;
        x/=a;
      }
    }
    if (x != 1){
      if (mp.count(x)){
        flag = true;
      }
      mp[x]++;
    }
  }
  if (res == 1){
    if (flag){
      cout << "setwise coprime" << endl;
    }
    else cout << "pairwise coprime" << endl;
  }
  else cout << "not coprime" << endl;

  return 0;
  
}


Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int N;
    cin >> N;
    bool flag = false;
    while(N != 0){       
        if(N % 10 == 7){flag = true;break;}
        else{
            N = N / 10;
        }

    }
    cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
 
int main() {
  int n;
  cin>>n;
  float count=0.0;
  for(int i=1;i<=n;i++){
    if(i%2==1){
      count++;
    }
  }
  cout<<count/n;

}
 
    
 

Measured memory_bytes: 256
N, X = map(int,input().split())
L = list(map(int,input().split()))
ans = 0
point = [0]
for i in range(1,N+1):
  p = (point[-1]) + (L[i-1])
  point.append(p)
  
for j in range(len(point)):
  if point[j] <= X:
    ans += 1
  else:
    break
    
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
using namespace std;
int main(void){
    char s[200001];
    cin >> s;
    int k=0;
    for(int i=0;i<strlen(s);i++){
        k+=s[i]-'0';
        k=k%3;
    }
    if(k==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3784
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int bekijo(int n){
  int tmp = sqrt(n) + 1;
  int ans = 1;
  int f = 0;
  int prev;
  for(int b = tmp; b >= 1; b--){
    int limit = (double)log(n) / (double)log(b);
//    cout << limit << ":"<< b << " ";
    for(int a = 2; a <= 10; a++){
      if (n / (int)pow(b,a) == 0){
        ans = max(ans ,prev);
        break;
      }
      prev = pow(b,a);
    }
  }
  return ans;
}

int main(){
  int N;
  cin >> N;
  int a = bekijo(N);
  cout << a;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <tuple>

using namespace std;
// c++14 (atcoder環境)だとtupleは普通に動く
// cd "/Users/shinkaitomomichi/Desktop/test_folder/" && g++ -std=c++14 sample_045D.cpp -o sample_045D && ./sample_045D

// &をつけてアドレスに変更
int count_area(map<tuple<int, int>, int> &table, int a, int b){
    int count_n = 0;
    for(int j=-1; j<=1; ++j){
        for(int k=-1; k<=1; ++k){
            count_n += table[make_tuple(a+j,b+k)];
        }
    }
    return count_n;
}

int main()
{    
    unsigned long long h, w, n;
    cin >> h >> w >> n;
    int a[n], b[n];
    for(int i=0; i<n; ++i){
        cin >> a[i] >> b[i];
    }

    // map : 2つのキーを持つ
    map<tuple<int, int>, int> table;
    map<tuple<int, int>, int> count_table;
    int ans[10];
    for(int i=0; i<10; ++i) ans[i] = 0;
    // mapに0, 1を塗る
    for(int i=0; i<n; ++i){
        for(int j=-2; j<=2; ++j){
            for(int k=-2; k<=2; ++k){
                table[make_tuple(a[i]+j, b[i]+k)] = 0;
            }
        }
    }
    for(int i=0; i<n; ++i){
        table[make_tuple(a[i], b[i])] = 1;
    }    
    // 探索
    for(int i=0; i<n; ++i){
        for(int j=-1; j<=1; ++j){
            for(int k=-1; k<=1; ++k){
                // 端の場合処理は不要
                if (a[i]+j > 1 && a[i]+j < h && b[i]+k > 1 && b[i]+k < w){
                    // 作り直し
                    // int count_n = 0;
                    // for(int l=-1; l<=1; ++l){
                    //     for(int m=-1; m<=1; ++m){
                    //         count_n += table[make_tuple(a[i]+j+l,b[i]+k+m)];
                    //     }
                    // }
                    // count_table[make_tuple(a[i]+j, b[i]+k)] = count_n;
                    count_table[make_tuple(a[i]+j, b[i]+k)] = count_area(table, a[i]+j, b[i]+k);
                }
            }
        }
    }
    // map内の全探索
    for(auto itr = count_table.begin(); itr != count_table.end(); ++itr){
        // cout << itr->first << endl; // tupleの時これが使用できない?
        ans[itr->second]++;
    }

    // 0のカウントは全パターンから引けばいい
    unsigned long long ans_0 = (h-2)*(w-2);
    for(int i=1; i<10; ++i) ans_0 -= ans[i];
    cout << ans_0 << endl;
    for(int i=1; i<10; ++i){
        cout << ans[i] << endl;        
    }
    return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl



int main(){
    ll n,k;
    cin >> n >> k;
    int a,b;
    vector<ll> list(100010,0);
    ll ans = 0;
    REP(i,n){
        cin >> a >> b;
        list[a]+=b;
    }
    REP(i,100010){
        ans += list[i];
        if(ans>=k){
            COUT(i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int maxn = 105, maxk = 1e5+5;
int N,K, a[maxn], sg[maxk];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    memset(sg, -1, sizeof(sg));
    cin>>N>>K;
    
    for(int i = 0; i<N; i++){
        cin>>a[i];
    }
    
    sort(a, a+N);
    sg[0] = 0;
    for(int i = 0; i <= K; i++){
        set<int> mex;
        for(int j = 0;j<N&&a[j]<=i; j++){
            mex.insert(sg[i-a[j]]);
        }
        int k = 0;
        while(mex.count(k)){k++;}
        sg[i] = k;
    }
    
    cout<<(sg[K]?"First":"Second")<<"\n";

    return 0;
}





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

const int Max=51;
int n,m,now,num[Max];
long long ans;
long long f[3][Max][Max*Max];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&num[i]);
	f[1][0][0]=f[0][0][0]=1;
	for(int i=1;i<=n;i++)
	{
	  for(int j=1;j<=i;j++)
	    for(int k=0;k<=2500;k++)
	    {
	      f[now][j][k]=f[now^1][j][k];
	      if(k>=num[i]) f[now][j][k]+=f[now^1][j-1][k-num[i]];
	    }
	  now^=1;
	}
	for(int i=1;i<=n;i++) ans+=f[now^1][i][i*m];
	cout<<ans<<"\n";
	return 0;
}

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

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  int ans;
  if (n >= k) ans = (n - k) * y + k * x;
  else ans = n * x;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace _087_StrangeMathematicalExpression
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;

			while ((inputStr = Console.ReadLine ()) != null)
			{
				string[] splits = inputStr.Split (' ');
				Stack<string> content = new Stack<string> (inputStr.Length);

				for (int lp = 0; lp < splits.Length; lp++)
				{
					decimal tmp;
					bool isOperator = !decimal.TryParse (splits[lp], out tmp);

					if (isOperator)
					{
						decimal operand1 = decimal.Parse (content.Pop ());
						decimal operand2 = decimal.Parse (content.Pop ());
						decimal result = 0m;

						switch (splits[lp])
						{
							case "+": result = operand2 + operand1; break;
							case "-": result = operand2 - operand1; break;
							case "*": result = operand2 * operand1; break;
							case "/": result = operand2 / operand1; break;
						}

						content.Push (result.ToString ());
					}
					else
					{
						content.Push (splits[lp]);
					}
				}

				Console.WriteLine (content.Peek ());
			}
		}
	}
}

Measured memory_bytes: 10632
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#define int long long
using namespace std;

signed main() {
	int res, N;
	res = 0;
	cin >> N;
	vector<int> a(N);
	int b;
	for (int i = 0; i < N; i++) {
		cin >> b;
		a[b - 1] = i + 1;
	}
	
	set<int> st;
	st.insert(0);
	st.insert(N + 1);
	int x, y;
	for (int i = 0; i < N; i++) {
		y = *st.lower_bound(a[i]);
		x = *(--st.upper_bound(a[i]));
		//cerr << x << " "<<y<<endl;
		res += (i+1)*(a[i] - x)*(y - a[i]);
		st.insert(a[i]);
	}
	cout << res << endl;

	return 0;
}

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

int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  
  long long sum = a;
  bool can = false;
  while(sum <= a * b){
    if(sum % b == c){
      can = true;
      break;
    }
    sum += a;
  }
  
  if(can){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
      
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  if(N > M) swap(N, M);
  if(N == 1){
    if(M == 1) cout << 1 << endl;
    else cout << (long long int)max(0, M-2)*N << endl;
  }else{
    cout << (long long int)max(0, M-2)*max(0, N-2) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import os, sys, re, math
from functools import reduce

N = int(input())
A = [int(n) for n in input().split()]

v = 1
count = 0
for i in range(N):
    if A[i] == v:
        v += 1
    else:
        count += 1

if v > 1:
    print(count)
else:
    print(-1)


Measured memory_bytes: 34652
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

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

    if (D == 25) {cout << "Christmas";}
    if (D == 24) {cout << "Christmas Eve";}
    if (D == 23) {cout << "Christmas Eve Eve";}
    if (D == 22) {cout << "Christmas Eve Eve Eve";}

    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
print("Yes" if re.fullmatch(r"(hi)+", S) else "No")


Measured memory_bytes: 10324
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

const LL MAXN = 1e9;
const int TIMES = 64;

struct Querier {
	LL chosen;
	void choose() {
		srand(time(NULL));
		chosen = rand() % MAXN;
		chosen++;
		cerr << "Chosen: " << chosen << endl;
	}
	bool ask(LL n) {
		bool res = false;
		if(n <= chosen && to_string(n) <= to_string(chosen)) res = true;
		if(n > chosen && to_string(n) > to_string(chosen)) res = true;
		cerr << "Asking " << n << " and answered = " << "NY"[res] << endl;
		return res;
	}
} qq;

LL conv(string s) {
	LL res = 0;
	for(auto &c: s) {
		res = res * 10 + (c - '0');
	}
	return res;
}

int main() {
  ios_base::sync_with_stdio(false);
	int asked = 0;
	qq.choose();
	auto ask = [&](LL n) -> bool {
		asked++;
		assert(asked < TIMES);
		char resp;
		bool ans;
#ifdef LOCAL
		ans = qq.ask(n);
#else
		cout << "? " << n << endl;
		cin >> resp;
		ans = resp == 'Y';
#endif
		return ans;
	};
	LL temp = 1;
	int idx = -1;
	for(int i = 1; i <= 10; i++) {
		if(ask(temp) == false) {
			idx = i;
			break;
		}
		temp *= 10;
	}
	string res;
	if(idx == -1) { // Power of 10
		if(ask(conv("9")) == true) {
			res = "1";
		} else {
			res = "19";
			for(int i = 1; ; i++) {
				assert(res.size() < 12);
				if(ask(conv(res)) == true) {
					break;
				} else {
					res.push_back('9');
				}
			}
			for(auto &c: res) {
				if(c == '9') c = '0';
			}
		}
	} else {
		assert(idx > 1);
		LL numdgts = idx - 1;
		res.resize(numdgts + 1);
		for(auto &c: res) {
			c = '9';
		}
		for(int i = 0; i < numdgts; i++) {
			int lower = i == 0, upper = 10, mid;
			while(lower < upper) {
				mid = (lower + upper) / 2;
				res[i] = mid + '0';
				if(ask(conv(res)) == false) {
					lower = mid + 1;
				} else {
					upper = mid;
				}
			}
			assert(lower != 10);
			res[i] = lower + '0';
		}
		res.pop_back();
	}
	cout << "! " << res << endl;
#ifdef LOCAL
	if(qq.chosen != conv(res)) {
		cerr << "WA!" << endl;
		assert(false);
	}
	cerr <<"AC!" << endl;
#endif
  return 0;
}


Measured memory_bytes: 632
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=100100;
ll i,j,k,n,a,b,c,d,m,ch,ff;
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(int x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
void R(ll &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(ll x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
int main() {
	R(n);R(a);R(b);R(c);R(d);
	if (a>b) {
		ll t=a;a=b;b=t;
	}
	n--;
	ll now=a;
	for (i=1;i<=n;i++) now-=d;
	for (i=1;i<=n;i++) if (now+c+d<=b) now+=c+d;
	if (now+n*(d-c)>=b) puts("YES");
	else puts("NO");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int l,r,d;
    cin>>l; cin>>r; cin>>d;
    int i=l; int cnt=0;
    while(i<=r){
        if(i%d==0){
            cnt++; i++;
        } else i++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define mul(a,b) a=a*b%mod;
#define base 100010
namespace bit{
  ll dat[2*base];
  void init(){
      for(int i=0;i<2*base;i++)dat[i]=0;
  }
  void add(ll i){
      i+=base;
      for(;i<2*base;i+=i&-i){
          dat[i]++;
      }
  }
  ll qry(ll i){
      i+=base;
      ll res=0;
      for(;i;i-=i&-i){
          res+=dat[i];
      }
      return res;
  }
};
ll n,a[100010];
bool solve(ll key){
    ll rui=0;
    bit::init();
    bit::add(0);
    ll res=0;
    for(int i=0;i<n;i++){
        if(a[i]>=key)rui++;
        else rui--;
        res+=bit::qry(rui);
      bit::add(rui);
    }
    return res*2>=n*(n+1)/2;
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  ll l=-1,r=1e10,mid;
  while(l<r-1){
      mid=(l+r)>>1;
      if(solve(mid))l=mid;
      else r=mid;
  }
  cout<<l<<endl;
  return 0;
}



Measured memory_bytes: 2560
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int A, B, C;
  cin >>A>>B>>C;
  FOR(i,0,1000) {
    if((A*i)%B==C) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
# define M_PI           3.14159265358979323846
#define vec vector 
int main()
{
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    ll dp[n];
    for(ll i=0;i<n;i++)
        dp[i]=1e9;
    dp[0]=0;
    for(ll i=0;i<n-1;i++)
        for(ll j=1;j<=k && i+j<n;j++)
            dp[i+j]=min(dp[i+j],dp[i]+abs(arr[j+i]-arr[i]));
    cout<<dp[n-1]<<"\n";
    return 0;     
}

Measured memory_bytes: 5132
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc167/tasks/abc167_a>
 問題文============================================================
 A - Registration
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string S,T; cin >> S >> T;
    T.pop_back();
    if(S == T) return "Yes";
    else return "No";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


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

using namespace std;

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

    int ret = 100000;
    for (int start = 0; start + t.size() <= s.size(); start++) {
        int now = 0;
        for (int i = 0; i < t.size(); i++) {
            if (s[start + i] != t[i])now++;
        }
        ret = min(ret, now);
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (int)(s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
constexpr long long INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}



signed main(){
	int N;
	cin>>N;
	int even = N / 2;
	cout<<(double)(N-even)/N*1.0<<endl;
}

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

#define MAX 2000000
#define INF 200000000
int H,A[MAX+1];

/*void swap(int x,int y){
  int t;
  t=x;
  x=y;
  y=x;
  }*/

void maxHeapify(int i){
  int l,r,largest,tmp;
  l=2*i;
  r=2*i+1;
  if(l<=H && A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H && A[r]>A[largest]) largest=r;
  if(largest!=i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(H<1) return -INF;
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i,int key){
  int tmp;
  if(key<A[i]) return;
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    tmp=A[i];
    A[i]=A[i/2];
    A[i/2]=tmp;
    i=i/2;
  }
}

void insert(int key){
  H++;
  A[H]=-INF;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];
  while(1){
    scanf("%s",com);
    if(com[0]=='e' && com[1]=='n' ) break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else printf("%d\n",extract());
  }
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

vector<vi> adj;
vll A;
vll dp;
bool ng=false;

void dfs(int v, int p){
    if (ng) return;
    if (v!=0 && adj[v].size()==1){
        dp[v] = A[v];
        return;
    }
    ll sum=0,ma=0;
    priority_queue<ll> que;
    for(auto u:adj[v]){
        if (u==p) continue;
        dfs(u,v);
        sum+=dp[u];
        chmax(ma,dp[u]);
    }
    ll xmax=0;
    if (ma*2>sum){
        xmax = sum-ma;
    }else{
        xmax = sum/2;
    }

    ll x = sum-A[v];
    if (x<0 || x>xmax){ng=true; return;}
    ll y = A[v]-x;
    if (y<0){ng=true; return;}
    dp[v] = y;
    if (v==0 && y>0 && adj[v].size()!=1) ng=true;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    adj.resize(n);
    A.resize(n);
    dp.resize(n);
    rep(i,n) cin>>A[i];
    rep(i,n-1){
        int a,b; cin>>a>>b; a--; b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    dfs(0,-1);
    // rep(i,n) cout<<dp[i]<<" ";
    if (ng){
        cout<<"NO\n";
    }else{
        cout<<"YES\n";
    }
    return 0;
}


Measured memory_bytes: 13952
package main

import "fmt"

func main() {
	in, an := 0, 0
	fmt.Scanf("%d", &in)
	for i := 1; i <= in; i++ {
		for j := 1; j <= in; j++ {
			for k := 1; k <= in; k++ {
				an += gcd(i, j, k)
			}
		}
	}
	fmt.Println(an)
}
func gcd(a, b, c int) int {
	return gcd2(a, gcd2(b, c))
}
func gcd2(a, b int) int {
	if b == 0 {
		return a
	} else {
		return gcd2(b, a%b)
	}
}

Measured memory_bytes: 1860
#include"iostream"

using namespace std;

int main()
{
	int n;
	int a, b, c;
	cin >> n;
	while (n--) {
		cin >> a >> b >> c;
		if (a*a + b*b == c*c || a*a + c*c == b*b || b*b + c*c == a*a)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Combination{
	constexpr static int atcoder_mod = 1000000007;
	vector<ll> fac,finv,inv;
public:
	Combination(ll N){
		fac.resize(N+1);
		finv.resize(N+1);
		inv.resize(N+1);
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i=2;i<=N;i++){
			fac[i] = fac[i-1] * i % atcoder_mod;
			inv[i] = atcoder_mod - inv[atcoder_mod%i] * (atcoder_mod/i) % atcoder_mod;
			finv[i] = finv[i-1] * inv[i] % atcoder_mod;
		}
	}
	ll Caluclation(ll n,ll r){
		if(n < r) return 0;
		if (n < 0 || r < 0) return 0;
		return fac[n] * (finv[r] * finv[n-r] % atcoder_mod) % atcoder_mod;
	}
	ll GetFInv(ll i){
		return finv[i];
	}
};

ll BallBoxCombination5(ll n,ll k){
	Combination comb(k);
	return comb.Caluclation(k,n);
}

ll BallBoxCombination6(ll n,ll k){
	Combination comb(n-1);
	return comb.Caluclation(n-1,k-1);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),K=in();
	int R=N-K;
	REP(i,K){
		ll X=BallBoxCombination5(i+1,R+1);
		ll Y=BallBoxCombination6(K,i+1);
		out((X*Y)%atcoder_mod);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int *A = new int[n-1];
    for(int i=0;i<n-1;++i){
        cin>>A[i];
    }
    int *B = new int[n];
    for(int i=0;i<n;++i){
        B[i]=0;
    }
    for(int i=0;i<n-1;++i){
        B[A[i]-1]++;
    }
    for(int i=0;i<n;++i){
        cout<<B[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 5188
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    a=a*b;
    if(a<=c){
        printf("%d\n",a);
    }
    else{
        printf("%d\n",c);
    }
    return 0;

}


Measured memory_bytes: 128
#include<bits//stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    int d=0;
    int b[a];
    for(int i=0;i<a;i++){
        cin>>b[i];
    }
    sort(b,b+a);
    for(int j=0;j<a;j++){
        d+=b[j];
    }
    if(d%2==0){
        cout<<d/2<<endl;
        return 0;
    }
    else{
        for(int k=0;k<a;k++){
            if(b[k]%2==1){
                d-=b[k];
                cout<<d/2<<endl;
                return 0;
            }
        }
    }
}



Measured memory_bytes: 3148
def CheckEven(N):
    n = len(N)
    flag = True
    for i in range(n):
        flag = (N[i]%2==0)*flag
    return flag

n = int(input())
N = input().split()
N = [int(i) for i in N]

count = 0
while(CheckEven(N)):
    for i in range(n):
        N[i] = N[i]/2
    count = count + 1
print(count)
    


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	
	string str[8];
	
	for(int i = 0; i < 8; i++){
		cin >> str[i];
	}
	printf("90\n");
	for(int x = 0; x < 8; x++){
		for(int y = 7; y >= 0; y--){
			printf("%c", str[y][x]);
		}
		printf("\n");
	}
	
	printf("180\n");
	for(int y = 7; y >= 0; y--){
		for(int x = 7; x >= 0; x--){
			printf("%c", str[y][x]);
		}
		printf("\n");
	}
	
	printf("270\n");
	for(int x = 7; x >= 0; x--){
		for(int y = 0; y < 8; y++){
			printf("%c", str[y][x]);
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;


int main() {
	string S;
	cin >> S;
	vector<int>A(26);
	for (int i = 0; i < S.size(); ++i) {
		A[S[i] - 'a']++;
	}
	for (int i = 0; i < A.size(); ++i) {
		if (0 == A[i]) {
			cout << (char)('a' + i) << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 3748