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

int prime(int x);

int main(void){
    int n;
    int x;
    int retval=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        retval+=prime(x);
    }
    printf("%d\n",retval);
    return 0;
}

int prime(int x){
    if(x==1){return 0;}
    if(x==2){return 1;}
    for(int i=2;i<sqrt(x)+1;i++){
        if ((x/i)*i==x){return 0;}
    }
    return 1;
}



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

int main(void){
    int n,m,i;
    char suit,j;
    int s[]={0,1,1,1,1,1,1,1,1,1,1,1,1,1};
    int h[]={0,1,1,1,1,1,1,1,1,1,1,1,1,1};
    int c[]={0,1,1,1,1,1,1,1,1,1,1,1,1,1};
    int d[]={0,1,1,1,1,1,1,1,1,1,1,1,1,1};
    scanf("%d",&n);
    for(i=0;i<=n;i++){
        scanf("%c %d%c",&suit,&m,&j);
        if(suit=='S')s[m]=0;
        if(suit=='H')h[m]=0;
        if(suit=='C')c[m]=0;
        if(suit=='D')d[m]=0;
    }
    for(i=1;i<14;i++){
        if(s[i]) printf("S %d\n",i);
    }
    for(i=1;i<14;i++){
        if(h[i]) printf("H %d\n",i);
    }
    for(i=1;i<14;i++){
        if(c[i]) printf("C %d\n",i);
    }
    for(i=1;i<14;i++){
        if(d[i]) printf("D %d\n",i);
    }
    return 0;
}


Measured memory_bytes: 2100
# coding: utf-8
a,b,c=(int(x) for x in input().split())
x=0
if a>b:
    x=a
    a=b
    b=x
if a>c:
    x=a
    a=c
    c=x
if b>c:
    x=b
    b=c
    c=x
    
print("{} {} {}".format(a,b,c))


Measured memory_bytes: 5604
import scala.io.StdIn

object Main extends App {
  val n  = StdIn.readLine().toInt
  val p :Array[Int] = StdIn.readLine().split(" ").map(_.toInt).sorted

  def solve(n: Int, p: Array[Int]): Int = {
    val m = n / 2
    if (p(m - 1) == p(m)) 0
    else if (p(m - 1) + 1 == p(m)) 1
    else p(m) - p(m - 1)
  }

  println(solve(n, p))
}
  



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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (c < b)
	{
		swap(c, b);
	}
	
	if (b < a)
	{
		swap(b, a);	
	}
	
	if (c < b)
	{
		swap(c, b);
	}	
	cout << a << ' ' << b << ' ' << c << endl;
	
	return 0;
}

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

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

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            ArrayDeque<String> deq = new ArrayDeque<>();
            for (int i = 0; i < n; i++) {
                String a = in.next();
                if (i % 2 == 0) {
                    deq.offerLast(a);
                } else {
                    deq.offerFirst(a);
                }
                if (n == 1) {
                    break;
                }
            }
            for (int i = 0; i < n; i++) {
                if (n % 2 != 0 && n != 1) {
                    out.print(deq.pollLast() + " ");
                } else {
                    out.print(deq.pollFirst() + " ");
                }
            }
            out.println();
        }
    }

    static boolean permutation_2(String s, String t) {
        if (s.length() != t.length()) {
            return false;
        }

        int[] letters = new int[256];

        char[] s_array = s.toCharArray();
        for (char c : s_array) {
            letters[c]++;
        }

        for (int i = 0; i < t.length(); i++) {
            int c = (int) t.charAt(i);
            if (--letters[c] < 0) {
                return false;
            }
        }
        return true;
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public char nextChar() {
            return next().charAt(0);
        }

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

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

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

    }
}


Measured memory_bytes: 68272
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;
int h,w;
ll dp[1010][1010];

char field[1010][1010];

int main() {
  cin >> h >> w;
  rep(i,h+10){
    rep(j,w+10){
      dp[i][j]=0;
    }
  }
  
  rep(i,h){
    rep(j,w){
      cin >> field[i][j];
    }
  }
  dp[0][0]=1;
  rep(i,h){
    rep(j,w){
      dp[i][j]%=MOD;
      if(i+1<h && field[i+1][j]=='.')dp[i+1][j]+=dp[i][j];
      if(j+1<w && field[i][j+1]=='.')dp[i][j+1]+=dp[i][j];
    }
  }
  cout << dp[h-1][w-1]%MOD << endl;
  
}

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

