akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  if(n < 1000) cout << "ABC" << endl;
  else cout << "ABD" << endl;
  return 0;
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = min(n * a, b);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h> 
using namespace std; 
typedef long long ll;
int a[100005],b[100005];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=n/2,j=i+1,k=1;k<=m;k++,i--,j++){
		if(n%2==0&&(j-i==n/2||j-i==n/2+1))j++;
		cout<<i<<' '<<j<<endl;
		a[k]=i,b[k]=j;
	}
	/*for(int i=1;i<=n;i++){
		cout<<endl;
		for(int j=1;j<=m;j++)cout<<a[j]<<' '<<b[j]<<endl;
		for(int j=1;j<=m;j++)a[j]--,(a[j]==0?a[j]=n:0);
		for(int j=1;j<=m;j++)b[j]--,(b[j]==0?b[j]=n:0);
	}*/
	return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

using namespace std;

void inputData(vector<string>& data_set) {
	string buffer;
	while(getline(std::cin,buffer))
		data_set.push_back(buffer);
}

vector<string> splitString(const string& str, const string& separator = " ") {
	vector<string> ret;

	std::size_t bp, ep;
	bp = ep = 0;
	while((ep = str.find_first_of(separator, bp)) != string::npos){
		if(bp != ep){
			ret.push_back(string(str.begin() + bp, str.begin() + ep));
		}
		bp = ep + 1;
	}

	if(bp <= str.size() - 1){
		ret.push_back(string(str.begin() + bp, str.end()));
	}

	return ret;
}

template <class T>
T convertStringToNumber(const string& str) {
	stringstream ss;
	T ret;

	ss << str;
	ss >> ret;

	return ret;
}



vector<int> parseStringData(const string& data_str) {
	auto buff = splitString(data_str);

	vector<int> ret(buff.size());
	for(int i = 0; i < buff.size(); ++i){
		auto temp = convertStringToNumber<int>(buff[i]);
		ret[i] = temp;
	}

	return ret;
}


int calcGCD(int a, int b) {
	return (a % b == 0) ? b : calcGCD(b, a%b);
}


void displayAnswer(int a, int b) {
	int gcd = calcGCD(a, b);
	int lcm = gcd * (a/gcd) * (b/gcd);
	std::cout << gcd << " " << lcm << std::endl;
}


void doAllProcess() {
	vector<string> buffer;
	inputData(buffer);

	for(int i = 0; i < buffer.size(); ++i){
		auto data_set = parseStringData(buffer[i]);

		int a, b;
		if(data_set[0] > data_set[1]) {
			a = data_set[0];
			b = data_set[1];
		}
		else {
			a = data_set[1];
			b = data_set[0];
		}

		displayAnswer(a, b);
	}
}


int main() {
	doAllProcess();

	return 0;
}


Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int main() {
	int a, b;
	char op;
	cin >> a >> op >> b;
	while (op != '?') {
		if (op == '+')
			cout << a + b << endl;
		else if (op == '-')
			cout << a - b << endl;
		else if (op == '*')
			cout << a * b << endl;
		else if (op == '/')	
			cout << a / b << endl;
		cin >> a >> op >> b;	
	}
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(void){
    int n, k, ans = 0, us = 0;
    vector<int> p;
    set<int> s;
    vector<bool> u;
    cin >> n >> k;
    p.assign(n, 0);
    u.assign(n, false);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }

    int v = 0;
    for(int i=1;i<n;i++){
        if(p[i] < p[i-1]){
            v = i;
        }
        if(i-v+1 >= k){
            u[i-k+1] = true;
            us++;
        }
    }

    for(int i=0;i<k;i++){
        s.insert(p[i]);
    }
    ans = n-k+1;
    for(int i=0;i<n-k;i++){
        s.erase(p[i]);
        auto mn = s.begin();
        auto mx = s.end(); mx--;

        if(p[i] < (*mn) && (*mx) < p[i+k]){
            if(!u[i] || !u[i+1])ans--;
        }

        s.insert(p[i+k]);

    }

    if(us > 1) ans -= us-1;


    cout << ans << endl;

}


