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

using namespace std;

constexpr int MOD = 1000000007;

using Long = long long;
template<typename T>
using V = vector<T>;
template<typename T>
using Vv = V<V<T>>;
using Vb = V<bool>;
using Vvb = V<Vb>;
using Vi = V<int>;
using Vvi = V<Vi>;
using Vl = V<Long>;
using Vvl = V<Vl>;
using Vd = V<double>;
using Vvd = V<Vd>;
using Vs = V<string>;

template <typename First, typename Second>
istream& operator>>(istream& is, pair<First, Second>& v);

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& x : v) {
        is >> x;
    }
    return is;
}

template <typename First, typename Second>
istream& operator>>(istream& is, pair<First, Second>& v) {
    is >> v.first >> v.second;
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for (const auto& x : v) {
        os << x << ' ';
    }
    return os;
}

// *** SOLUTION BEGIN ***

void solve() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if (x > y) {
        swap(x, y);
        swap(a, b);
    }
    cout << min(x * a + y * b, min(y * 2 * c, x * 2 * c + (y - x) * b));
}

// *** SOLUTION END ***

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for(int i = 0; i < H; ++i) cin >> S[i];
  vector<vector<int>> L(H,vector<int>(W,0)), R = L, U = L, D = L;
  for(int i = 0; i < H-1; ++i){
    for(int j = 0; j < W; ++j){
      if(S[i][j] == '.' and S[i+1][j] == '.')
        D[i+1][j] = D[i][j]+1;
    }
  }
  for(int i = H-1; i > 0; --i){
    for(int j = 0; j < W; ++j){
      if(S[i][j] == '.' and S[i-1][j] == '.')
        U[i-1][j] = U[i][j]+1;
    }
  }
  for(int j = 0; j < W-1; ++j){
    for(int i = 0; i < H; ++i){
      if(S[i][j] == '.' and S[i][j+1] == '.')
        R[i][j+1] = R[i][j]+1;
    }
  }
  for(int j = W-1; j > 0; --j){
    for(int i = 0; i < H; ++i){
      if(S[i][j] == '.' and S[i][j-1] == '.')
        L[i][j-1] = L[i][j]+1;
    }
  }
  int ans = 0;
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      if(S[i][j] != '.') continue;
      ans = max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]+1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 67200
import math
from functools import reduce


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def my_round(val, digit=0):
    p = 10 ** digit
    return (val * p * 2 + 1) // 2 / p