int main()
{       double x1;
        double x2;
        double y1;
        double y2;
        double product1;
        double product2;
        double newproduct;
        double result;
        cin>>x1>>y1>>x2>>y2;
         product1=(x1-x2)*(x1-x2);
          product2= (y1-y2)*(y1-y2);
       newproduct= product1+product2;

        result=sqrt(newproduct);
        cout.precision(19);
        cout<<result<<endl;
}



Measured memory_bytes: 3300
using System;

class summation
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        while (n != 0)
        {
            
            long sum = 0;
            int[] num = new int[n];
            for (int i = 0; i < n; i++) num[i] = int.Parse(Console.ReadLine());
            long max = -100000;
            for (int i = 0; i < n; i++)
            {
                for (int j = i; j < n; j++)
                {
                    sum += num[j];
                    if (sum > max) max = sum;
                }
                sum = 0;
            }
            Console.WriteLine(max);
            n = int.Parse(Console.ReadLine());
        }
        
    }
}

Measured memory_bytes: 9128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {

	static long changecount = 0;
   public static void main(String args[]) throws IOException{

	   Scanner sc = new Scanner(System.in);
	   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	   int n = Integer.parseInt( br.readLine()  );

	   Tree tree = new Tree();

	   /*
	   tree.insert(30);
       tree.insert(88);
       tree.insert(12);
       tree.insert(1);
       tree.insert(20);
       tree.insert(17);
       tree.insert(25);
       tree.inorder(tree.root);
       System.out.println();
       tree.preorder(tree.root);
       */

       for(int i = 0; i < n ; i++){

    	   String[] string =  br.readLine().split(" ");
    	   if( string[0].equals("insert") ){
    		   tree.insert( Integer.parseInt(string[1]) );
    	   }
    	   else if(string[0].equals("print")) {
    		   tree.inorder(tree.root);
    	       System.out.println();
    	       tree.preorder(tree.root);
    	       System.out.println();
    	   }
    	   else if(string[0].equals("find")) {
    		   //System.out.println( tree.find( tree.root, Integer.parseInt(string[1]) ) );
    		   tree.find( tree.root, Integer.parseInt(string[1]) );
    	   }
       }



   }


}



class Node{

	int  key;
	Node left;
    Node right;
    Node parent;

    Node(int x) {
        key = x;
        left = null;
        right = null;
        parent = null;
    }

}




class Tree{

	Node root = null;


	void insert( int date ){

		Node z = new Node(date);
		Node y = null;
		Node x = root;

		while(x != null){
			 y = x ;// ???????¨????
			 if( z.key < x.key ){
				 x = x.left; // ?????????????§????
			 }
			 else{
				 x = x.right; // ?????????????§????
			 }

		}

		z.parent = y;

		if ( y == null ){
            root = z;
		}
		else if(z.key < y.key){
			y.left = z; // z ??? y ?????????????????????

		}
		else{
			y.right = z ;// z ??? y ?????????????????????
		}


	}


	void find(Node tree, int serch){


		while (tree != null) {

			if( tree.key == serch ){
				System.out.println("yes");
				return ;
			}
			else if(tree.key > serch ){
                 tree = tree.left;
			}
			else{
				tree = tree.right;
			}
	    }
		System.out.println("no");
       return ;
	}


	 void preorder(Node tree ) {

	        if (tree != null) {
	       	 System.out.print(" " + tree.key);
	        	preorder(tree.left);

	           preorder(tree.right);
	       }
	}

	    void inorder (Node tree) {

	    	         if (tree != null) {

	    	        	inorder(tree.left);
	    	            System.out.print(" " + tree.key);
	    	            inorder(tree.right);
	    	        }
	     }


	    void postorder (Node tree) {
	        if (tree != null) {

	        	postorder(tree.left);
	        	postorder(tree.right);
	            System.out.print(" " + tree.key);
	       }
	}




}