Measured memory_bytes: 10368
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  int n,a,b;
  int x=0;
  cin>>n>>a>>b;
  while(1){
    if(x%2==0){
      if(a==1&&b==2){
	cout<<"Borys"<<endl;
	return 0;
      }
      if(a+1!=b)a++;
      else a--;
    }else{
      if(a==n-1&&b==n){
	cout<<"Alice"<<endl;
	return 0;
      }
      if(b-1!=a)b--;
      else b++;
    }
    x++;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int ans=0;
    if(n>=2)
    {
        ans+=(n*(n-1))/2;
    }
    if(m>=2)
    {
        ans+=(m*(m-1))/2;
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import collections
from sys import stdin
N = int(stdin.readline().rstrip())
data = []
for i in range(N):
    s = (stdin.readline().rstrip())
    data.append(s)
c = collections.Counter(data)
maxc = max(c.values())
for j in sorted(c.keys()):
    if c[j] == maxc:
        print(j)

Measured memory_bytes: 35564
parseint(x) = parse(Int, x)
readint() = readline() |> parseint
readints() = map(parseint, readline() |> split)

function binarysearch(s)
    l = 0
    r = 500
    while r - l > 1
        m = l + div(r - l, 2)
        if m*m <= s
            l = m
        else
            r = m
        end
    end
    l
end

function dist2(u, v)
    s = 0
    for i = 1:length(u)
        s += (u[i] - v[i])^2
    end
    s
end

function main()
    n, d = readints()
    x = [readints() for _ = 1:n]
    cnt = 0
    for i = 1:n-1, j = i+1:n
        s = dist2(x[i], x[j])
        v = binarysearch(s)
        if v*v == s
            cnt += 1
        end
    end
    println(cnt)
end

main()


Measured memory_bytes: 170624
n, k = map(int, input().split())
dic = {}
for i in range(n):
  a, b = map(int, input().split())
  dic.setdefault(a, 0)
  dic[a] += b
lst = sorted(list(dic.items()))
for tpl in lst:
  if k > tpl[1]:
    k -= tpl[1]
  else:
    print(tpl[0])
    exit()

Measured memory_bytes: 20772
#include <stdio.h>
int main(void) {
    int a, b, c, d;
    scanf("%d%d",&a,&b);
    
    c=1;
    d=0;
    while(c<b){
        c+=a-1;
        d++;
    }
    printf("%d\n",d);
    return 0;
}

Measured memory_bytes: 1708
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for _ in range(n):
    a = list(map(int, input().split()))
    tmp = 0
    for i, t in enumerate(a):
        tmp += t*b[i]
    tmp += c
    if tmp > 0:
        ans += 1

print(ans)




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

int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << 1 << endl;
    cout << 0 << endl;
  } else if (n == 2) {
    cout << 2 << endl;
    cout << 0 << endl;
    cout << 11 << endl;
  } else {
    cout << n - 1 << endl;
    for (int i = 0; i < n - 1; i++) {
      cout << 1;
      for (int j = 0; j < i; j++) cout << 0;
      cout << 1 << endl;
    }
  }
}



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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
    ll n, m, k;
    cin >> n >> m >> k;

    vll a_ruiseki(n + 1, 0), b_ruiseki(m + 1, 0);

    FOR(i, 1, n) {
      ll a_in;
      cin >> a_in;
      a_ruiseki[i] = a_ruiseki[i - 1] + a_in;
    }
    FOR(i, 1, m) {
      ll b_in;
      cin >> b_in;
      b_ruiseki[i] = b_ruiseki[i - 1] + b_in;
    }

    ll book_num = 0;
    ll index = m;
    ll next_index = m;
    REP(i, n + 1) {
      index = next_index;
      REPD(j, index + 1) {
        if (a_ruiseki[i] + b_ruiseki[j] <= k) {
          book_num = max(book_num, i + j);
          next_index = j;
          break;
        }
      }
    }
    COUT(book_num);
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

