akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void){
	
	double a, b, c, d, e, f;
	double x, y, A;

	while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
		A = e*a-b*d;

		x = (c*e-b*f)/A;
		y = (a*f-d*c)/A;
		if(x > -0.001 && x < 0.001)x = 0;
		if(y > -0.001 && y < 0.001)y = 0;
		printf("%.3lf %.3lf\n", x, y);
	}

	return 0;
}

Measured memory_bytes: 652
s = list(raw_input())
for op1 in '+-':
    for op2 in '+-':
        for op3 in '+-':
            exec 'ans = %s %s %s %s %s %s %s' % (s[0], op1, s[1], op2, s[2], op3, s[3])
            if ans == 7:
                print '%s%s%s%s%s%s%s=7' % (s[0], op1, s[1], op2, s[2], op3, s[3])
                exit()

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
const long long INF = numeric_limits<long long>::max();

int main(void) {
    int a, b; cin >> a >> b;
    if ((a * b) % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	char s[7];
	scanf("%s",s);
	if(strcmp(s,"Rainy")==0){
		printf("Sunny\n");
	}
	if(strcmp(s,"Sunny")==0){
		printf("Cloudy\n");
	}
	if(strcmp(s,"Cloudy")==0){
		printf("Rainy\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    while(true){
        int H = sc.nextInt();
        int W = sc.nextInt();
        if(H==0 && W == 0){
            break;
        }
        for(int y=0; y<H; y++){
            for(int x=0; x<W; x++){
                System.out.print("#");
            }
            System.out.println();
        }   
        System.out.println();
    }
 }
}


Measured memory_bytes: 37764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

int main(){
  int N, M;
  cin >> N >> M;
  vector<double> A(N);
  rep(i,N) cin >> A[i];
  priority_queue<double> q;
  rep(i,N) q.emplace(A[i]);
  LL ans=0;
  rep(i,M){
    LL a=q.top(); q.pop();
    a/=2;
    q.emplace(a);
  }
  rep(i,N){
    LL a=q.top(); q.pop();
    ans+=floor(a);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 2168
#include<stdio.h>
#include<math.h>
int main(void){
    int i,n,s[1000];
    double m,a,sum,sd;
    while(1){
        scanf("%d",&n);
        m=0;sum=0;
        if(n!=0){
            for(i=0;i<n;i++){
            scanf("%d",&s[i]);
            m+=s[i];
        }
        m/=n;
        for(i=0;i<n;i++){
            a=(s[i]-m)*(s[i]-m);
            sum+=a;
        }
        sum/=n;
        sd=sqrt(sum);
        printf("%.8lf\n",sd);
        }
        else if(n==0){
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2104
#!/usr/bin/env python3

s = int(input())

A = [s]
for i in range(1,1000000+1):
    if A[i-1] % 2 == 0:
        a = A[i-1] // 2
    else:
        a = A[i-1]*3+1
    if a in A:
        ans = i+1
        break
    else:
        A.append(a)

print(ans)


Measured memory_bytes: 9104
#include<bits/stdc++.h>
#define ft(i,l,r) for(register int i=l;i<=r;i++)
#define fd(i,r,l) for(register int i=r;i>=l;i--)
using namespace std;
long long n,k;
int main()
{
    cin>>n>>k;
    if(n*2<=k) cout<<n;
    else if(n%k==0) cout<<0;
    else cout<<min(n%k,abs(n%k-k));
    return 0;
}

Measured memory_bytes: 256
def top(n):
    return int(str(n)[0])

def bottom(n):
    return int(str(n)[-1])

n = int(input())
c = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1,n+1):
    c[top(i)][bottom(i)] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j]*c[j][i]
print(ans)

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int a,b,c,d,e,f;

int main(){
	cin >> a >> b >> c >> d >> e >> f;
	a *= 100; b *= 100;
	
	int nw = 1, ns = 0;
	for(int i = 0; i*a < f; i++){
		for(int j = 0; j*b + i*a < f; j++){
			for(int k = 0; c*k <= (i*a+b*j)/100 * e && c*k+i*a+j*b <= f; k++){
				for(int l = 0; c*k+l*d <= (i*a+b*j)/100 * e && c*k+d*l+a*i+b*j <= f; l++){
					if(i+j > 0 && (double)ns / (double)nw < (double)(k*c+l*d) / (double)(i*a+b*j)){
						ns = k*c + l*d;
						nw = i*a + b*j;
					}
				}
			}
		}
	}
	if(nw == 1) cout << a << " " << 0 << endl;
	else cout << nw+ns << " " << ns << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    string str;
    cin >> str;
    int ans = 0;
    for (int i = 0, j = str.length() - 1; i <= j; i++, j--) {
        if(str[i] != str[j]) {
            ans ++;
        }
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    s = input()
    t = input()

    c = 0
    ans = len(t)
    for i in range(len(s)-len(t)+1):
        c = 0
        now = i
        for tt in t:
            if s[now] != tt:
                c += 1
            now += 1
        ans = min(ans,c)
    print(ans)
if __name__=='__main__':
    main()


Measured memory_bytes: 9112
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

newUF n = VUM.replicate n (-1 :: Int)

root uf x = do
    p <- VUM.read uf x
    if p < 0
        then return x
        else do
            r <- root uf p
            VUM.write uf x r
            return r

same uf x y = liftM2 (==) (root uf x) (root uf y)

unite uf x y = do
    px <- root uf x
    py <- root uf y
    when (px /= py) $ do
        sx <- VUM.read uf px
        sy <- VUM.read uf py
        let (par, chld) = if sx < sy then (px, py)　else (py, px)
        VUM.write uf chld par
        VUM.write uf par (sx + sy) 

size uf x = do
    px <- root uf x
    s <- VUM.read uf px
    return $ abs s

main = do
    [n,m] <- getIntList
    ab <- fmap VU.fromList $ replicateM m $ do
        [a,b] <- getIntList
        return (a-1,b-1)
    
    let result = VU.create $ do
            vec <- VUM.replicate (m+1) (0::Int) 
            VUM.write vec m $ n * (n-1) `div` 2
            uf <- newUF n
            forM_ [m-1,m-2..0] $ \i -> do
                let (x, y) = ab VU.! i
                b <- same uf x y
                a <- VUM.read vec (i+1)
                if b then
                    VUM.write vec i a
                else do
                    nx <- size uf x
                    ny <- size uf y
                    unite uf x y
                    VUM.write vec i $ a - (nx * ny)
            return vec
    
    forM_ [1..m] $ \i -> do
        print $ result VU.! i

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    for (int i = n-1; i > 0; --i) {
        if (h[i-1] > h[i] + 1) {
            cout << "No" << endl;
            return 0;
        } else if (h[i-1] > h[i]) {
            --h[i-1];
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3764
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;

class Program
{
	static void Main(string[] args)
	{
		string s = Console.ReadLine();
		if(s.Contains("A") && s.Contains("B"))
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		}
	}
}

//string s = Console.ReadLine();
//int[] inputintArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = inputintArray[0];
//int W = inputintArray[1];
//int N = int.Parse(Console.ReadLine());
//int[] a = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

//Console.WriteLine(ans);
//Console.ReadKey();


Measured memory_bytes: 13140
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.Set;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int s = in.nextInt();

            Set<Integer> set = new HashSet<>();
            int ans = 1;
            while (true) {
                set.add(s);
                if (s % 2 == 0) {
                    s /= 2;
                } else {
                    s = s * 3 + 1;
                }
                ans++;
                if (set.contains(s)) {
                    out.println(ans);
                    return;
                }
            }
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 3 * 1e5 + 5;
const ll mod = 1e6 + 3;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
ll dp[N][3][4];
int n;
string s;
ll f(int i, int est, int sum){
    if(i == n)
        return est > 0 && sum == 0;//)return 1;
    if(est == 2 && sum == 0)return 1;
    ll &ans = dp[i][est][sum];
    if(ans != -1)return ans;
    ans = 0;
    int val = (sum * 10 + (s[i] - '0')) % 4;
    if(est == 0){
        ans += f(i + 1, 1, val);
        ans += f(i + 1, 0, sum);
    }
    if(est == 1){
        ans += f(i + 1, 1, val);
        ans += f(i + 1, 2, sum);
    }
    return ans;
}
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << '\n';
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}   

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  as <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  putStrLn $ if 22 <= sum as then "bust" else "win"

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384626433832795

int main() {
	int a, b;
	cin >> a >> b;
	cout << a*b << " " << (a + b) * 2 << endl;
}


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

int compare(const void *a,const void *b){
	if(*(long long int*)a-*(long long int*)b > 0)	return 1;
	if(*(long long int*)a-*(long long int*)b == 0)	return 0;
	if(*(long long int*)a-*(long long int*)b < 0)	return -1;
}

int main(){
	long long int N;
	long long int limit[5];
	int i;
	long long int ans;
	
	scanf("%lld",&N);
	for(i=0;i<5;i++)	scanf("%lld",&limit[i]);
	
	qsort(limit,5,sizeof(long long int),compare);
	
	if(limit[0]>=N)	printf("5");
	else{
		ans=0;
		ans+=N/limit[0];
		if(N%limit[0]!=0)	ans++;
		
		ans+=4;
		
		printf("%lld",ans);
	}
	
	return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char C[2200010];
char *ci = C, ct;
char D[2200010];
char *di = D;
void pakuri_sort(int N, ll A[], int ichi[]) {
	const int b = 8;
	ll tmp[200001];
	int tmp2[200001];
	rep(k, 6) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmp2[kazu[A[i] >> k * b & ((1 << b) - 1)]] = ichi[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			ichi[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp2[i];
		}
	}
}

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

	fread(C, 1, 2200010, stdin);
	int N = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';

	ll S[200000];
	int ichi[200001];
	rep(i, N) {
		ll s = 0;
		ichi[i] = ci - C;
		int k = 10;
		while ((ct = *ci++) >= 'a') {
			s = s * 27 + ct - '`';
			k--;
		}
		rep(i, k) s *= 27;
		S[i] = s;
	}
	pakuri_sort(N, S, ichi);
	int kazu = 0;
	int saidai = 0;
	ll mae = 0;
	rep(i, N) {
		if (S[i] != mae) {
			chmax(saidai, kazu);
			kazu = 1;
			mae = S[i];
		}
		else kazu++;
	}
	chmax(saidai, kazu);
	kazu = 0;
	mae = 0;
	
	rep(i, N) {
		if (S[i] != mae) {
			if (saidai == kazu) {
				char *tmp = C + ichi[i - 1];
				while (*tmp >= 'a') *di++ = *tmp++;
				*di++ = '\n';
			}
			kazu = 1;
			mae = S[i];
		}
		else kazu++;
	}
	if (saidai == kazu) {
		char* tmp = C + ichi[N - 1];
		while (*tmp >= 'a') *di++ = *tmp++;
		*di++ = '\n';
	}
	fwrite(D, 1, di - D, stdout);

	Would you please return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vd vector<double>
#define f(i,l,r) for(ll i=l;i<r;i++)
#define d(i,n,m) for(ll i=n;i>=m;i--)
#define P (ll)1e9+7
#define pb push_back
#define F first
#define S second
#define IP ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int offset[]={1,0,-1,0,1};
ll expo(ll a,ll x)
{
    if(a==0)
    return 0;
    if(x==0)
    return 1;
    ll ans=1;
    ans*=expo(a,x/2);
    ans*=ans;
    if(x&1)
    ans*=a;
    return ans;
}
int main()
{
    IP
    ll x;
    cin>>x;
    bool found=1;
    for(int i=0;i<=1001&&found;i++)
    {
        for(int j=-1001;j<=1001;j++)
        {
            if(expo(i,5)-expo(j,5)==x)
            {
                cout<<i<<" "<<j<<"\n";
                found=0;
                break;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3652
// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define in(x) 		scanf("%d", &x)
#define echo(x)		printf("%d", x)
#define inf 		(int)(1e18)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;

#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}

// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };


// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz

	int p;
	for(int i=0; i<5; i++){
		cin >> p;
		if(p==0){
			cout << i+1;
			return 0;
		}
	}

	return 0;
}  


Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>       // printf,scanf
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>  //sort,binarySearch
#include <functional> 
#include <iomanip> // setprecision
#include <utility>    // c+11 Array
#include <set>
#include <sstream>
#include <numeric>
#define PI 3.141592653589793238462643383279
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;

using namespace std;

long long gcd(long long n, long long m)
{
  return (n == 0) ? m : gcd(m % n,n);
}

int main(){

    long long A,B;
    cin >> A >> B;

    long long n = gcd(A,B);

    long long ans = 1;
    for(long long i = 2; i*i <= n; i++){
        if (n % i == 0) ans++;
        while(n % i == 0) {
            n /= i;
        }
    }
    if (n > 2) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int array[12] = {1,3,1,2,1,2,1,1,2,1,2,1};
    int x,y;
    cin >> x >> y;
    if(array[x-1] == array[y-1])cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

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

/*                                                                              
int main(void) {                                                                
    char str[21];                                                               
    int i;                                                                      
                                                                                
    scanf("%s", str);                                                           
    for (i = strlen(str) - 1; i >= 0; i--) {                                    
        putchar(str[i]);                                                        
    }                                                                           
    putchar('\n');                                                              
    return 0;                                                                   
}                                                                               
*/

int reverse() {                                                                 
    int c;                                                                      
    if ((c = getchar()) == '\n')                                                
        return;                                                                 
    reverse();                                                                  
    putchar(c);                                                                 
}

int main(void) {                                                                
    reverse();                                                                  
    putchar('\n');                                                              
    return 0;                                                                   }

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
using namespace std;

ll n, m, l, ans;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read(), m = read();
	REP(i, 1, m) l = read(), ans += l;
	if (ans > n) puts("-1");
	else printf("%lld\n", n - ans);
}

int main(){
	work();
	return 0;
}

Measured memory_bytes: 3764
#include <iostream>

using namespace std;

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    if(A==B){
        cout<<C<<endl;
    }
    else if(A==C){
        cout<<B<<endl;
    }
    else if(B==C){
        cout<<A<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
const int MAX = 11;
const int INF = (1<<20);
int D[MAX][MAX];
int n, pos;

void init(){
  for(int i = 0; i < MAX; i++)
    for(int j = 0; j < MAX; j++)
      D[i][j] = INF;

  pos = 0;
}

void solve(){

  for(int i = 0; i < MAX; i++)
    D[i][i] = 0;

  for(int k = 0; k < MAX; k++)
    for(int i = 0; i < MAX; i++)
      for(int j = 0; j < MAX; j++)
	D[i][j] = min(D[i][j],D[i][k]+D[k][j]);

  int city = -1, T = INF;

  for(int i = 0; i <= pos; i++){
    int tmp = 0;
    for(int j = 0; j <= pos; j++)
      tmp += D[i][j];
    
    if(T > tmp){
      city = i;
      T = tmp;
    }
  }
  cout << city << " " << T << endl;
}
int main(){
 
  while(cin >> n && n){
    init();
    for(int i = 0; i < n; i++){
      int f,t,c;
      cin >> f >> t >> c;
      pos = max(pos,max(f,t));
      D[f][t] = D[t][f] = c;
    }
    solve();
  }
  return 0;
}

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

int main()
{
    string n;
    cin >> n;
    string ans = "No";
    rep(i,3){
        if(n[i] == '7') ans = "Yes";
    }

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

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
ll dp[100005];
int main()
{
	dhoom;
	dp[0] = 0;
	int n;
	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		dp[i] = inf;
		ll power = 1;
		while(power <= i){
			dp[i] = min(1+ dp[i-power],dp[i]);
			power *= 6;
		}
		power = 1;
		while(power <= i){
			dp[i] = min(dp[i],1+dp[i-power]);
			power *= 9;
		}
	}
	
	cout << dp[n];
	return 0;
} 



Measured memory_bytes: 1024
# # Educational DP Contest E
# 方針：dp[i][v] := i-1番目までの物の中から，価値v以上を達成するように選んだ時の重さの最小値

# 入力
N, W = map(int, input().split())
weight = [0] * N
value = [0] * N
for i in range(N):
    w, v = map(int, input().split())
    weight[i] = w
    value[i] = v

# DPテーブル
max_v = sum(value)
dp = [[float("inf")] * (max_v + 1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
    for v in range(max_v+1):
        if v >= value[i]:       # i番目の物を選ぶ時
            dp[i+1][v] = min(dp[i][v - value[i]] + weight[i], dp[i][v])
        else:
            dp[i+1][v] = dp[i][v]

for v in range(max_v, -1, -1):
    if dp[N][v] <= W:
        ans = v
        break
print(ans)

Measured memory_bytes: 308040
import java.math.BigInteger;
import java.util.*;
public class Main {



public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  String s=sc.next();
  int ob=0;
  int cb=0;
  boolean check=false;
  Deque<Character> dq=new LinkedList<>();
  for(int i=0;i<n;i++) {
    dq.addLast(s.charAt(i));
  }
  
  Stack<Character> st=new Stack<>();
  for(int i=0;i<n;i++) {
   if(st.isEmpty()) {
     st.push(s.charAt(i));
     continue;
   }
   if(st.peek()=='('&&s.charAt(i)==')') {
     st.pop();
     continue;
   }
   st.push(s.charAt(i));
  
  }
   while(!st.isEmpty()) {
     if(st.peek()=='(') {
       dq.addLast(')');
       st.pop();
     }else {
       dq.addFirst('(');
       st.pop();
     }
   }
   for(char i:dq) {
     System.out.print(i);
   }
   System.out.println();


}
}
class Solution{

  public static int minSum(int arr[], int n, int k) 
  { 
          int dp[][][]=new int[n+1][k+1][100001];
          for(int i=0;i<=n;i++){
              for(int j=0;j<=k;j++){
                for(int kk=0;kk<100001;kk++)
                 dp[i][j][kk]=-1;
          }
          }
          int ans=solve(arr,n,n,k,dp,100000);
          return ans;
          
  } 
  static int solve(int arr[],int nn,int n,int k,int dp[][][],int prev){
     
 
    if(k==1){
          int ans=100001;

         for(int i=0;i<n;i++){
             ans=Math.min(ans,arr[i]);
         }
        
         return ans>prev?100001:ans;
  
      }
      if(n==0){
          return 100001;
      }
      if(dp[n][k][prev]!=-1) {
        return dp[n][k][prev];
      }
     int ans=100001;
     if(arr[n-1]<=prev){
     
     ans=Math.min(ans, Math.min(solve(arr,nn,n-1,k-1,dp,arr[n-1])+arr[n-1],solve(arr,nn,n-1,k,dp,prev)));

     }else{
     ans=Math.min(ans, solve(arr,nn,n-1,k,dp,prev));
     }
     
return dp[n][k][prev]=ans;
  }
  
 }








Measured memory_bytes: 27136
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k;
  
  ll N, K, C;
  cin >> N >> K >> C; C++;
  string s;
  cin >> s;
  s="z"+s;
  
  ll dp[MAX*2][2]={}, ep[MAX*2][2]={};
  for(i=1; i<=N; i++) {
    if(s[i]=='o') {
      dp[i][1]=dp[i][0]+1;
      if(i+C<N) chmax(dp[i+C][0], dp[i][1]);
      chmax(dp[i+1][0], dp[i][0]);
    }else {
      chmax(dp[i+1][0], dp[i][0]);
    }
  }
  
  for(i=N; i>=1; i--) {
    if(s[i]=='o') {
      ep[i][1]=ep[i][0]+1;
      if(i-C>=0) chmax(ep[i-C][0], ep[i][1]);
      chmax(ep[i-1][0], ep[i][0]);
    }else {
      chmax(ep[i-1][0], ep[i][0]);
    }
  }
  
  for(i=1; i<=N; i++) chmax(dp[i][0], max(dp[i-1][0], dp[i-1][1]));
  for(i=N; i>=1; i--) chmax(ep[i][0], max(ep[i+1][0], ep[i+1][1]));
  
  for(i=1; i<=N; i++) if(s[i]=='o') if(dp[i][0]+ep[i][0]<K) pt(i);
  
}



Measured memory_bytes: 8128
#include <bits/stdc++.h>
#define oo 100005
using namespace std;
int n, cap[oo], cnt, in[oo], flag;
long long w[oo];
struct edge {int ne, to;} e[oo * 2];
inline void add (int u, int v)
{e[++ cnt] = {cap[u], v}; cap[u] = cnt;}
long long dfs (int u, int fa)
{
    if(in[u] == 1) return w[u];
    long long maxn = 0, ret = 0, tmp;
    for(int i = cap[u], v; i; i = e[i].ne)
    {
        if((v = e[i].to) == fa) continue;
        w[u] -= w[v]; tmp = dfs(v, u);
        ret += tmp; maxn = max(maxn, tmp);
    }
    if(w[u] > 0) flag = 1;
    tmp = min((ret - maxn), ret / 2);
    if(-w[u] > tmp) flag = 1;
    w[fa] -= w[u], ret += 2 * w[u], w[u] = 0;
    return ret;
}
int main ()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; ++ i)
    scanf("%lld", &w[i]);
    if(n == 2) {puts(w[1] == w[2] ? "YES" : "NO"); return 0;}
    for(int i = 1, x, y; i < n; ++ i)
    {
        scanf("%d%d", &x, &y);
        add(x, y); add(y, x);
        ++ in[x], ++ in[y];
    }
    for(int i = 1; i <= n; ++ i)
    if(in[i] != 1) {if(dfs(i, 0)) flag = 1; break;}
    puts(flag ? "NO" : "YES"); return 0;
}

Measured memory_bytes: 8704
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>

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

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

const ll mod = 1e9 + 7;


int main(){
    long long k,a,b;
    cin >> a >> b >> k;

    long long takahashi,aoki;
    if (k <= a) {
        takahashi = a - k;
        aoki = b;
    }
    else {
        takahashi = 0;
        if (b < abs(a-k)){
            aoki = 0;
        }
        else aoki = b - abs(a-k);
    }

    cout << takahashi << " " << aoki << endl;
}

Measured memory_bytes: 256
from sys import exit, stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
A.sort()
for i, a in enumerate(A):
    if N % 2 == 1:
        try:
            assert a == (i + 1) // 2 * 2
        except AssertionError:
            print(0)
            exit()
    else:
        try:
            assert a == i // 2 * 2 + 1
        except AssertionError:
            print(0)
            exit()
ans = pow(2, N // 2, 10 ** 9 + 7)
print(ans)

Measured memory_bytes: 13812
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	//vector<ll> cnt(5, 0);
	ll cnt[5] = {};
  	string s = "MARCH";
	for(int i = 0; i < n; i++)
	{
		string t;
		cin >> t;
		for(int j = 0; j < 5; j++)
		{
			if(t[0] == s[j])
				cnt[j]++;
		}
	}
	ll ans = 0;
	for(int i = 0; i < 5; i++)
	{
		for(int j = i + 1; j < 5; j++)
		{
			for(int k = j + 1; k < 5; k++)
			{
				ans += cnt[i] * cnt[j] * cnt[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def max(a, b)
  a > b ? a : b
end

N = gets.to_i
arr = gets.split.map(&:to_i)
dp = N.times.map{[0]*(N)}
N.times.each do |i|
  dp[i][i] = arr[i]
end

(1..(N-1)).each do |length|
  (0..(N-1-length)).each do |left|
    right = left + length
    dp[left][right] = max(arr[left] - dp[left + 1][right], arr[right] - dp[left][right - 1])
  end
end
puts dp.first.last

Measured memory_bytes: 74364
import java.util.*;
 
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int x = sc.nextInt();
    int[] a = new int[n];
    for(int i=0; i<n; i++){
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    int count = 0;
    for(int i=0; i<n; i++){
      if(x >= 0 && x >= a[i]){
        x -= a[i];
      } else {
        count++;
      }
    }
    if(count != 0){
      System.out.println(a.length-count);
    } else if(count == 0 && x == 0){
      System.out.println(a.length);
    } else {
      System.out.println(a.length-1);
    }

    sc.close();
  }
}

Measured memory_bytes: 22996
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
//#pragma GCC target ("avx,avx2,tune=native")
//#pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/rope>

using namespace __gnu_pbds; 
using namespace __gnu_cxx;
using namespace std;
using ll = long long;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define precision(n) fixed<<setprecision(n)

#ifdef LOCAL
    #include "debug.h"
#else
    #define debug(...) 42
#endif

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("output.txt","w",stderr);
    #endif
}
template<typename T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;
template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T> >;
template<typename T> void done(T ans) {cout << ans << "\n"; exit(0);}

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);

clock_t time_p=clock();
void printTime(){
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}


const int N = 2e5 + 5;
const int mod = 1e9 + 7;

int main() {
    io();
    string s;
    cin >> s;
    int a[s.size() + 1];
    memset(a, 0, sizeof a);
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '<') {
            a[i + 1] = max(a[i] + 1, a[i + 1]);
        }
    }
    for (int i = s.size() - 1; i >= 0; i--) {
        if (s[i] == '>') {
           a[i] = max(a[i], a[i + 1] + 1);
        }
    }
    long long ans = 0;
    for (int i = 0; i <= s.size(); i++) {
        ans += a[i];
    }
    cout << ans << '\n';
}



        

Measured memory_bytes: 2844
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <complex>

using namespace std;

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

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
#define X real()
#define Y imag()

typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef vector<P> Pol;

const D INF = 1e40;
const D EPS = 1e-5;
const D PI = acos(-1);

int sign(D r){ return (r < -EPS) ? -1 : (r > EPS) ? 1 : 0; }
bool eq(D a, D b){ return abs(b - a) < EPS; }
bool near(P a, P b){ return abs(b - a) < EPS; }

D dot(P a, P b){ return a.X * b.X + a.Y * b.Y; }
D cross(P a, P b){ return a.X * b.Y - a.Y * b.X; }
P vec(L a){ return a.second - a.first; }

P pLL(L a, L b){ return a.first + vec(a) * (cross(vec(b), b.first - a.first) / cross(vec(b), vec(a))); }
int main(){
  int N;
  while(cin>>N && N){
    vector<L> l;
    REP(i, N){
      double a, b, c, d;
      cin>>a>>b>>c>>d;
      l.push_back(L(P(a, b), P(c, d)));
    }
    int ans = 1;
    for(int i = 0; i < N; i++){
      int cnt = 1;
      vector<P> crs;
      for(int j = 0; j < i; j++){
        if(!sign(cross(vec(l[i]), vec(l[j])))) continue;
        P p = pLL(l[i], l[j]);
        if(!(abs(p.X) < 100 - EPS && abs(p.Y) < 100 - EPS)) continue;
        bool ok = true;
        for(int k = 0; k < crs.size(); k++){
          if(eq(crs[k].X, p.X) && eq(crs[k].Y, p.Y)){
            ok = false;
            break;
          }
        }
        if(ok){
          crs.push_back(p);
          cnt++;
        }
      }
      ans += cnt;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1248
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t N, M, K;
    intmax_t A[200000], B[200000];
    intmax_t time = 0, num_a = 0, num_b = 0, ans = 0;

    scanf("%jd%jd%jd", &N, &M, &K);
    for (size_t i = 0; i < N; i++) {
        scanf("%jd", &A[i]);
    }
    for (size_t i = 0; i < M; i++) {
        scanf("%jd", &B[i]);
    }

    for (size_t i = 0; i < N; i++) {
        if ((time + A[i]) <= K) {
            time += A[i];
            num_a++;
        } else {
            break;
        }
    }
    for (size_t i = 0; i < M; i++) {
        if ((time + B[i]) <= K) {
            time += B[i];
            num_b++;
        } else {
            break;
        }
    }

    ans = num_a + num_b;

    while ((num_b < M) && (num_a > 0)) {
        num_a--;
        time -= A[num_a];

        while ((num_b < M) && ((time + B[num_b]) <= K)) {
            time += B[num_b];
            num_b++;
        }

        if (ans < (num_a + num_b))
            ans = num_a + num_b;
    }

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 5272
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = (long)sc.nextInt();
    long Ans=0;
    for(int i=1;i<N;i++){
      if(N%i==0){
        Ans+=N/i-1;
      }else{
        Ans+=N/i;
      }
    }
    System.out.println(Ans);
  }
}

Measured memory_bytes: 27196
# coding: utf-8

w, h, N = list(map(int, input().split()))

rect = [0, w, 0, h]
for i in range(N):
    x, y, a = list(map(int, input().split()))
    rect[a - 1] = (lambda c, r, p: [r, c][[c < r, c > r][p]])([x, y][a > 2], rect[a - 1], a % 2)

length = lambda x: [x, 0][x < 0]
print(length(rect[1] - rect[0]) * length(rect[3] - rect[2]))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>

using namespace std;

int main()
{
    int n;cin>>n;
    int m;cin>>m;
    int sum=0;
    for(int i=0;i<m;++i){
        int tmp;cin>>tmp;
        sum+=tmp;
    }
    sum = sum>n?-1:n-sum;
    cout<<sum<<endl;
    
    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> c(h);
    For(i,0,h) cin >> c[i];

    For(i,0,(1<<h)){
        For(j,0,(1<<w)){
            int cnt = 0;
            For(s,0,h){
                if((i>>s)&1) continue;
                For(t,0,w){
                    if((j>>t)&1) continue;
                    if(c[s][t] == '#') cnt++;
                }
            }
            if(cnt == k) ans ++;
        }
    }
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int main()
{
	int a, b, c;
	while (scanf("%d%d%d", &a, &b, &c) != EOF)
	{
		if (a == b)
			printf("%d\n", c);
		if (b == c)
			printf("%d\n", a);
		if (a == c)
			printf("%d\n", b);
	}
	return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var h, m, c int
	for i := 0; i < n; i++ {
		fmt.Scan(&h)
		if h >= m {
			m = h
			c++
		}
	}

	fmt.Println(c)
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
	int a,b,ab,o;
	int dummy;
	char type[10];
	a=b=ab=o=0;
	while(1) {
		if(scanf("%d,%s",&dummy,type)==-1)break;
		if(type[0]=='A') {
			if(type[1]=='B')ab++; else a++;
		} else if(type[0]=='B')b++;
		else if(type[0]=='O')o++;
	}
	printf("%d\n",a);
	printf("%d\n",b);
	printf("%d\n",ab);
	printf("%d\n",o);
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for(int i=0; i<n; i++){
        int h=0;
        cin >> h;
        if(h>=k){
            ans++;
        }
    }

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

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

int main() {
    ll n;
    cin >> n;
    if (n%2==1) printf("%.15f", (double)(n/2+1)/n);
    else printf("%.15f", (double)(n/2)/n);
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define FOR(j, a, b) for(int j = (a); j <= (b); j + 2)
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

signed main(void)
{
	int q; cin >> q;
	int l[q], r[q]; rep(i, q) cin >> l[i] >> r[i];
	bool f[100001];
	int c[100002];
	
	rep(i, 100001) f[i] = false;
	rep(i, 100001) c[i] = 0;
	f[0] = f[1] = true;
	for (int i = 2; i < 100001; i++)
	{
		if (f[i])
			continue;
		for (int j = i + i; j < 100001; j+=i)
			f[j] = true;
	}
	for(int i = 3; i < 100001; i++)
		if (!f[i] && !f[(i + 1) / 2])
			c[i] += 1;
	for (int i = 0; i < 100001; i++) c[i + 1] += c[i];
	rep(i, q)
		cout << c[r[i]] - c[l[i] - 1] << endl;
	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>

map<int,int> mp;

signed main(){
	
	int n;cin >> n;
	int dai = 0,zyun;
	rep(i,n)
	{
		int a,b;cin>>a>>b;
		if(a>dai)
		{
			dai = a;
			zyun = b;
		}
	}
	
	cout << dai+zyun<<endl;
	
}

//cout << ans << endl;

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

int main(){
  //入力
  int N;
  cin >>N;
  vector <string> S(N);
  vector <string> A(N);
  vector <string> C(N);
  for (int i=0;i<N;i++){
    cin>> S[i];
    A[i]=S[i];
    C[i]=S[i];//Cにオリジナル保持
  }
  //バブルソート
  string temp;
  bool flag=1;
  while(flag){
    flag=0;
    for (int j=N-1;j>0;j--){
      if(S[j].at(1)<S[j-1].at(1)){
        temp=S[j-1];
        S[j-1]=S[j];
        S[j]=temp;
        flag=1;
      }
    }
  }
  for (int i=0;i<N-1;i++){
    cout<<S[i]<<" ";
  }
  cout<<S[N-1]<<endl;
  cout<<"Stable"<<endl;
 
  
  //選択ソート
  for(int i=0;i<N;i++){
    int minj=i;
    for (int j=i;j<N;j++){
      if(A[j].at(1)<A[minj].at(1)){
        minj =j;
      }
    }
    string temp=A[i];
    A[i]=A[minj];
    A[minj]=temp;
  }
  for (int i=0;i<N-1;i++){
    cout<<A[i]<<" ";
  }
  cout<<A[N-1]<<endl;
  bool flagb=1;
  for(int i=0;i<N;i++){
    for (int j=i+1;j<N;j++){
      for (int a=0;a<N;a++){
        for(int b=a+1;b<N;b++){
          if((C[i].at(1)==C[j].at(1))&&(C[i]==A[b])&&(C[j]==A[a])){
            if(flagb){
              cout<<"Not stable"<<endl;
              flagb=0;
            }
          }
        }
      }
    }
  }
  if(flagb) cout<<"Stable"<<endl;

  return 0;
}


        

        



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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define P				pair<int, int>

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; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main() {
	int k, s; cin >> k >> s;

	int cnt = 0;
	REPE( i, k ) {
		REPE( j, k ) {
			if( 0 <= s - i - j && s - i - j <= k ) cnt++;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <tuple>
#include <vector>
#include <complex>
#include <cstdio>
using namespace std;
typedef complex<double> P;
typedef tuple<double,double,double> tddd;
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}
int main(){
	int N,M;
	for(;scanf("%d",&N),N;){
		vector<tddd> v(N);
		for(int i=0;i<N;i++){
			double x,y,r;
			scanf("%lf%lf%lf",&x,&y,&r);
			v[i]=make_tuple(x,y,r);
		}
		for(scanf("%d",&M);M--;){
			double x1,y1,x2,y2;
			scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
			P A(x1,y1),B(x2,y2);
			double a=y2-y1;
			double b=-x2+x1;
			double c=-y1*b-x1*a;
			for(auto &e:v){
				double d=a*get<0>(e)+b*get<1>(e)+c;
				double x=sqrt(get<2>(e)*get<2>(e)*(a*a+b*b)-d*d);
				P X(get<0>(e) + (-a*d+b*x)/(a*a+b*b),get<1>(e) + (-b*d-a*x)/(a*a+b*b));
				P Y(get<0>(e) + (-a*d-b*x)/(a*a+b*b),get<1>(e) + (-b*d+a*x)/(a*a+b*b));
				if((dot(X-A,B-A)>0&&dot(X-B,A-B)>0) || (dot(Y-A,B-A)>0&&dot(Y-B,A-B)>0)){
					puts("Safe");
					goto NEXT;
				}
			}
			puts("Danger");
			NEXT:;
		}
	}
}

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

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rep2(i,a,b,c) for(i=a;i<=b;i+=c)
#define maxn 200000
#define ll long long

ll ar[maxn],pref[maxn],suff[maxn];

int main(){
	int N,i;
	cin>>N;
	rep(i,0,N-1){
		cin>>ar[i];
		pref[i]=ar[i];
		suff[i]=ar[i];
	}
	pref[0]=ar[0];
	rep(i,1,N-1){
		pref[i]+=pref[i-1];
	}
	suff[N-1]=ar[N-1];
	for(i=N-2;i>=0;i--){
		suff[i]+=suff[i+1];
	}
	ll has=LLONG_MAX;
	rep(i,0,N-2){
		has=min(has,abs(pref[i]-suff[i+1]));
	}
	cout<<has<<"\n";
}


Measured memory_bytes: 4992
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int a[105];

int main()
{
	int n, m;
	int ans = 0;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)	scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++){
		ans += min(fabs(a[i] - 0), fabs(a[i] - m));
	}
	printf("%d\n", 2 * ans);
	return 0;
}

Measured memory_bytes: 128
n , m = map(int, input().split(' '))
s = [0,2,5,5,4,5,6,3,7,6]
a = list(map(int, input().split(' ')))
r = []
for i in range(len(a)):
    r.append([s[a[i]],a[i]])
r.sort()
d = [-1]*(n+1)
d[0] = 0
for i in range(1,n+1):
    j = 0
    while j < len(a):
        if i-s[r[j][1]] < 0:
            j += 1
        elif d[i-s[r[j][1]]] >= 0:
            d[i] = d[i-s[r[j][1]]] +1
            break
        else:
            j+= 1
result = []
a.sort(reverse = True)
while n > 0:
    j = 0
    while j < len(a):
        if n < s[a[j]]:
            j += 1
        elif d[n-s[a[j]]] +1 == d[n]:
            result.append(a[j])
            n -= s[a[j]]
            break
        else:
            j += 1
print(''.join(list(map(str, result))))

Measured memory_bytes: 3700
h, w = map(int, input().split())
l = []
for h_ind in range(1, h+1):
    l.append(input())

for h_ind in range(0, h):
    for w_ind in range(0, w):
        if l[h_ind][w_ind] == '#':
            print('#', end='')
            continue
        res = 0
        for dx in range (-1, 2):
            for dy in range(-1, 2):
                if dx == 0 and dy == 0:
                    continue
                if h_ind+dx < 0 or h_ind+dx >= h or w_ind+dy < 0 or w_ind+dy >= w:
                    continue
                if l[h_ind+dx][w_ind+dy] == '#':
                    res +=1
        print(res, end='')
    print('')


Measured memory_bytes: 3444