Measured memory_bytes: 141364
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String str;
        int len;
        str = input.next();
        len = str.length();
        int q;
        q = input.nextInt();
        String qi,p;
        int a,b;
        for (int i = 0; i < q; i++){
            qi = input.next();
            if (qi.equals("print")){
                a = input.nextInt();
                b = input.nextInt();
                System.out.println(str.substring(a,b+1));
            } else if (qi.equals("reverse")){
                a = input.nextInt();
                b = input.nextInt();
                StringBuffer sb = new StringBuffer(str.substring(a,b+1));
                str = str.substring(0,a) + sb.reverse() + str.substring(b+1,len);
            } else {
                a = input.nextInt();
                b = input.nextInt();
                p = input.next();
                str = str.substring(0,a) + p + str.substring(b+1,len);
            }
        }
    }
}


Measured memory_bytes: 29656
#include <bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F_(i,a,b) for(int i=(a);i>=(b);--i)
#define G(i,u) for(int i=Head[a];i;i=Next[i])

typedef long long ll;
typedef double db;
typedef long double ld;

template<typename T> inline T max(T& a, T b) { return a>b?a:a=b; }
template<typename T> inline T min(T& a, T b) { return a<b?a:a=b; }

const int N = 300005;

char s[N]; int w[N], e[N];

int main() {
	
	int n;
	scanf("%d%s", &n, s+1);
	F(i,1,n) e[i] = e[i-1]+(s[i]=='W');
	F_(i,n,1) w[i]= w[i+1]+(s[i]=='E');
	
	int ans = N;
	F(i,1,n) min(ans,e[i-1]+w[i+1]);
	printf("%d\n", ans);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector <int> card(N);
  for (int i=0;i<N;i++)
  {
    cin >> card[i];
  }
  sort (card.begin(),card.end());
  reverse (card.begin(),card.end());
  int alice=0,bob=0;
  for (int i=0;i<N;i++)
  {
    if (i%2 == 0)
    {
      alice += card[i];
    }
    if (i%2 == 1)
    {
      bob += card[i];
    }
  }
  cout << alice - bob << endl;
}


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

namespace AtCoder
{
    static class E_DividingChocolate
    {
        public static void Main()
        {
            var values = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int h = values[0];
            int w = values[1];
            int k = values[2];

            int minSplitN = w / k + h - 1;

            var integral = new int[h+1][];
            var rowsInt = new int[h][];
            integral[0] = new int[w+1];
            for (int y = 1; y <= h; y++)
            {
                integral[y] = new int[w + 1];
                var temp = Console.ReadLine().ToCharArray();
                for (int x = 1; x <= w; x++)
                {
                    integral[y][x] = integral[y][x - 1] + temp[x - 1] - '0';
                    integral[y][x - 1] += integral[y - 1][x - 1];
                }
                integral[y][w] += integral[y - 1][w];
            }

            var rowIndex = new int[h+1];
            rowIndex[0] = 0;
            for (int bits = 0; bits < 1 << (h-1); bits++)
            {
                int activeRowN = 0;
                int splitH = 0;
                int prevY = 0;
                for (int y = 1; y < h; y++)
                {
                    if ((bits & 1 << (y-1)) != 0)
                    {
                        if (integral[y][w] - integral[prevY][w] > k)
                            rowIndex[++activeRowN] = y;
                        prevY = y;
                        splitH++;
                    }
                }
                if (integral[h][w] - integral[prevY][w] > k)
                    rowIndex[++activeRowN] = h;

                if (activeRowN == 0)
                {
                    minSplitN = Math.Min(minSplitN, splitH);
                    continue;
                }

                int splitW = 0;
                int prevX = 0;

                bool canSplit = true;
                for (int x = 1; x <= w; x++)
                {
                    canSplit = true;
                    for (int i = 1; i <= activeRowN; i++)
                    {
                        int y0 = rowIndex[i - 1];
                        int y1 = rowIndex[i];
                        int whiteN = integral[y1][x] - integral[y1][prevX] - integral[y0][x] + integral[y0][prevX];
                        if (!(canSplit &= whiteN <= k))
                            break;
                    }

                    if (!canSplit)
                    {
                        x--;
                        if (prevX == x)
                            break;
                        prevX = x;
                        splitW++;
                    }
                }
                if (canSplit)
                {
                    minSplitN = Math.Min(minSplitN, splitH + splitW);
                    continue;
                }
            }
            Console.WriteLine(minSplitN);
        }
    }
}


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