3 2
*/


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

#define ll long long
#define pi 2*acos(0.0)

ll cnt[30];

ll MOD = 1e9+7;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;

    for(int i = 0; i < n; i++)
    {
        cnt[s[i]-'a']++;
    }

    ll ans = 1;

    for(int i = 0; i < 26; i++)
    {
        ans = (ans%MOD*(cnt[i]+1)%MOD)%MOD;
    }

    ans -= 1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
import sys
import collections
import itertools

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	al = collections.defaultdict(lambda :0)
	for _ in range(n):
		s=input()
		al[s[0]] += 1
	ret = 0
	for cl in itertools.combinations('MARCH', 3):
		r=1
		for c in cl:
			#pa(c)
			r *= al[c]
		ret += r
	print(ret)
	
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

using namespace std;

int main()
{
int K,X;
cin>>K>>X;
if(K!=0&&X!=0&&K<=100&&X<=100000){
if((K*500)>=X){
    cout<<"Yes";
}
else{
    cout<<"No";
}
}
return 0;
}

Measured memory_bytes: 3628
# coding: utf-8
# クイックソート
import copy


def partition(A, p, r):
    x = int(A[r].split()[1])

    i = p - 1
    tmp = 0

    for j in range(p, r):
        if int(A[j].split()[1]) <= x:
            i = i + 1
            tmp = A[i]
            A[i] = A[j]
            A[j] = tmp

    tmp = A[i + 1]
    A[i + 1] = A[r]
    A[r] = tmp
    return i + 1


def quickSort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q - 1)
        quickSort(A, q + 1, r)
    return (A)


def checkStable(before_list, sorted_list):

    for val in sorted_list:
        same_list = [
            i for i in sorted_list
            if (int(val.split()[1]) == int(i.split()[1])) and val != i
        ]
        if len(same_list) == 0:
            continue

        for data in same_list:
            bef = before_list.index(val) - before_list.index(data)
            aft = sorted_list.index(val) - sorted_list.index(data)

            if (bef > 0 and aft < 0) or (bef < 0 and aft > 0):
                return 'Not stable'

    return 'Stable'


if __name__ == "__main__":
    n = int(input())

    A = []
    for _ in range(n):
        A.append(input())

    bef_A = copy.deepcopy(A)

    aft_A = quickSort(A, 0, n - 1)

    print(checkStable(bef_A, aft_A))

    for data in aft_A:
        print(data)



Measured memory_bytes: 13564
import java.util.*;

class Main{

    Main(){
        Scanner SC = new Scanner(System.in);
        int N = Integer.parseInt(SC.next());
        int M = Integer.parseInt(SC.next());

        int[] R = new int[N];

        for(int i=0;i<N;i++){
            R[i] = -1;
        }

        for(int i=0;i<M;i++){
            int S = Integer.parseInt(SC.next());
            int C = Integer.parseInt(SC.next());

            if(R[S-1] == -1){
                R[S-1] = C;
            } else {
                if(R[S-1] != C){
                    System.out.println(-1);
                    return;
                }
            }
        }

        if(N == 1){
            if(R[0] == -1){
                R[0] = 0;
            }
        } else {
            if(R[0] == 0){
                System.out.println(-1);
                return;
            } else if(R[0] == -1){
                R[0] = 1;
            }

            for(int i=1;i<N;i++){
                if(R[i] == -1){
                    R[i] = 0;
                }
            }
        }

        for(int i=0;i<N;i++){
            System.out.print(R[i]);
        }
        System.out.println("");
    }

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


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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; }
// int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll dp[100100][3];
char output[100100];