n, m = list(map(int, input().split()))
a_pr = [i // 2 for i in list(map(int, input().split()))]
lcm_ = lcm_list(a_pr)
res, div2 = 0, None
for ai in a_pr:
    cnt = 0
    while ai % 2 == 0:
        ai //= 2
        cnt += 1
    if div2 is None:
        div2 = cnt
    elif cnt != div2:
        print(0)
        exit()

print(int(my_round(m // lcm_ / 2)))


Measured memory_bytes: 20988
import Data.Functor( (<$>))
import Data.List( sort)

putList::[Int] -> IO ()
putList [] = return ()
putList (x:xs) = putStr (show x) >> __putList xs
  where
    __putList [] = return ()
    __putList (x:xs) = putStr (' ':show x) >> __putList xs

putListLn list = putList list >> putStrLn ""

main = putListLn . sort . (read <$>) . words =<< getLine



Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
	int n;
	
	scanf("%d",&n);
	
	int a;
	
	scanf("%d",&a);
	
	int need;
	
	need = n % 500;
	
	if(need > a){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	
	return 0;
	
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t k,i,ans=0;
  cin>>k;
  if(k%2==0||k%5==0) cout<<-1<<endl;
  else{
    if(k%7==0) k/=7;
    i=1;
    ans++;
    while(i<k){
      i=i*10+1;
      ans++;
    }
    while(i%k>0){
      i=10*(i%k)+1;
      ans++;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define rep(i,n) for(int i=0; i<n; i++)

int main(void) {
  int N;
  cin >> N;
  vi A(N+1), B(N);

  rep(i,N+1) {
    cin >> A[i];
  }
  rep(i,N) {
    cin >> B[i];
  }

  long count = 0;
  rep(i,N) {
    // 正面撃破
      // モンスターの方が多い場合
      if(A[i] >= B[i]) {
        count += B[i];
        A[i] -= B[i];
        B[i] = 0;
        continue;
      }
      // 勇者の方が多い場合
      else if(A[i] < B[i]) {
        count += A[i];
        B[i] -= A[i];
        A[i] = 0;
      }

    // 右隣撃破
      // モンスターの方が多い場合
      if(A[i+1] >= B[i]) {
        count += B[i];
        A[i+1] -= B[i];
        B[i] = 0;
        continue;
      }
      // 勇者の方が多い場合
      else if(A[i] < B[i]) {
        count += A[i+1];
        B[i] -= A[i+1];
        A[i+1] = 0;
      }

  }

  cout << count << endl;
  

  return 0;
}

Measured memory_bytes: 1024
package main

import (
  "fmt"
  "math"
)

func main() {
	var n int
	var a []int

	fmt.Scanf("%d", &n)
	for i:=0; i<n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		a = append(a, x)
	}

	min := math.MaxInt32
	for i:=-100; i<=100; i++ {
		sum := 0
		for _, v := range a {
			sum += (v - i)*(v - i)
		}
		if sum < min {
			min = sum
		}
	}

	fmt.Print(min)
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define ll long long int
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef pair<ll, ll> pairs;
typedef pair<ll, pairs> tpl;
vector<string> v;
ll mod = 1000000007, dp[1001][1001], n, m;
ll getAns(ll i, ll j)
{
	if (i < 0 || j < 0 || i > n - 1 || j > m - 1 || v[i][j] == '#')
		return 0;
	if (i == n - 1 && j == m - 1)
		return 1;
	if (dp[i][j] != -1)
		return dp[i][j];
	return dp[i][j] = (getAns(i + 1, j) + getAns(i, j + 1)) % mod;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> m;
	for (ll i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		v.push_back(s);
	}
	// memset(dp, -1, sizeof(dp));
	// cout << getAns(0, 0);
	for (ll i = 0; i < n; i++)
	{
		for (ll j = 0; j < m; j++)
		{
			if (v[i][j] == '#')
				dp[i][j] = 0;
			else if (i == 0 && j == 0)
				dp[i][j] = 1;
			else if (i == 0)
			{
				dp[i][j] = dp[i][j - 1];
			}
			else if (j == 0)
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		}
	}
	cout << dp[n - 1][m - 1];
}


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

#define S 101

int main(){
  int i, j, k, p, n, a[S], b[S][S], min;

  scanf("%d", &n);
  if(n<1 || n>100) exit(1);

  for(i=1; i<n+1; i++){
    scanf("%d%d", &a[i-1], &a[i]);
    if(a[i-1]<1 ||a[i-1]>100 || a[1]<1 || a[i]>100) exit(2);
  }

  for(i=0; i<101; i++) b[i][i] = 0;

  for(i=2; i<n+1; i++){
    for(j=1; j<n-i+2; j++){
      
      k = j+i-1;
      b[j][k] = 100000000;
      
      for(p=j; p<=k-1; p++){
	
	if(b[j][k] > b[j][p]+b[p+1][k]+a[j-1]*a[p]*a[k])
	  b[j][k] = b[j][p]+b[p+1][k]+a[j-1]*a[p]*a[k];
	else
	  b[j][k] = b[j][k];
	
      } 
    }
  }
  printf("%d\n", b[1][n]);

  return 0;
}




Measured memory_bytes: 2104
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long ;

int main(){
    ll a , b , c , d ; 
    cin >> a >> b >> c >> d ; 
    ll first = b/c - (a-1)/c ; 
    ll second = b/d - (a-1)/d ; 
    ll lcm = c*d / __gcd(c,d) ; 
    ll third = b / lcm - (a-1) / lcm ; 
    ll ans = (b-a+1) - (first + second - third) ; 
    cout << ans << endl;
    return 0 ; 
}




Measured memory_bytes: 256
def cmb(n, r, mod):
    numerator = 1
    # n * (n-1) * ... * (n-r+1)
    for i in range(n-r+1, n+1):
        numerator = (i * numerator) % mod
    denominator = 1
    # r * (r-1) * ... * 1
    for i in range(1, r+1):
        denominator = (i * denominator) % mod
    # y^(mod-2) % mod
    fermat = pow(denominator, mod-2, mod)
    return (numerator * fermat) % mod


n, a, b = map(int, input().split())
mod = 10 ** 9 + 7

ans = pow(2, n, mod) - 1
ans -= (cmb(n, a, mod) + cmb(n, b, mod))

print(ans % mod)



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

using namespace std;

const int MOD=1e9+7;

//const int MOD=998244353;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,q;
    cin>>n>>q;
    
    string s;
    cin>>s;
    
    vector<int> ct(n);
    for(int i=1; i<n; i++){
        ct[i]=ct[i-1]+(s[i]=='C' && s[i-1]=='A');
    }
    while(q--){
        int l,r;
        cin>>l>>r;
        l--,r--;
        int ans=ct[r]-(l?ct[l-1]:0);
        if(l && s[l]=='C' && s[l-1]=='A') ans--;
        cout<<ans<<'\n';
    }
}

Measured memory_bytes: 1488
#include <bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define __TRUE "Yes"
#define __FALSE "No"
#define cout(x) cout << (x) << endl
#define MAX 100001
using namespace std;

int main() {
  int x,a,b;
  cin >> x >> a >> b;
  cout << (x-a) % b << endl;
}

Measured memory_bytes: 256
import fractions

a, b, c, d = map(int, input().split())
g = fractions.gcd(c, d)


t = b//c + b//d - b//(c*d//g)
l = (a - 1)//c + (a - 1)//d - (a - 1)//(c*d//g)
ans = b - (a - 1) - t + l

print(ans)

Measured memory_bytes: 5048
//Complete Binary Tree
#include <iostream>

using namespace std;

int parent(int i) {
    return i / 2;
}

int left(int i) {
    return 2 * i;
}

int right(int i) {
    return 2 * i + 1;
}

int main() {
    int H;
    cin >> H;
    int A[H + 1];
    for(int i = 1; i < H + 1; i++) cin >> A[i];

    for(int i = 1; i < H + 1; i++) {
        cout << "node " << i << ": key = " << A[i] << ", ";
        if(parent(i) > 0) cout << "parent key = " << A[parent(i)] << ", ";
        if(left(i) < H + 1) cout << "left key = " << A[left(i)] << ", ";
        if(right(i) < H + 1) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
}



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

int main(){
  int n, a = 1;
  char c;
  cin >> n;
  
  for (int i = 0; i < n; i++){
    cin >> c;
    
    if (c == 'Y'){
      cout << "Four" << endl;
      a = 0;
      break;
    }
  }
  
  if (a){
    cout << "Three" << endl;
  }
}

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();

		solve(a, b, c);

		in.close();

	}

	private static void solve(int a, int b, int c) {
		
		if((a <= c) && (c <= b)) {
			System.out.println("Yes");
			return;
		}
		
		if((b <= c) && (c <= a)) {
			System.out.println("Yes");
			return;
		}

		System.out.println("No");
	}

}

Measured memory_bytes: 22100
def main():
    n, m = map(int, input().split())
    *h, = map(int, input().split())
    l = [True for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        if h[a - 1] == h[b - 1]:
            l[a - 1] = False
            l[b - 1] = False
        elif h[a - 1] > h[b - 1]:
            l[b - 1] = False
        else:
            l[a - 1] = False
    ans = sum(l)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20004
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
using namespace std;

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

    if(r < 1200)
        cout << "ABC" << endl;
    else if(r < 2800)
        cout << "ARC" << endl;
    else
        cout << "AGC" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

int main() {
    string S, T;
    cin >> S >> T;
    int ans = INF;
    rep(i, S.length() - T.length() + 1) {
        int tmp = 0;
        rep(j, T.length()) {
            if (S[i + j] != T[j]) tmp++;
            //cout << i + j << endl;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
# coding: utf-8
S = input()
az = [0, len(S) - 1]
for i in range(len(S)):
  if S[i] == 'A':
    az[0] = i
    break
for i in range(len(S) - 1, 0, -1):
  if S[i] == 'Z':
    az[1] = i
    break
print(az[1] - az[0] + 1)


Measured memory_bytes: 3516
from math import gcd
import sys
input = sys.stdin.readline

n = int(input())
s = input().strip()
R = [0] * (n + 1)
G = [0] * (n + 1)
B = [0] * (n + 1)
ans = 0
for i in range(len(s)):
    R[i + 1] = R[i]
    G[i + 1] = G[i]
    B[i + 1] = B[i]
    if s[i] == 'R':
        R[i + 1] += 1
    elif s[i] == 'G':
        G[i + 1] += 1
    else:
        B[i + 1] += 1
for i in range(len(s)):
    for j in range(i, len(s)):
        if s[i] == 'R' and s[j] == 'B':
            ans += G[j + 1] - G[i]
            if (i + j) % 2 == 0 and s[(i + j) // 2] == 'G':
                ans -= 1
for i in range(len(s)):
    for j in range(i, len(s)):
        if s[i] == 'R' and s[j] == 'G':
            ans += B[j + 1] - B[i]
            if (i + j) % 2 == 0 and s[(i + j) // 2] == 'B':
                ans -= 1
for i in range(len(s)):
    for j in range(i, len(s)):
        if s[i] == 'B' and s[j] == 'R':
            ans += G[j + 1] - G[i]
            if (i + j) % 2 == 0 and s[(i + j) // 2] == 'G':
                ans -= 1
for i in range(len(s)):
    for j in range(i, len(s)):
        if s[i] == 'B' and s[j] == 'G':
            ans += R[j + 1] - R[i]
            if (i + j) % 2 == 0 and s[(i + j) // 2] == 'R':
                ans -= 1
for i in range(len(s)):
    for j in range(i, len(s)):
        if s[i] == 'G' and s[j] == 'R':
            ans += B[j + 1] - B[i]
            if (i + j) % 2 == 0 and s[(i + j) // 2] == 'B':
                ans -= 1
for i in range(len(s)):
    for j in range(i, len(s)):
        if s[i] == 'G' and s[j] == 'B':
            ans += R[j + 1] - R[i]
            if (i + j) % 2 == 0 and s[(i + j) // 2] == 'R':
                ans -= 1


print(ans)


Measured memory_bytes: 69104
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		int Rx1 = (r+x);
		int Rx2 = (x-r);
		int Ry1 = (r+y);
		int Ry2 = (y-r);
		if(x>0 && x<W && y>0 && y<H){
			if(Rx1<=W && Rx2>=0 && Ry1<=H && Ry2>=0){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26424
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[1006],t[1006];
int lens,lent,min1=0,min2=0,result1=0,z=0,p=0;
int main()
{
	scanf("%s",s);
	scanf("%s",t);
		lens=strlen(s);lent=strlen(t);
	for(int i=0;i<=lens-lent;i++)
	{
		for(int j=0;j<=lent-1;++j)
		{
			if(s[i+j]==t[j])
			min1++;
			if(min2<min1)
			min2=min1;
		}
		min1=0;
	}
	/*for(int i=0;i<=lent-1;i++)
	{
		z=i;
		for(int j=0;j<=lens-1;j++)
		{
			if(j>=z&&lens-1-j>=lent-z)
			{
				if((s[j]==t[z]&&s[j-1]==t[z-1])||((j==0||z==0)&&s[j]==t[z])||(p==0&&s[j]==t[z]))
				{
					p=1;
				z++;
				min1++;
					if(min1>min2)
					min2=min1;
				}
				else if(s[j-1]==t[z-1]&&s[j]!=t[z]&&p==1)
				{
					z=i;p=0;j--;min1=0;
				}
			}
		}
		p=0;
		min1=0;
	}
	result1=lent-min2;*/
	result1=lent-min2;
	printf("%d",result1);
	return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1e-6
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define MOD 1000000000
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("1\n")
using namespace std;
int main()
{
 long long N,T,q;
 scanf("%lld",&N);
 scanf("%lld",&T);
 scanf("%lld",&q);
 long long ans;
 long long last=ans=T;
 long long time=0,pop;
 for(long long i=0;i<N-1;i++)
 {
  scanf("%lld",&pop);
  time=pop;
  if(time>=last)
  {
   ans+=T;
   last=time+T;
  }
  else
  {
   if((time+T)>last)
   {
    ans+=time+T-last;
    last=time+T;
   }
  }
 }
 printf("%lld",ans);
}


Measured memory_bytes: 256
#include<stdio.h>

void bubbleSort(int *,int);

int swap=0;

int main(){
  int i,n;
  int data[100];

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

  bubbleSort(data,n);

  for(i=0;i<n-1;i++) printf("%d ",data[i]);
  printf("%d\n",data[i]);
  printf("%d\n",swap);

  return 0;

}

void bubbleSort(int *data,int n){
  int i,tmp,flag;

  flag=1;

  while(flag){
    flag=0;
    for(i=n-1;1<=i;i--){
      if(data[i]<data[i-1]){
	tmp=data[i];
	data[i]=data[i-1];
	data[i-1]=tmp;
	flag=1;
	swap++;
      }
    }
  }
}



Measured memory_bytes: 2052
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int n = stdIn.nextInt();
			if(n==0) break;
			
			int[] a = new int[n];
			int sum = 0;
			
			for(int i=0;i<a.length;i++){
				a[i] = stdIn.nextInt();
				sum+=a[i];
			}
			
			int max = a[0];
			int min = a[0];
			
			for(int i=1;i<a.length;i++){
				max = Math.max(max, a[i]);
				min = Math.min(min, a[i]);
			}

			sum-=(max+min);
			System.out.println(sum/(n-2));
		}

	}
}

Measured memory_bytes: 20944
#include <stdio.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int gcd(int a, int b)
{
	int r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

int main()
{
	int a, b;

	a = in(), b = in();
	printf("%d\n", gcd(a, b));
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i=0; i<N; i++) {
    cin >> d.at(i);
  }
  int ans=0;
  for (int i=0; i<N-1; i++) {
    for (int j=i+1; j<N; j++) {
       ans = ans + (d.at(i)*d.at(j));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#coding:utf-8                                              
import numpy as np                                         
                                                           
n = int(input())                                           
comb_list = [int(i) for i in input().split()]              
                                                           
max_num = max(comb_list)                                   
idx = np.abs(np.asarray(comb_list) - max_num / 2).argmin() 
ans = comb_list[idx]                                       
if ans == max_num:                                         
  ans = 0                                                  
                                                           
print(max_num, ans)                                        

Measured memory_bytes: 23392
h, w = map(int,input().split())
c = []


for i in range(h):
    tmp = input()
    flag = 0
    for j in range(len(tmp)):
        if tmp[j] == '#':
            flag = 1
            break
    if flag == 0:
        continue
    else:
        c.append(tmp)

tate = []

for i in range(len(c[0])):
    flag = 0
    for j in range(len(c)):
        if c[j][i] == '#':
            flag = 1
            break
    if flag == 0:
        tate.append(i)

for i in range(len(c)):
    c[i] = list(c[i])
    for j in range(len(tate)):
        c[i].pop(tate[j]-j)
    c[i] = ''.join(c[i])
    print(c[i])


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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 n,m,Q;
i64 s[101010], t[101010], x[101010];
void solve(){
	cin >> n >> m >> Q;
	for(int i = 1; i <= n; i++){
		cin >> s[i];
	}
	s[0] = -LINF; s[n+1] = LINF;
	for(int i = 1; i <= m; i++){
		cin >> t[i];
	}
	t[0] = -LINF; t[m+1] = LINF;
	
	for(int i = 0; i < Q; i++){
		cin >> x[i];
		i64 *pos = lower_bound(s+1,s+n+1,x[i]);
		i64 *pos2 = lower_bound(t+1,t+m+1,x[i]);
		i64 ans = min(max(*pos,*pos2)-x[i], x[i]-min(*(pos-1),*(pos2-1)));
		chmin(ans, (*pos-x[i])*2+x[i]-*(pos2-1));
		chmin(ans, (*pos2-x[i])*2+x[i]-*(pos-1));
		chmin(ans, (x[i]-*(pos-1))*2+*pos2-x[i]);
		chmin(ans, (x[i]-*(pos2-1))*2+*pos-x[i]);
		cout << ans << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>

int main(void){
  int x,a,b;

  scanf("%d %d %d",&x,&a,&b);

  if(a-b>=0)
    printf("delicious\n");
  else if(b-a<=x)
    printf("safe\n");
  else
    printf("dangerous\n");

  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; // find_by_order(), order_of_key()
using ll = long long int;
using i64 = long long int;
#define SZ(v) (int((v).size()))
#define ALL(vec) (vec).begin(),(vec).end()
template <typename T> inline void ckmax(T &x, T y) {if (y > x) x = y; }
template <typename T> inline void ckmin(T &x, T y) {if (y < x) x = y; }

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " =: " << a << endl;
    err(++it, args...);
}
template <typename T1, typename T2>
inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& buf) {
    return os << "(" << buf.first << ": " << buf.second << ")";
}
template<typename T>
inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v) {
    bool first = true;
    os << "[";
    for(unsigned int i = 0; i < v.size(); i++) {
        if(!first) os << ", ";
        os << v[i];
        first = false;
    }
    return os << "]";
}
template<typename T>
inline std::ostream &operator << (std::ostream & os,const set<T>& v) {
    bool first = true;
    os << "{";
    for (auto ii = v.begin(); ii != v.end(); ++ii) {
        if(!first) os << ", ";
        os << *ii;
        first = false;
    }
    return os << "}";
}
inline std::ostream &operator << (std::ostream & os,const std::multiset<pair<int,int>,greater<pair<int,int>>>& v) {
    bool first = true;
    os << "{";
    for (auto x: v) {
        if(!first) os << ", ";
        os << x;
        first = false;
    }
    return os << "}";
}
template<typename T1, typename T2>
inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v) {
    bool first = true;
    os << "{";
    for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii) {
        if(!first) os << ", ";
        os << *ii ;
        first = false;
        return os << "}";
    }
}
template<typename T>
inline std::ostream &operator << (std::ostream & os,const vector<vector<T>>& v) {
    for (auto &u: v) os << '\n' << u;
    return os;
}
template<typename T>
void finish(T ans) {cout << ans << '\n'; exit(0);}
const int MOD = 1e9 + 7;
const long long INF = 1e18;
const double EPS = 1e-6;
#define PI 3.14159265358979323846
/***********************************************************************/

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    float a, b;
    cin >> a >> b;
    cout << fixed << a / b << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define endl "\n"
#define loop(i,s,e) for(int i=s;i<e;i++)
#define int long long
#define mp make_pair
#define pii pair<int,int>
#define mset(a,f)  memset(a , f , sizeof(a))
#define pb push_back
const int N = 2e5 + 6;
const int M = 1e9 + 7;
const int inf = 1e17;
int A[N];
int B[N];
int n;
int dp[401][401];

int alpha(int i, int j)
{
	if(i >= j)return 0;
	int &abstergo = dp[i][j];
	if(abstergo != -1)return abstergo;
	int ans = inf;
	loop(k,i,j)
	{
		int a1 = 0;
		a1 = alpha(i,k)+alpha(k+1,j);
		a1 += B[j];
		if(i > 0)a1 -= B[i-1];
		ans = min(ans,a1);
	}
	return abstergo = ans;
}

void solve()
{
	cin >> n;

	loop(i,0,n)cin >> A[i];

	int sum = 0;

	loop(i,0,n)
	{
		sum += A[i];
		B[i] = sum;
	}

	mset(dp,-1);

	cout << alpha(0,n-1);

}
 
int32_t main()
{
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
    
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}


Measured memory_bytes: 4092
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  int N; cin >> N;
  vector <ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  sort(A.begin(), A.end());

  
  int start = 0, end = N - 1;
  ll now1 = A[start], now2 = A[end];
  ll ans = now2 - now1;

  for (int i = 0; i < N - 2; i++){
    ll num1 = abs(now1 - A[start + 1]);
    ll num2 = abs(now1 - A[end - 1]);
    ll num3 = abs(now2 - A[start + 1]);
    ll num4 = abs(now2 - A[end - 1]);

    ll M = max(max(num1, num2), max(num3, num4));
    ans += M;

    if (M == num1){
      start++; now1 = A[start];
    }else if(M == num2){
      end--; now1 = A[end];
    }else if(M == num3){
      start++; now2 = A[start];
    }else{
      end--; now2 = A[end];
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a[3][110],n,ans;
void messi(int x,int y,int k)
{
	if(x==2&&y==n)
	{ans=max(ans,k);return;}
	if(x>2||y>n)return;
	messi(x+1,y,k+a[x+1][y]);
	messi(x,y+1,k+a[x][y+1]); 
	
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[1][i];
	for(int i=1;i<=n;i++)cin>>a[2][i];
	messi(1,1,a[1][1]);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long,long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    string s; cin>>s;
    bool a=false,b=false,c=false,d=false;
    rep(i,s.size()){
        if(s.at(i)=='N') a=true;
        if(s.at(i)=='S') b=true;
        if(s.at(i)=='E') c=true;
        if(s.at(i)=='W') d=true;
    }
    cout<<((a==b and c==d)?"Yes":"No")<<endl;
}

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

// macros
#define overload_rep(_1, _2 ,_3 ,name, ...) name
#define re_p(i, n) for(int i = 0; i < (n); ++i)
#define r_ep(i, x, y) for(int i = (x); i < (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, r_ep, re_p,)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do{ cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << setprecision(20);
    }
} iosetup;

// Let's get AC!
int main(){

    long long x;
    cin >> x;

    long long ans = 0;
    ans += x / 11 * 2;
    x %= 11;
    if(x == 0);
    else if(x <= 6)ans++;
    else ans += 2;

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a<b){
    while(b!=0){
      cout<<a;
      b--;
    }
  }
  else
  {
    while(a!=0){
      cout<<b;
      a--;
    }
  }
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<long long> A(N), B(N), D(N);
  long long s = 0;
  for(int i = 0; i < N; ++i) cin >> A[i], s += A[i];
  for(int i = 0; i < N; ++i) cin >> B[i], s -= B[i], D[i] = A[i]-B[i];
  if(s < 0){
    cout << -1 << endl;
    return 0;
  }
  sort(D.begin(), D.end());
  int ans = N;
  for(int i = 0; i < N; ++i){
    if(D[i] < 0) continue;
    if(D[i] > s) break;
    s -= D[i];
    --ans;
  }
  cout << ans << endl;
}


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

int main() {
  long long int n;
  cin >> n;
  
  vector<long long int> initial(5,0);
  
  for (long long int i=0; i < n; i++) {
    string s;
    cin >> s;
    switch(s[0]) {
      case 'M':
        initial[0] ++;
        break;
      case 'A':
        initial[1] ++;
        break;
      case 'R':
        initial[2] ++;
        break;
      case 'C':
        initial[3] ++;
        break;
      case 'H':
        initial[4] ++;
        break;
    }
  }
  
  long long int ans = 0;
  
  for (int i = 0; i < 5; i++) {
    for (int j = i+1; j < 5; j++) {
      for (int k = j+1; k < 5; k++) {
        ans += initial[i] * initial[j] * initial[k];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int FindStep(int n)
{
    auto step = 0;
    auto power = (1 << 29);

    while (power > 0) {
        auto new_step = step + power;
        power >>= 1;

        if (1LL * new_step * (new_step + 1) / 2 < n) {
            step = new_step;
        }
    }
    return step + 1;
}

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

    auto res = FindStep(n);
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter

n, *s = sys.stdin.read().split()

def main():
    cnt = sorted(Counter(s).items(), key=lambda x: -x[1])
    m = cnt[0][1]
    ans = [s for s, c in cnt if c == m]
    print(*sorted(ans), sep='\n')
         

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 45292
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int K; cin >> K;
    int t = 0;
    for (int i = 0; i < 2*K; i++) {
        t = (t * 10 + 7) % K;
        if (t == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    int n,m; cin >> n;
    map<int,int> mp;
    int a[n];
    vector<int> v;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        mp[a[i]]++;
    }
    cin >> m;
    int b[m];
    for(int i = 0; i < m; i++){
        cin >> b[i];
        mp[b[i]]++;
    }
    for(int i = 0; i < n; i++){
        if (mp[a[i]] == 1){
            v.push_back(a[i]);
        }
    }
    /* 
    for(int i = 0; i < m; i++){
        if (mp[b[i]] == 1){
            v.push_back(b[i]);
        }
    }
    */
    for(int i = 0; i < v.size(); i++){
        cout << v[i] << endl;
    }
}


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

int main(){
    int n,m;
    cin>>n>>m;
    if(n==0) n=1;
    if(m==0) m=1;
    cout<<(n*(n-1)+m*(m-1))/2<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int a, b; cin >> a >> b;
  int n = (b - a);
  int h = 0;
  FOR(i, 0, n + 1)
    h += i;
  cout << h - b << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define pri 998244353 
#define nonod 1000001
#define pr pair <ll,ll>
#define mnx  1000001
#define inf 100000000000000001
#define prin(x) cout<<setprecision(9)<<fixed<<x<<endl;
using namespace std;





void masterstroke(ll ta){
ll p,q,r;
cin>>p>>q>>r;
cout<<(p+q+r-max(p,max(q,r)));

    }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)masterstroke(i);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2010;
const int MAXVAL = MAXN * MAXN;
int main(){
    int n;
    scanf("%d", &n);
    bitset<MAXVAL> subs;
    subs.set(0);
    int sm = 0;
    for(int i = 0; i < n; i++){
        int x;
        scanf("%d", &x);
        sm += x;
        subs |= (subs << x);
    }
    sm = (sm + 1) / 2;
    while(true){
        if(subs[sm]) return 0 * printf("%d\n", sm);
        sm++;
    }
}


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

int main() {
	int n;
	while(cin >> n && n){
		int ans = 0;
		for(int i = 1; i <= n / 2 + 1; ++i){
			int sum = i;
			for(int j = i + 1; j <= n; ++j){
				if(sum == n){
					ans++;
				}
				sum += j;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
    string S;
    cin >> S;
    if (S[0] == 'S')
    {
        cout << "Cloudy" << endl;
    }
    else if (S[0] == 'C')
    {
        cout << "Rainy" << endl;
    }
    else
    {
        cout << "Sunny" << endl;
    }
}


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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int N;
  cin>>N;
  vector<vector<int>> r(N,vector<int>(2));
  rep(i,N)
    cin>>r[i][0]>>r[i][1];
  double answer;
  int s,t;
  rep(i,N-1){
    for(int j=i+1; j<N; j++){
      s=r[i][0]-r[j][0];
      t=r[i][1]-r[j][1];
      answer+=sqrt(s*s+t*t);
    }
  }
  answer=answer*2/N;
  cout << fixed << setprecision(10);
  cout<<answer;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=10000007;

int main() {
  int64_t N,M;
  cin>>N>>M;
  for(int64_t i=M;i>0;i--){
    if(i*N<=M&&M%i==0){
    cout<< i;
    break;
    }
  }
}


Measured memory_bytes: 3588
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Foldable
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> VU.Vector Int -> VU.Vector Int -> Int
solve n vn cn = sum $ map (\i -> max 0 $ vn VU.! i - cn VU.! i) [0 .. n - 1]

main = do
  let readInt = fmap (second B.tail) . B.readInt

  n  <- (\vec -> vec VU.! 0) . VU.unfoldrN 1 readInt <$> B.getLine
  vn <- VU.unfoldrN n readInt <$> B.getLine
  cn <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n vn cn


Measured memory_bytes: 380
fn main(){
  let xy: Vec<u32> = read_vec();
  let ans: u32 = xy[0] + xy[1] / 2;
  println!("{}", ans);
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}


Measured memory_bytes: 4352
#include"bits/stdc++.h"
using namespace std;
using ll = long long;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))

ll f(ll n, ll b) {
	ll res = 0;
	while (n > 0) {
		res += n % b;
		n /= b;
	}
	return res;
}

int main()
{
	ll n, s, ans = 1ll << 60;
	cin >> n >> s;

	REP(b, 2, sqrt(n) + 2) {
		if (f(n, b) == s)ans = min(ans, b);
	}
	if (n == s)ans = min(ans, n + 1);
	REP(x, 1, sqrt(n) + 2) {
		ll y = s - x;
		ll xb = n - y;
		if (y < 0 || xb % x != 0)continue;

		ll b = xb / x;
		if (x < b && y < b && x*b + y == n) {
			ans = min(ans, b);
		}
	}
	cout << (ans == (1ll << 60) ? -1 : ans) << endl;
	return 0;
}


Measured memory_bytes: 256
let for_range s e step f =
  let rec loop i =
    if i > e then ()
    else
      begin f i;loop (i + step) end
  in loop s;;

let () =
  let num = 1000000 in
  let p = Array.make (num+1) 1 in
  let rec loop i =
    if i*i < num then
      begin
        if p.(i) = 1 then
          begin
            p.(i*2) <- 0;for_range (i*3) num (i*2) (fun x -> p.(x) <- 0);
          end;
        loop (i+2)
      end
  in
  p.(0) <- 0; p.(1)<-(0);
  for_range 4 num 2 (fun x -> p.(x) <- 0);loop 3;
  let get_count n =
    let count = ref 0 in
    for i = 1 to (n+(n mod 2))/2 do
      if p.(i) = 1 && p.(n-i+1) = 1 then
        if i = n-i+1 then
          count := !count+1
        else
          count := !count+2
    done;
    count
  in
  let rec read () =
    try let n = read_int () in
        Printf.printf "%d\n" !(get_count n);
        read ()
    with End_of_file -> ()
  in read ();;

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  string S;
  cin >> S;
  int n = S.length();
  ll ret = 0LL;
  REP(T,1<<(n - 1)) {
    ll sum = 0LL;
    string tmp;
    tmp += S[0];
    REP(i,n) {
      if(T & (1 << i)) {
        sum += stol(tmp);
        tmp = S[i + 1];
      }else{
        tmp += S[i + 1];
        if(i == n - 1) sum += stol(tmp);
      }
    }
    ret += sum;
  }
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int n,m,c;
  cin >> n >> m >> c;

  vector<int> b(m);
  REP(i,m) cin >> b[i];

  vector<vector<int>> a( n, vector<int>(m));
  REP(i,n) REP(j,m) cin >> a[i][j];

  int ans = 0;
  REP(i, n) {
    int t = 0;
    REP(j, m){
      t += a[i][j] * b[j];
    }
    if(t + c > 0) ans++;
  }

  cout << ans << endl;

  return 0;
}

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


inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
    return x * f;
}

const int N = 1e5 + 10;
int g1[N], g2[N], a[N];
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
    int n = read();
    for (int i = 1; i <= n; i++) a[i] = read();  
    g1[1] = a[1]; g2[n] = a[n];
    for (int i = 2, j = n - 1; i <= n; i++, j--) g1[i] = gcd(a[i], g1[i-1]), g2[j] = gcd(a[j], g2[j+1]);
   // for (int i = 1; i <= n; i++) printf("%d %d\n" , g1[i], g2[i]);
    int ans = max(g1[n], max(g1[n-1], g2[2]));
    for (int i = 2; i <= n; i++) {
        ans = max(gcd(g1[i-1], g2[i+1]), ans);
    }
    printf("%d\n", ans);
    return 0;
}

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

#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 

#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

const int N =1e5+5;

int mod= 1e9+7;
int dx[4]={0,0,+1,-1};
int dy[4]={+1,-1,0,0};


void solve() {
   
   int n;
   cin>>n;
   vi v(n,0);


   rep(i,0,n)
	    cin>>v[i];
  
   double sum=0;

   rep(i,0,n){
     sum += (double)1/v[i];
   }

   sum = (double)1/sum;
   cout<<fixed<<setprecision(8)<<sum<<endl;
    
}

int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
		solve();


	return 0;	  
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

vector<int>a[200000];

int main()
{
	int N,x;
	cin >> N; 
	vector<int>b(N+1);
	rep(i, 0, N)
	{
		cin >> x;
		a[x].push_back(i+1);
		b[i + 1] = x;
	}
	int s;
	long long int ans = 0, ansx;
	rep(i, 0, N)
	{
		ans += a[i + 1].size() * (a[i + 1].size() - 1) / 2;
	}
	rep(i, 0, N)
	{
		ansx = ans;
		s = a[b[i + 1]].size();
		ansx = ansx - s * (s - 1) / 2 + (s - 1) * (s - 2) / 2;
		cout << ansx << endl;
	}

	return 0;
}


Measured memory_bytes: 12712
// https://atcoder.jp/contests/abc149/tasks/abc149_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B, K;
    cin >> A >> B >> K;
    if (A >= K) {
        A -= K;
        K = 0;
    } else {
        K -= A;
        A = 0;
    }
    if (B >= K) {
        B -= K;
    } else {
        B = 0;
    }
    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

# 合計値
x = 0

# 組み合わせパターン
count = 0

for a in range(A + 1):
    x = a * 500
    for b in range(B + 1):
        x = a * 500 + b * 100
        for c in range(C + 1):
            x = a * 500 + b * 100 + c * 50
            if x == X:
                count += 1
print(count)


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

#define F first
#define S second
#define pb push_back
#define ld  double
#define ll long long
#define int long long


using namespace std;

const int MAXN = 101 * 1001;


int32_t main()
{
   ios::sync_with_stdio(0);cin.tie(0);
   int a,b;
   cin >> a >> b ;
   if(a>=0)
   {
       if(b>=a)
        return cout<<b-a,0;

        if(b>0)
            return cout<<2+a-b,0;
       if(b<-a)
           return cout<<1+(-a-b),0;
        return cout<<b+a+1,0;
   }
   if(a<=b&&b<=0)
        return cout<<b-a,0;
    if(a<=b&&abs(a)>abs(b))
        return cout<<abs(a)-abs(b)+1,0;
   if(a<=b)
       return cout<<a+b+1,0;
    return cout<<abs(b)-abs(a)+2,0;
}


Measured memory_bytes: 256
n=list(map(int,input().split()))
Y=list(map(int,input().split()))
P=[i for i in Y if i>=0]
M=[i*-1 for i in Y if i<0]
if P==[]:
    P.append(max(M)*1000)
if M==[]:
    M.append(max(P)*1000)
p=sorted(P)
m=sorted(M)
L1=[]
L2=[]
for i in range(n[1]):
    if n[1]-i-2<len(m) and i<len(p):
        L1.append(p[i]+m[n[1]-i-2]*2)
        L2.append(p[i]*2+m[n[1]-i-2])
if len(p)>=n[1]:
    L1.append(p[n[1]-1])
if len(m)>=n[1]:
    L2.append(m[n[1]-1])
print(min(min(L1),min(L2)))

Measured memory_bytes: 14484
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    used = set()
    Ans = [None for _ in range(M)]
    left = 1
    right = N
    for i in range(M):
        if right - left in used or 2 * (right - left) == N: right -= 1
        Ans[i] = (left, right)
        diff = right - left
        used |= {diff, N - diff}
        left += 1
        right -= 1
    for i in range(M): print(*Ans[i], sep=" ")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 36764
#include<iostream>

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

Measured memory_bytes: 256