using namespace std;

typedef long long ll;

/// The definitions in this library are as below.
#define rI readInt
#define rL readLong
#define rC readChar
#define rC2 readChar2
#define rS readString

#define pb push_back

#define acc accumulate

#define FOR(i, a, b) for(int i=(a); i<=(b); i++)
#define FOR0(i, a, b) for(int i=(a); i<(b); i++)
namespace __library_79brue{
    /// This is a C++ library which improves the programming speed by \
        defining frequently used data structures or algorithms.       \
        This library can be freely used without any copyrights,       \
        but I recommend not to change the name of this library.       \
        Made by 79brue                                                \
        2019

    /// The functions or structures in this library are as below.
    /// quit()
    /// readInt() readLong() readChar() readChar2() readString()

    /// terminates the program
    inline void quit(){
        exit(0);
    }

    /// reads an integer
    inline void readInt(int& _x){
        scanf("%d", &_x);
    }

    /// reads a long-long integer
    inline void readLong(ll& _x){
        scanf("%lld", &_x);
    }

    /// reads a character
    inline void readChar(char& _x){
        scanf(" %c", &_x);
    }

    /// reads a character, the character may be space or line-break, etc...
    inline void readChar2(char &_x){
        scanf("%c", &_x);
    }

    inline void readString(char* _x){
        scanf("%s", _x);
    }

    inline int readLine(char* _x, int limit){
        if(!fgets(_x, limit, stdin)) quit();
        int _y = strlen(_x);
        while(_x[_y-1] == '\n' or _x[_y-1] == '\r') _y--;
        return _y;
    }
}
using namespace __library_79brue;

int n;
int d[52];
int ans;

int main(){
    scanf("%d", &n);
    FOR(i, 1, n) rI(d[i]);
    FOR(i, 1, n) FOR(j, i+1, n) ans += d[i] * d[j];
    printf("%d", ans);
}


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

#define ll long long
#define endl '\n'

int sp[100001];

void bsf(vector<vector<int>>& G) {
    queue<int> Q;
    Q.push(1);
    sp[1] = 1;
    while (!Q.empty()) {
        int t = Q.front();
        Q.pop();
        for (auto& c : G[t]) {
            if (!sp[c]) {
                sp[c] = t;
                Q.push(c);
            }
        }
    }
}

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

    int n, m;
    cin >> n >> m;
    int a, b;
    vector<vector<int>> graph(n + 1, vector<int>());
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    // for (auto& r : graph) {
    //     for (auto& e : r) cout << e << ' ';
    //     cout << endl;
    // }
    bsf(graph);
    bool completed = true;
    for (int j = 1; j <= n; j++) {
        if (!sp[j]) {
            completed = false;
            break;
        }
    }
    if (completed) {
        cout << "Yes" << endl;
        for (int j = 2; j <= n; j++) cout << sp[j] << endl;
    } else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 10252
<?php

$stdin1 = trim(fgets(STDIN));
$stdin1 = explode(" ", $stdin1);
$stdin2 = trim(fgets(STDIN));
$stdin2 = explode(" ", $stdin2);
$stdin3 = trim(fgets(STDIN));

if ($stdin3 === $stdin1[0]) {
  $stdin2[0] = $stdin2[0] - 1;
} else {
  $stdin2[1] = $stdin2[1] - 1;
}

echo $stdin2[0] . ' ' .  $stdin2[1];

Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;
 
int main() {
	
	uint N;
	cin >> N;
	
	vector<pair<uint, uint>> A(N);
	for(uint i=0; i<N; i++) {
		cin >> A[i].first;
		A[i].second = i;
	}
	
	vector<pair<uint, uint>> B(N);
	for(uint i=0; i<N; i++) {
		cin >> B[i].first;
		B[i].second = i;
	}

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	
	bool dpl = false;
	for(uint i=0; i<N; i++) {
		if(A[i].first > B[i].first) {
			cout << "No";
			return 0;
		}		
		dpl |= (i < N -1) && (A[i+1].first <= B[i].first);
	}
	
	if(dpl) {
		cout << "Yes";
		return 0;
	}
	
	vector<uint> rpl(N);
	for(uint i=0; i<N; i++) {
		rpl[B[i].second] = A[i].second;
	}
	
	uint cnt = 0;
	uint nxt = 0;
	while(rpl[nxt] != 0) {
		cnt++;
		nxt = rpl[nxt];
	}
	
	if(cnt < N - 1) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	
	return 0;
}

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