int main() {
  ll n,k,r,s,p; cin >> n >> k >> r >> s >> p;
  string t; cin >> t;
  ll ans = 0;

  FOR(i,0,k-1){
    if(t[i]=='r') ans += p, output[i] = 'p';
    if(t[i]=='s') ans += r, output[i] = 'r';
    if(t[i]=='p') ans += s, output[i] = 's';
  }

  FOR(i,k,n-1){
    if(t[i]=='r') {
      if(output[i-k]=='p') continue;
      else ans += p, output[i] = 'p';
    }
    if(t[i]=='s') {
      if(output[i-k]=='r') continue;
      else ans += r, output[i] = 'r';
    }
    if(t[i]=='p') {
      if(output[i-k]=='s') continue;
      else ans += s, output[i] = 's';
    }
  }

  cout << ans << endl;


}



Measured memory_bytes: 512
import math

N = int(input())
x = [0]*N
y = [0]*N
for i in range(N):
    x[i],y[i]=map(int,input().split())
    
ans=0
for i in range(N):
    for j in range(i):
        ans+=math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
print(ans*2/N)

Measured memory_bytes: 38384
import scala.io.StdIn._

object Helpers {
  def readIntLine = readLine.split(" ").map(_.toInt)
  def readInts(n: Int) = Array.fill(n)(readInt)

  def splitDigits(i: Int): Seq[Int] = i.toString.map(_.asDigit)

  def log[A](x: A): A = {println(x); x}

  implicit class IntImplicits(val i: Int) {
    def isEven = i % 2 == 0
    def isOdd = !isEven

    def ** (exp: Int): Int = scala.math.pow(i, exp).intValue
  }

  implicit class LongImplicits(val i: Long) {
    def isEven = i % 2 == 0
    def isOdd = !isEven

    def ** (exp: Long): Long = scala.math.pow(i, exp).longValue
  }

  def mycomb[T](n: Int, l: List[T]): List[List[T]] =
    n match {
      case 0 => List(List())
      case _ => for(el <- l;
                sl <- mycomb(n-1, l dropWhile { _ != el } ))
                yield el :: sl
  }
  
  def comb[T](n: Int, l: List[T]): List[List[T]] = mycomb(n, l.distinct)
}

object Main extends App {
  import Helpers._

  val xs = readLine

  println(if (xs.count(_ == '5') == 2 && xs.count(_ == '7') == 1) "YES" else "NO")
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll A, P;
    cin >> A >> P;
    cout << (3*A+P)/2 << endl;
    return 0;
}

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

using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int t = (n + 999) / 1000;
  int ans = 1000 * t - n;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3648
N = int(input())
A = [int(n) for n in input().split()]
Q = int(input())

D = dict()
for a in A:
    if a not in D.keys():
        D[a] = 0
    D[a] += 1

ans = 0
for k, v in D.items():
    ans += k * v
    
for _ in range(Q):
    B, C = [int(n) for n in input().split()]
    
    if B in D.keys():
        count = D[B]
        
        if C not in D.keys():
            D[C] = 0
        D[C] += count
        del D[B]
        
        ans += (C - B) * count

    print(ans)




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

using namespace std;

int main() {
    long double a, b, h, m;

    long double kakudo;

    long double result;

    cin >> a >> b >> h >> m;

    m /= (long double)5;
    h += m / (long double)12;
    long double wariai = (h - m);

    kakudo = (long double)3.141592653589793238462643 * abs(wariai) / 6;
    //cout<<cos(kakudo)<<endl;

    result = sqrtl(a * a + b * b - (2 * a * b * cosl(kakudo)));

    cout << fixed << setprecision(20) << result << endl;

    return 0;
}


Measured memory_bytes: 4164
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            long N = in.nextLong();
            long[] n = new long[5];
            for (int i = 0; i < n.length; i++) {
                n[i] = in.nextLong();
            }

            long min = (long) 1e18;
            for (int i = 0; i < n.length; i++) {
                min = Math.min(min, n[i]);
            }

            long res = 4 + N / min + (N % min == 0 ? 0 : 1);

            System.out.println(res);
        }
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	string S;
	cin >> S;
	if(S.length()%2 != 0) {
		cout << "No\n";
		return 0;
	}
	for(int i = 0; i < S.length(); i += 2) if(S[i] != 'h' || S[i+1] != 'i') {
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long
int ans1, ans2;
double dl = 0;
signed main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	ans1 = a * 100;
	for (int i = 0; i <= f; i += a * 100) {
		for (int j = 0; i + j <= f; j += b * 100) {
			int g = (i + j) / 100 * e;
			for (int k = 0; k <= g && i + j + k <= f; k += c) {
				for (int l = 0; k + l <= g && i + j + k + l <= f; l += d) {
					if (dl < (double)(k + l) / (i + j + k + l)) {
						dl = (double)(k + l) / (i + j + k + l);
						ans1 = i + j + k + l;
						ans2 = k + l;
					}
				}
			}
		}
	}
	cout << ans1 << ' ' << ans2 << endl;
}

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

int main()
{
    int A, B, max = 0;
    cin >> A >> B;
    max = A + B;
    if (A - B > max)
        max = A - B;
    if (A * B > max)
        max = A * B;
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {

    long a = 0;
    long b = 0;
    long x = 0;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      String[] tmp = br.readLine().split("\\s");
      a = Long.parseLong(tmp[0]);
      b = Long.parseLong(tmp[1]);
      x = Long.parseLong(tmp[2]);
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }


    long sum = (b / x) + 1;
    long diff = (a / x) + 1;
    if (a % x == 0) {
      diff--;
    }
    System.out.print(sum - diff);
  }
}


Measured memory_bytes: 24532
#include <cstdio>
const int MAXN = 110;

using namespace std;

int selectionSort(int A[], int N);

int main()
{
	int n;
	scanf("%d", &n);

	int nums[MAXN];
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &nums[i]);
	}

	int sw = selectionSort(nums, n);

	for (int i = 0; i < n; i++)
	{
		if (i != n - 1)
		{
			printf("%d ", nums[i]);
		}
		else
		{
			printf("%d", nums[i]);
		}
	}
	printf("\n%d\n", sw);

	return 0;
}

int selectionSort(int A[], int N)
{
	int temp;
	int sw = 0;

	for (int i = 0; i < N; i++)
	{
		int minj = i;
		for (int j = i; j < N; j++)
		{
			if (A[j] < A[minj])
			{
				minj = j;
			}
		}
		temp = A[i];
		A[i] = A[minj];
		A[minj] = temp;
		if (minj != i)
		{
			sw++;
		}
	}

	return sw;
}


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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 998244353;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;

ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}