int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r ;
	if(0 <= x - r  && x + r <= W){
		if(0 <= y - r && y + r <= H){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		cout << "No" << endl;
	}
	return 0;
} 

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

#define MOD 998244353


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> h(n);
    
    for(ll i = 0; i<n; i++){
        cin>>h[i];
    }
    sort(h.begin(),h.end());
    
    ll total = 0;
    for(ll i = 0; i<n-k; i++){
        total += h[i];
    }
    
    cout<< total << endl;
    return 0;
}





Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N, M, Q;
vector<int> G[100005];
int idx[100005][11];
int color[100005][11];

void dfs(int v, int d, int id, int c){
  if(d<0) return;
  if(color[v][d] != 0) return;
  color[v][d] = c;
  idx[v][d] = id;
  rep(i,G[v].size()){
    dfs(G[v][i], d-1, id, c);
  }
}


struct ST {
  int v, d, c;
};

int main(){
  cin >> N >> M;
  rep(i,M){
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  cin >> Q;
  vector<ST> v;
  rep(i,Q){
    ST st;
    cin >> st.v >> st.d >> st.c;
    v.push_back(st);
  }
  reverse(ALLOF(v));
  rep(i,v.size()){
    dfs(v[i].v, v[i].d, i+1, v[i].c);
  }

  rep(i,N){
    int id = 10000000;
    int c = 0;
    rep(j,11){
      if(idx[i+1][j] != 0 && idx[i+1][j] < id){
        c = color[i+1][j];
        id = idx[i+1][j];
      }
    }
    cout << c << endl;
  }
  
  return 0;
}


Measured memory_bytes: 16624
import java.util.*;

class Main {

    static void solve (int[] a, int[] b) {
        
        int hit = 0;
        int blow = 0;

        for (int i = 0; i < 4; i++) {
            if (a[i] == b[i]) {
                hit += 1;
            } else {
                for (int j = 0; j < 4; j++) {
                    if ( a[i] == b[j] ) blow += 1;
                }
            }
        }

        System.out.printf("%d %d\n", hit, blow);
    }

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        while (sc.hasNext()) {
            
            int [] a = new int [4];
            int [] b = new int [4];

            for (int i = 0; i < 4; i++) {
                a[i] = sc.nextInt();
            }
            for (int i = 0; i < 4; i++) {
                b[i] = sc.nextInt();
            }

            solve(a, b);

        }

    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
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=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  double L;
  cin>>L;
  cout<<fixed<<setprecision(10)<<L*L*L/27<<endl;
  return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read() {
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
	while(ch<='9'&&ch>='0')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return f?x:-x;
}
ll ans1, ans2, a[N];
int main(int argc, char const *argv[]) {
	int n = read();
	for (int i = 1; i <= n; i++)
		a[i] = read();
	for (ll i = 1, sum = 0; i <= n; i++) {
		sum += a[i];
		if (i & 1) {
			if (sum >= 0)
				ans1 += sum + 1, sum = -1;
		} else {
			if (sum <= 0)
				ans1 += - sum + 1, sum = 1;
		}
	}
	for (ll i = 1, sum = 0; i <= n; i++) {
		sum += a[i];
		if (~i & 1) {
			if (sum >= 0)
				ans2 += sum + 1, sum = -1;
		} else {
			if (sum <= 0)
				ans2 += - sum + 1, sum = 1;
		}
	}
	printf("%lld\n", min(ans1, ans2));
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,a,b,ans,MIN=1e9;
  cin >> n >> a >> b;
  a*=1000;b*=1000;
  long long h[n];
  for(int i=0;i<n;i++){
    cin >> h[i];
    h[i]*=6;
    long long tmp=a-h[i];
    if(abs(b-MIN)>abs(b-tmp)){
      ans=i+1;
      MIN=tmp;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  ll x;
  cin >> x;
  vector<ll> v;
  rep(i, 1001){
    v.push_back((ll)i*i*i*i*i);
  }
  rep(i, 1001){
    rep(j, 1001){
      ll add1 = v.at(i) + v.at(j), add2 = v.at(i) - v.at(j);
      if(add1 == x){
        cout << i << " " << -j << endl;
        return 0;
      }else if(add2 == x){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

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

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

signed main() {
  ll N;
  cin >> N;
  cout << (N)*(N-1)/2 << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

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

	FastScanner sc;
	
	void run() {
		sc = new FastScanner();
		String s = sc.next();
		String ans = "";
		for (int i = 0; i < s.length(); i++) {
			if (!"".equals(ans) && s.charAt(i) == 'B') {
				ans = ans.substring(0, ans.length()-1);
			}
			else if(s.charAt(i) != 'B'){
				ans = ans + s.charAt(i);
			}
		}
		
		System.out.println(ans);
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

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

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

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

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

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 8020
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e10;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    vl t(110, 0), s(110, 0);
    FOR(i,1, N+1){
        cin >> t[i]; t[i] *= 2;
        s[i+1] = s[i] + t[i];
    }
    vl v(110, 0);
    FOR(i,1, N+1){
        cin >> v[i];
        v[i] *= 2;
    }
    
    vl p(40100, 0);
    FOR(i, 0, s[N+1] + 1){
        FOR(j, 1, N+2){
            if(i <= s[j]){
                p[i] = v[j-1]; break;
            }
        }
        FOR(j, 1, N+2){
            ll dst = abs(s[j] - i);
            p[i] = min(p[i], dst + min(v[j-1],v[j]));
        }
    }
    
    ll ans = 0;
    REP(i, s[N+1]+1){
        ans += p[i];
    }
    double ansd = (double)0.25 * ans;
    cout << fixed << std::setprecision(20) << ansd << endl;
    return 0;
}


Measured memory_bytes: 512
<?php
	fscanf(STDIN, "%d", $money);
	fscanf(STDIN, "%d", $cake_price);
	fscanf(STDIN, "%d", $donut_price);
	$money = $money - $cake_price;
	while($money >= $donut_price){
		$money = $money - $donut_price;
		if($money < $donut_price){ break; }
	}

	echo $money;
?>

Measured memory_bytes: 4604
//\\//\\ * * * //\\// ||
#include <bits/stdc++.h> 

#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

const int N = (int) 2e5 + 10;

int a[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int x = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    x ^= a[i];
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << (x ^ a[i]);
  }
  cout << '\n';
  return 0;
}


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

signed main(){
	int n,A,B;
	cin>>n>>A>>B;
	int sum=0;
	while(n--){
		int a,b;
		cin>>a>>b;
		if(a>=A&&b>=B)sum++;
	}
	cout<<sum<<endl;
}

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

int main()
{
  int n, tmp; cin >> n;
  for (int i=1; i < n+1; i++) {
    if(i % 3 == 0 ||  check_three(i)) {
      cout << " " << i;
    }
    // } else {
    //   tmp = i;
    //   while (tmp > 9) {
    //     tmp /= 10;
    //     if (tmp % 10 == 3) {
    //       cout << " " << i;
    //     }
    //   }
    // }
  }
  cout << endl;
  return 0;
}

bool check_three(int n) {
  while (n > 0) {
    if(n % 10 == 3) return true;
    n /= 10;
  }
  return false;
}


Measured memory_bytes: 3116
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#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
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 200002;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()
const ll md = (ll)998244353;
 
inline ll add(ll a, ll b) {
  a += b;
  if (a >= md) a -= md;
  return a;
}
 
inline ll sub(ll a, ll b) {
  a -= b;
  if (a < 0) a += md;
  return a;
}
 
inline ll mul(ll a, ll b) {
  return (ll) ((long long)((a%md) * (b%md)) % md);
}
 
inline ll power(ll a, long long b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
 
inline ll inv(ll a) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
int dp[3001][3001];
int c,d;
int solve(int a,int b){
    if(a == c || b == d){
        return mul(power(a,d-b),power(b,c-a));
    }
    if(dp[a][b]!=-1){
        return dp[a][b];
    }
    int &res = dp[a][b];
    res = sub(add(mul(b,solve(a+1,b)),mul(a,solve(a,b+1))),mul(mul(a,b),solve(a+1,b+1)));
    return res;
}
int32_t main()
{ 
  IOS

  int a,b;
  cin>>a>>b>>c>>d;
  memset(dp,-1,sizeof(dp));
  cout<<solve(a,b)<<endl;
  
  
  
}

Measured memory_bytes: 74260
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

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

int MOD = 1000000007;


int main(){
    std::ios_base::sync_with_stdio(false);

    int a,b,c; cin >> a >> b >> c;

    cout << a*b/2 << endl;


    return 0;
}


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

int main() {
  
  int N;
  cin >> N;
  
  int max =0;
  int min =0;
  
  bool initialize = false;
  
  for(int i =0; i < N ; i++){
    int num;
    cin >> num;
    
    if(!initialize){
      max = num;
      min = num;
    }else if(max < num){
     max = num; 
    }else if(min > num){
     min = num; 
    }
    
    initialize = true;
  }
  
  cout << max - min << endl;

    
 
}


           

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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint fact(int n){
	static vector<mint> memo{1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		for(;k<=n;k++) memo[k]=memo[k-1]*k;
	}
	return memo[n];
}

mint fact_inverse(int n){
	static vector<mint> memo{1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		memo[n]=inverse(fact(n));
		for(int i=n;i>k;i--) memo[i-1]=memo[i]*i;
	}
	return memo[n];
}

mint choose(int n,int k,int type=0){
	if(k<0 || n<k) return 0;
	if(type==0){
		return fact(n)*fact_inverse(k)*fact_inverse(n-k);
	}
	else{
		if(k>n-k) k=n-k;
		mint res=fact_inverse(k);
		rep(i,k) res*=n-i;
		return res;
	}
}

int main(){
	int h,w,a,b; scanf("%d%d%d%d",&h,&w,&a,&b);

	if(a==h-1){
		printf("%d\n",choose(a+(w-b-1),a).to_int());
		return 0;
	}

	mint ans=0;
	rep(x,b) ans+=choose((h-a-2)+x,x)*choose(a+(w-b-1),a);
	rep(y,h-a-1) ans+=choose((b-1)+y,y)*choose((h-y-1)+(w-b-1),h-y-1);
	printf("%d\n",ans.to_int());

	return 0;
}


Measured memory_bytes: 2040
#include<stdio.h>

int main(void){
    int n,m,i,k,c=0,sum=0;
    int v[200];
    (void)scanf("%d %d",&n,&m);
    for(i=1;i<=n;i++){
        (void)scanf("%d",&k);
        v[i]=k;
        sum+=k;
    }

    for(i=1;i<=n;i++){
        if(4*v[i]*m>=sum)c++;
    }

    if(c>=m){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
import sys
read=sys.stdin.readline

N=read()
A=list(map(int,read().split()))

Max=max(A)+1
Min=min(A)

ans=float('inf')

for i in range(Min,Max):
    buf=0
    for a in A:
        buf+=(i-a)**2
    if ans>buf:
        ans=buf

print(ans)


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

using namespace std;

int t; string num;
int ans;
bool rej;
vector<int> avec;

void solve(int idx, int sum, vector<int> vec)
{
  if(idx == num.size()){
    if(ans < sum && sum <= t) ans = sum, avec = vec, rej = false;
    else if(ans == sum) rej = true;
    return;
  }
  for(int i = 1; i <= num.size() - idx; i++){
    vector<int> tmp = vec;
    tmp.push_back(stoi(num.substr(idx, i)));
    solve(idx + i, sum + stoi(num.substr(idx, i)), tmp);
  }
  return;
}

int main()
{
  while(cin >> t >> num, t || num != "0"){
    ans = -1;
    rej = false;
    vector<int> vec;
    solve(0, 0, vec);
    if(rej) cout << "rejected" << endl;
    else if(ans < 0) cout << "error" << endl;
    else{
      cout << ans;
      for(int i = 0; i < avec.size(); i++) cout << " " << avec[i];
      cout << endl;
    }
  }
  return 0;
}

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

using namespace std;

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

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {
    string s;
    int n;
    cin >> n >> s;
    int x = 0;
    int max = 0;
    REP(i, n) {
        if(s[i] == 'I') x++;
        else x--;
        if(max < x) max = x;
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

from math import sqrt

def divisor_enumeration(n):
    div = []
    for i in range(1, int(sqrt(n))+1):
        if n % i == 0:
            if n // i != i:
                div.append((i, n // i))
            else:
                div.append((i, i))
        
    return div


def main():
    N = int(readline())

    d = divisor_enumeration(N)
    
    ans = 10**15
    for x, y in d:
        ans = min(ans, x + y - 2)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3464
N, A, B, C = map(int, input().split())
ls = [int(input()) for i in range(N)]


def select(next_idx, a=0, b=0, c=0, point=0):
  if next_idx == N:
    if a and b and c:
      tmp = abs(A - a) + abs(B - b) + abs(C - c)
      yield abs(A - a) + abs(B - b) + abs(C - c) + point - 30
  else:
    length = ls[next_idx]
    flag = length > 10
    next_idx += 1

    yield from select(next_idx, a=a, b=b, c=c, point=point)
    point += 10
    if a == 0 or flag: 
      yield from select(next_idx, a=a + length, b=b, c=c, point=point)
    if b == 0 or flag: 
      yield from select(next_idx, a=a, b=b + length, c=c, point=point)
    if c == 0 or flag: 
      yield from select(next_idx, a=a, b=b, c=c + length, point=point)



print(min(select(0)))


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

int main()
{
    int n;
    cin >> n;
    int b[200005]{0};
    for(int i = 0; i < n - 1; i++){
        int a;
        cin >> a;
        b[a - 1]++;
    }
    for(int i = 0; i < n; i++) cout << b[i] << endl;
}


Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
#define dlwlrma ios::sync_with_stdio(0); cin.tie(0);
int n;
int main(){
    dlwlrma
    cin >> n;
    vector<int>a(n),b(n);
    for(int &next : a)
        cin >> next;
    for(int &next : b)
        cin >> next;
    reverse(b.begin(),b.end());
    vector<int>same,dif;
    int h;
    for(int i = 0; i < n; i++){
        if(a[i]==b[i])
            h=a[i];
    }
    for(int i = 0; i < n; i++){
        if(a[i]==b[i])
            same.push_back(i);
        if(a[i]!=h&&b[i]!=h)
            dif.push_back(i);
    }
    if(same.size()>dif.size()){
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    for(int i = 0; i < same.size(); i++)
        swap(b[same[i]],b[dif[i]]);
    for(int i = 0; i < n; i++)
        cout << b[i] << " ";
}

Measured memory_bytes: 6164
#include <iostream>

int main(int argc, char const *argv[])
{
    int W, H, x, y, r;

    std::cin >> W >> H >> x >> y >> r;

    if (   x-r >= 0 && x+r <= W
        && y-r >= 0 && y+r <= H)
    {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3092
answers = Array.new
dp = Array.new( 4 ){ Array.new( 4000 + 1 )}
0.upto( 3 ){ |i|
	0.upto( 4000 ){ |j|
		dp[ i ][ j ] = 0
	}
}
0.upto( 1000 ){ |j| 
	dp[ 0 ][ j ] = 1 
}

1.upto( 3 ){ |level|
	0.upto( 4000 ){ |i|
		0.upto( 1000 ){ |k|
			if i - k  >= 0
				dp[level][i] += dp[level-1][i-k] 
			end
		}
	}
}

while s = $stdin.gets
	answers << dp[ 3 ][ s.chomp.to_i]
end
answers.each{ |a|
	puts a
}


Measured memory_bytes: 6224
from heapq import heapify, heappop, heappush

x, y, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)
PQ = P[:x] + Q[:y]
heapify(PQ)

for r in R:
  pq = heappop(PQ)
  if pq < r:
    heappush(PQ, r)
  else:
    heappush(PQ, pq)
ans = sum(PQ)
print(ans)

Measured memory_bytes: 23456
//Code by Mukul Totla
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
void sublime(){ 
    #ifndef ONLINE_JUDGE 
    freopen ("input.txt", "r", stdin);
    freopen ("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
      }
  
int main()
{   
   sublime();
  
  int x;
  cin>>x;
  if(x==0)
    cout<<1;
  else
    cout<<0;
  return 0;
}

Measured memory_bytes: 3648