//__builtin_popcount ();
set<int> s[26];
int main(){
    FAST
int n;
    cin>>n;
    string h;
    cin>>h;
    for(int i=0;i<h.size();i++)
    {
        s[h[i]-'a'].insert(i);
    }
    int q;
    cin>>q;
    int t;
    while(q--)
    {
        cin>>t;
        if(t==1)
        {
            int ind;
            char reb;
            cin>>ind>>reb;
            s[h[ind-1]-'a'].erase(s[h[ind-1]-'a'].find(ind-1));
            h[ind-1]=reb;
            s[reb-'a'].insert(ind-1);
        }
        else
        {
            int l,r;
            cin>>l>>r;
            l--,r--;
            int ans=0;
            for(int i=0;i<26;i++)
            {
                auto it=s[i].lower_bound(l);
                if(it!=s[i].end() && *it<=r)
                {
                    ans++;
                }
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 24220
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

ll n, m;
ll k;
ll a[200009], b[200009];

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

    cin >> n >> m >> k;

    rep(i, n) cin >> a[i + 1], a[i + 1] += a[i];
    rep(j, m) cin >> b[j + 1], b[j + 1] += b[j];

    int ans = -1;

    rep(i, n + 1) if(a[i] <= k) {
        chmax(ans, i + upper_bound(b, b + m + 1, k - a[i]) - b - 1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6804
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> cnt;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ++cnt[a[i]];
  }
  if (cnt[0] == n) {
    cout << "Yes" << '\n';
    return 0;
  }
  if (n % 3 != 0) {
    cout << "No" << '\n';
    return 0;
  }
  vector<int> all;
  for (auto& p : cnt) {
    for (int i = 0; i < p.second / (n / 3); i++) {
      all.push_back(p.first);
    }
  }
  if (all.size() == 3 && (all[0] ^ all[1] ^ all[2]) == 0) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

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

    int ans = 0;
    rep(i, N) {
        int height;
        cin >> height;
        if (height >= K) {
            ans++;
        }
    }

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


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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

deque < char > a , b ;

int main() {

    string s1 , s2 ;
    cin >> s1 >> s2 ;

    fore( i , s1 ) a.pb( i ) ;
    fore( i , s2 ) b.pb( i ) ;

    int cnt = 0 ;

    while( a != b ){
      char x = a.back() ;
      a.pop_back() ;
      a.push_front( x ) ;
      if( cnt >= 1e5 ) break ;
      cnt++ ;
    }

    if( a == b ){
        cout << "Yes\n" ;
    } else cout << "No\n" ;

    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

void dfs(vector<vector<int>> &tree, vector<bool> &seen, int k, vector<int> &ans, vector<int> &point){
    seen[k]=true;
    for(int i: tree[k]){
        if(seen[i]) continue;
        else{
            ans[i]=ans[k]+point[i];
            dfs(tree,seen,i,ans,point);
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q; cin>>n>>q;
    vector <vector<int>> tree(n);
    vector<int> point(n,0);
    vector<bool> seen(n,false);
    for(int i=0; i<n-1; i++){
        int a,b; cin>>a>>b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    
    rep(i,q){
        int p,x;
        cin>>p>>x;
        p--;
        point[p]+=x;
    }
    vector<int> ans(n,0);
    ans[0]=point[0];
    dfs(tree,seen,0,ans,point);
    rep(i,n) cout<<ans[i]<<" ";
    return 0;
}

Measured memory_bytes: 31436
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


ll cost[305][305];

void warshall_floyd(ll n){
    rep(k, n){
        rep(i, n){
            rep(j, n) cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
        }
    }
}

int main(){
    ll n, m, r;
    cin >> n >> m >> r;
    vector<ll> route;
    rep(i, r) {
        ll p;
        cin >> p;
        p--;
        route.push_back(p);
    }
    sort(route.begin(), route.end());

    rep(i, 305) rep(j, 305) cost[i][j] = LINF;
    // rep(i, 305) cost[i][i] = 0;

    rep(i, m){
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        cost[a][b] = c;
        cost[b][a] = c;
    }

    warshall_floyd(n);

    ll ans = LINF;
    
    do {
        // rep(j, r) cout << route[j] << " ";
        // cout << endl;
        ll tmp = 0;
        rep(j, r - 1){
            tmp += cost[route[j]][route[j+1]];
        }
        ans = min(ans, tmp);
    } while(next_permutation(route.begin(), route.end()));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4324
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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 (b<a) { a=b; return 1; } return 0; }

int a,b;
char op;

int main(){
    cin>>a>>op>>b;
    if(op=='+')out(a+b);
    else out(a-b);
}


Measured memory_bytes: 256
#[allow(dead_code)]
fn main() {
    let mut bb = i::str();
    let mut xx1=0;
    let mut xx2=0;
    let mut yy1 = 0;
    let mut yy2 = 0;
    let vecs:Vec<char> =bb.as_str().chars().collect();
    for xx in vecs {
        if (xx=='N'){
            yy1+=1
        }
        if (xx=='W'){
            xx1+=1
        }
        if (xx=='S'){
            yy2+=1
        }
        if (xx=='E'){
            xx2+=1
        }
    }
    if (((yy1>0&&yy2>0)||(yy1==0&&yy2==0))&&((xx1>0&&xx2>0)||(xx1==0&&xx2==0))){
        println!("Yes");
    }else{
        println!("No");
    }


}


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn strv(n: usize) -> Vec<String> {
        (0..n).map(|_| str()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2100
n=int(input())
list_ = [int(x) for x in input().split() if (int(x) % 2) == 0]
for f in list_:
    if (f % 3 == 0) or (f % 5 == 0):
        continue
    else:
        print("DENIED")
        break
else:
    print("APPROVED")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long dp[100000000];
long long attack(long long h,long long cnt)
{
    if(h == 1)
    {
        cnt++;
        return cnt;
    }
    else
    {
        if(h <= 100000000 && dp[h] != 0)cnt += dp[h];
        else
        {
            cnt = attack(h/2,cnt);
            cnt = attack(h/2,cnt);
            cnt++;
            if(h <= 100000000)
            return dp[h] += (cnt);
            else return cnt;
        }
    }
    return cnt;
}
int main()
{
    long long h,cnt = 0;
    cin >> h;
    cout << attack(h,cnt) << endl;
	return 0;
}


Measured memory_bytes: 18688
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define pb push_back
using ll = long long;
using namespace std;

signed main(){
  int N,M;
  cin >> N >> M;

  vector<int> Mp;
  REP(i,M+1){
    Mp.pb(0);
  }

  REP(i,N){
    int K;
    cin >> K;
    REP(j,K){
      int temp;
      cin >> temp;
      Mp[temp]++;
    }
  }

  int counter = 0;
  REP(i,M+1){
    if(Mp[i] == N){
      counter++;
    }
  }
  cout << counter << endl;
}



Measured memory_bytes: 256
#include <iostream>

int main(void)
{
	using namespace std;
	
	int H,W;
	while(1){
		cin >> H;
		cin >> W;

		if((H==0) && (W==0))	break;

		for(int hy=0; hy<H; ++hy){
			for(int wx=0; wx<W; ++wx){
				if((hy+wx)%2 == 1 )	cout << ".";
				else cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	
	}


	return 0;

}

Measured memory_bytes: 3076
n,k = map(int,input().split())
if k > (n-1)*(n-2)/2:
  print(-1)
else:
  p = (n-1)*(n-2)/2 - k
  print(n-1+int(p))
  for i in range(2,n+1):
    print(1,i)
  x = 2
  y = 3
  for _ in range(int(p)):
    print(x,y)
    y = y + 1
    if y == n + 1:
      x = x + 1
      y = x + 1

Measured memory_bytes: 42736
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    s = input()
    rs = s[::-1]

    a = [0] * len(s)

    k = -1
    for i, j in enumerate(s):
        if j == 'L':
            if k == -1:
                k = i
            if (i - k) % 2:
                a[k - 1] += 1
            else:
                a[k] += 1
        else:
            k = -1

    k = -1
    for i, j in enumerate(rs):
        if j == 'R':
            if k == -1:
                k = i
            if (i - k) % 2:
                a[len(s) - k] += 1
            else:
                a[len(s) - k - 1] += 1
        else:
            k = -1

    print(*a)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


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

const int MAXN = 1e5 + 50;
typedef pair<int, int> P;

int n;
vector<int> V[MAXN];
bool used[MAXN];

P dfs(int t){
    int cnt = 0;
    used[t] = true;
    P res;

    for(int v : V[t]){
        if(used[v]) continue;
        P d = dfs(v);
        cnt ++;
        res.first += d.first;
        res.second += d.second;
    }
    if(cnt == 0) return P(1,0);
    if(res.first == 1 && res.second == 0) return res;
    if(res.first > 0) res.first--;
    res.second += res.first;
    return P(0, res.second);
}

int main(){
    cin >> n;
    int a,b;
    for(int i = 0; i < n-1; i++){
        scanf("%d%d", &a, &b);
        V[a].push_back(b);
        V[b].push_back(a);
    }
    fill(used, used + n, false);
    for(int i = 0; i < n-1; i++){
        if(V[i].size() >= 3){
            P d = dfs(i);
            return !printf("%d", d.first + d.second);
        }
    }
    return !printf("1");

}

Measured memory_bytes: 8320
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using System.Text;

namespace abc154
{
    class Program
    {
        static void Main(string[] args)
        {
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc154B();
        }

        public static void solve_abc154B()
        {
            string str = Console.ReadLine();
            StringBuilder newStr = new StringBuilder();
            for (int i = 0; i < str.Length; i++) 
            {
                newStr.Append("x");
            }
            Console.WriteLine(newStr.ToString());
        }

        public static void solve_abc154A()
        {
            string[] color = Console.ReadLine().Split();
            int[] number = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            string rm = Console.ReadLine();

            if (rm == color[0])
            {
                number[0]--;
                Console.WriteLine("{0} {1}", number[0], number[1]);
            }
            else
            {
                number[1]--;
                Console.WriteLine("{0} {1}", number[0], number[1]);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x,y;
  while(cin >> x >> y){
    TSTART();
    int ans = 0;
    while(x <= y){
      ans++;
      x *= 2;
    }

    cout << ans << endl;
    TSTOP();
  }
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define dbl double
#define forn(i,n,k) for(int i=0;i<n;i=i+k)
#define forpn(p,n,k) for(int i=p;i<n;i+=k)
#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
using namespace std;

int main()
{   ios::sync_with_stdio(0);
    
    
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    vector<int>v(n);
    for0(i,n) cin>>v[i];
    vector<ll> dp(n);
    dp[0]=0;
    for(int i=1;i<n;i++){ dp[i]=dp[i-1]+abs(v[i-1]-v[i]);
        for(int j=2;j<=k;j++)
        {
            if(j<=i){
            
             dp[i]=min(dp[i],dp[i-j]+abs(v[i-j]-v[i]));}
            
        }
        
    }
    cout<<dp[n-1];
      
    
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#define N 100

int select(int *, int);

int main(){

  int i, n, A[N], count;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  count=select(A, n);

  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}

int select(int *A,int n){

 int i, j, minj, sub, count=0;

  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(A[j]<A[minj])
         minj=j;
    }
    sub=A[i];
    A[i]=A[minj];
    A[minj]=sub;
    if(i!=minj) count++;
  }
  return count;
}


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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  int a[3*N];
  for (int i = 0; i < 3 * N; i++) scanf("%d", a + i);

  sort(a, a + 3 * N);
  int idx = 3 * N - 2;
  ll ans = 0;
  while (N--) {
    ans += a[idx];
    idx -= 2;
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N, K, Q; cin>>N>>K>>Q; int a[100010];
    for(int i=0; i<N;i++){
      a[i] = K-Q;
    }
    for(int i=0; i<Q;i++){
      int aa; cin>>aa; a[aa-1]++;
    }

    for(int i=0; i<N;i++){
      if(a[i]>0){
        cout<<"Yes"<<endl;
      }else{
        cout<<"No"<<endl;
      }
    }
    return 0;
}


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

long long N;
vector<long long> primes{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
map<long long, long long> prime_count;

int main(){
	cin >> N;
	for(long long i = 1; i <= N; i++){
		for(auto prime : primes){
			long long num = i;
			while(num%prime == 0){
				num /= prime;
				prime_count[prime]++;
			}
		}
	}

	long long ans = 0;
	//2,4,4
	for(auto first: primes){
		for(auto second: primes){
			for(auto third: primes){
				if(first == second || second == third || first == third){
					continue;
				}
				if(prime_count[first] >= 2 && prime_count[second] >= 4 && prime_count[third] >= 4){
					ans++;
				}
			}
		}
	}
	ans/=2;
	//4,14
	for(auto first: primes){
		for(auto second: primes){
			if(first == second){
				continue;
			}
			if(prime_count[first] >= 4 && prime_count[second] >= 14){
				ans++;
			}
		}
	}
	//2,24
	for(auto first: primes){
		for(auto second: primes){
			if(first == second){
				continue;
			}
			if(prime_count[first] >= 2 && prime_count[second] >= 24){
				ans++;
			}
		}
	}
	//74
	for(auto first: primes){
		if(prime_count[first] >= 74){
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256