akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
struct Node{
  int key;
  struct Node* p;
  struct Node* l;
  struct Node* r;
};
 
typedef struct Node node;
 
node* insert(node* r, int k) {
  node* x = r;
  node* y = NULL;
  node* z = (node*)malloc( sizeof(node) );
  z->key = k;
  z->l = NULL;
  z->r = NULL;
  z->p = NULL;
 
  while(x != NULL) {
    y = x;
 
    if(z->key < x->key) {
      x = x->l;
    }else {
      x = x->r;
    }
 
  }
  z->p = y;
 
  if(y == NULL) {
    r = z;
  }else if(z->key < y->key) {
    y->l = z;
  }else {
    y->r = z;
  }
 
  return r;
 
}
 
 
void printInorder(node* r) { 
   
  if(r->l != NULL) {
    printInorder(r->l);
  }
 
  printf(" %d", r->key);
 
  if(r->r != NULL) {
    printInorder(r->r);
  }
 
}
 
 
void printPreorder(node* r) {
 
  printf(" %d", r->key);
 
  if(r->l != NULL) {
    printPreorder(r->l);
  }
 
  if(r->r != NULL) {
    printPreorder(r->r);
  }
 
}
 
 
int main() {
 
  int m, k;
  node* r = NULL;
  char o[10];
  int i;
 
  scanf("%d", &m);
 
  for(i=0; i<m; i++) {
 
    scanf("%s", o);
 
    if(!strcmp(o, "insert")) { 
      scanf("%d", &k);
   
      r = insert(r, k);
   
    }
 
    if(!strcmp(o, "print")) {
      printInorder(r);
      printf("\n");
 
      printPreorder(r);
      printf("\n");
    }
 
 
  }
 
  return 0;
 
}

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

/*
ll xorxor(ll a){
    ll ret = ((a + 1) / 2) % 2;
    for(int n=0; n<59; n++){
        if((a >> n) & 1){
            if(a%2==0){
                ret |= (1 << n);
            }
        }
    }
    return ret;
}
*/
long long xorxor(long long  val) {
	long long ret = ((val + 1) / 2) % 2;
	for (int i = 0; i <= 59; i++) if ((val >> i) % 2) ret |= (1 ^ (val % 2)) << i;
	return ret;
}

int main(){
    ll A,B;

    cin >> A >> B;

    //cout << A << endl;
    //cout << B << endl;


    ll ans_A, ans_B;
    ans_A = xorxor(A-1);
    //cout << ans_A << endl;
    

    ans_B = xorxor(B);
    //cout << ans_B << endl;
    
    ll ans;
    ans = ans_A ^ ans_B;

    if(A >= 1){
        cout << ans << endl;
    }else{cout << ans_B << endl;}
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())

po_lst = [0]
a = 0
for i in range(0, 33, 2):
    a += 2**i
    po_lst.append(a)

ne_lst = [0]
a = 0
for i in range(1, 33, 2):
    a += (-2)**i
    ne_lst.append(a)

if n == 0:
    max_index = 0
elif n > 0:
    for k, i in enumerate(po_lst):
        if n < i:
            max_index = 2*(k-1)
            break
else:
    for k, i in enumerate(ne_lst):
        if n > i:
            max_index = 2*k-1
            break

def calcu(a, index, ans, po_lst, ne_lst):
    if index == -1:
        return ans
    elif a == 0:
        ans += '0'
        return calcu(a, index-1, ans, po_lst, ne_lst)
    else:
        b = (-2)**index
        if b > 0:
            k = (index // 2) + 1
            if a > po_lst[k-1]:
                a -= b
                ans += '1'
            else:
                ans += '0'
        else:
            k = (index+1) // 2
            if a < ne_lst[k-1]:
                a -= b
                ans += '1'
            else:
                ans += '0'
        return calcu(a, index-1, ans, po_lst, ne_lst)

print(calcu(n, max_index, '', po_lst, ne_lst))

Measured memory_bytes: 3064
def solve(l, r, i):
    if i - l < 1:
        return 0
    return dp[i - l] - dp[max(i - r - 1, 0)]


n, k = map(int, input().split())
MOD = 998244353
lr = [list(map(int, input().split())) for _ in range(k)]

dp = [0] * (n + 1)
dp[1] = 1

for i in range(2, n + 1):
    tmp = 0
    for l, r in lr:
        tmp += solve(l, r, i)
    tmp = tmp % MOD
    dp[i] = (dp[i - 1] + tmp) % MOD

print(tmp)

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

#define mod 1000000007
/*ll ebob(ll a, ll b){
	if(a == 0) return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a,b);
}*/
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	vector<double> vec(n);
	forloop(n){
		cin>>vec[i];
	}
	sort(vec.begin(), vec.end());
	for(int i = 1; i < n; i++){
		vec[i] = (vec[i]+vec[i-1])/2;
	}
	cout<<setprecision(10)<<vec[n-1];
	return 0; 
}

Measured memory_bytes: 256
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		Map<String, Integer> ansMap = new TreeMap<>();
		for(int i = 0 ; i < n; i++) {
			String nextStr = sc.nextLine();
			ansMap.compute(nextStr, (k,v) -> (v == null)? new Integer(1):new Integer(v+1));
		}
		sc.close();
		List<Map.Entry<String,Integer>> esList = ansMap.entrySet().stream()
	        .sorted(java.util.Collections.reverseOrder(java.util.Map.Entry.comparingByValue())).collect(Collectors.toList());
		
		int val = esList.get(0).getValue();
		for(Map.Entry<String, Integer> entry : esList) {
			if(val == entry.getValue()) {
				System.out.println(entry.getKey());
			}else {
				break;
			}
		}
	}
}

Measured memory_bytes: 183872
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int p = 0, q = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '(')
            p++;
        else if (p > 0)
            p--;
        else
            q++;
    }

    cout << string(q, '(') + s + string(p, ')') << endl;

    return 0;
}

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

#define what_is(x) cerr << #x << " is " << x << endl;

const int N = 1e5+1;

int n, a[N];
int go[N], back[N];

int main () {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// cout.precision(1); cout << fixed;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	go[0] = a[0]; back[n-1] = a[n-1];
	for (int i = 1; i < n; i++)
		go[i] = __gcd(go[i-1],a[i]);
	for (int i = n-2; i >= 0; i--)
		back[i] = __gcd(back[i+1],a[i]);

	int ans = max(go[n-2], back[1]);
	for (int i = 1; i < n-1; i++) {
		ans = max(ans, __gcd(go[i-1], back[i+1]));
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
constexpr int INF = 1 << 29;
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<ll> acc(N + 1);
    for (int i = 0; i < N; i++) {
        acc[i + 1] = acc[i] + A[i];
    }
    ll ans = 1LL << 62;
    int i = 1, k = 3;
    for(int j = 2; j < N - 1; j++) {
        while(i + 1 < j) {
            ll newarea = acc[i + 1] - acc[0];
            ll area = acc[i] - acc[0];
            if (abs(newarea - (acc[j] - newarea)) > abs(area - (acc[j] - area))) break;
            i++;
        }
        while(k + 1 < N) {
            ll newarea = acc[k + 1] - acc[j];
            ll area = acc[k] - acc[j];
            if (abs(newarea - (acc[N] - acc[j] - newarea)) > abs(area - (acc[N] - acc[j] - area))) break;
            k++;
        }
        vector<ll> area;
        area.push_back(acc[i]);
        area.push_back(acc[j] - acc[i]);
        area.push_back(acc[k] - acc[j]);
        area.push_back(acc[N] - acc[k]);
        sort(area.begin(), area.end());
        ans = min(ans, area.back() - area[0]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <memory.h>
int y[24*3600];
int main(void){
	int n,h,m,s,i,max;
	while(scanf("%d",&n),n){
		max=0;
		memset(y,0,sizeof(y));
		for(i=0;i<2*n;i++){
			scanf("%d:%d:%d",&h,&m,&s);
			if(!(i%2))y[h*3600+m*60+s]++;
			else y[h*3600+m*60+s]--;
		}
		for(i=0;i<24*3600;i++){
			if(i>0)y[i]+=y[i-1];
			if(y[i]>max)max=y[i];
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 944
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		int ans=0;
		for(int i=1; x>0; i++){
			x-=i;
			ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
//////////////////

void solve(){
  ini(N);
  vvi g(N + 1 , vi(N + 1));
  rep1(i,N) rep1(j,i - 1) g[j][i] = 1;
  rep1(i , N){
    if(N % 2 == 1 && i == N) break;
    int j = (N / 2 * 2) + 1 - i;
    if(i <= j) continue;
    g[j][i] = 0;
  }
  int cnt = 0;
  rep1(i , N) rep1(j , i){
    if(g[j][i]) cnt++;
  }
  out(cnt);
  rep1(i , N) rep1(j , i){
    if(g[j][i]) cout << j << " " << i << '\n';
  }

}

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

#define ll long long
#define endl "\n"
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define f first
#define s second
#define vecll vector<ll>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<ll,ll>>
#define mapllll map<ll,ll>
#define mapstrll map<string,ll>
#define mapllvecll map<ll,vecll>
#define setll set<ll>
#define fio ios_base::sync_with_stdio (false); cin.tie (NULL); cout.tie(NULL);

using namespace std;

ll const N=1e5+5;
ll const inf=1e18+5;
ll const MOD=1e9+7;

ll t,n,m,x,y,z,w,k;

int main()
{
    fio

    cin>>n>>k;

    ll a[n];
    ll f[n];

    for(ll i=0;i<n;i++) cin>>a[i];
    for(ll i=0;i<n;i++) cin>>f[i];

    sort(a,a+n);
    sort(f,f+n);

    ll i=0;
    ll j=n-1;
    while(i<j)
    {
        swap(f[i],f[j]);
        i++;
        j--;
    }

    ll ans = 1000000000000000;

    ll l = 0;
    ll r = 1000000000000;

    while(l<=r)
    {
        ll m = (l+r)/2;

        ll cnt = 0;
        for(ll i=0;i<n;i++)
        {
            ll val = m/f[i];
            cnt += max((ll)0,a[i]-val);
        }

        if(cnt<=k)
        {
            ans = min(ans,m);
            r = m-1;
        }
        else
        {
            l = m+1;
        }
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3328
n, k = map(int, input().split())
p = input()
x = p.split()
l = [int(s) for s in x]
shukei = 0

def shukei_def():
    global shukei
    if n == len(l):
        for i in range(k):
            shukei += min(l)
            l.remove(min(l))
        else:
            return

shukei_def()

print(shukei)

Measured memory_bytes: 9152
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var map = new long[n, 3];
        for (int i = 0; i < n; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < 3; j++)
                map[i, j] = long.Parse(line[j]);
        }
        Console.WriteLine(getAns(map,m));
    }
    public static long getAns (long[,] map, int m)
    {
        var n = map.GetLength(0);
        var ret = -99999999999999L;
        for (int i = 0; i < 8; i++)
        {
            var te = new long[n];
            for (int j = 0; j < n; j++)
            {
                if ((i & 4) == 4) te[j] += map[j, 0];
                else te[j] -= map[j,0];
                if ((i & 2) == 2) te[j] += map[j, 1];
                else te[j] -= map[j, 1];
                if ((i & 1) == 1) te[j] += map[j, 2];
                else te[j] -= map[j, 2];
            }
            Array.Sort(te);
            var te2 = 0L;
            for (int j = 0; j < m; j++)
                te2 += te[n - 1 - j];
            ret = Math.Max(ret, te2);
        }
        return ret;
    }
}



Measured memory_bytes: 13300
#include<iostream>
using namespace std;
int main()
{
int a1,a2,a3;
cin>>a1>>a2>>a3;
int x=min(min(a1,a2),a3);
int y=max(max(a1,a2),a3);
int z=a1+a2+a3-x-y;
int area=x*z/2;
cout<<area;
}

Measured memory_bytes: 256
#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 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// 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
// char '' str ""
ll mul(ll n){
  if(n==1) return 1;
  return mul(n-1)*n %MOD;
}

int main(void)
{
    ll N,M;cin>>N>>M;
    ll ans;
    ll b = min(N,M); ll a = max(N, M);

    if((N+1)==M ||(M+1)==N || N==M){
      ll m=mul(b);
      ans = m*m%MOD;
      if(N==M) ans = ans * 2 %MOD;
      else ans = ans * a % MOD;
    }else{
      ans = 0;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
from sys import stdin
input = stdin.readline
def main():
  n = int(input())
  a = list(map(int,input().split()))
  a.sort()
  if a[0] == 0:
    print(0)
    return
  ret = 1
  for i in a:
    ret *= i
    if ret > 10**18:
      print(-1)
      return
  print(ret)
main()


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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    LL n, m;
    cin >> n >> m;

    LL a[60], b[60], c[60], d[60];

    for(LL i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }

    for(LL i = 0; i < m; i++){
        cin >> c[i] >> d[i];
    }

    for(LL i = 0; i < n; i++){
        LL mn = 1e15, ans;
        for(LL j = m - 1; j >= 0; j--){
            LL dis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(dis <= mn){
                mn = dis;
                ans = j + 1;
            }
        }
        cout << ans << '\n';
    }
    return 0;
}



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

int main(void){
  int N, W;
  cin >> N >> W;
  vector<int> v(N + 1);
  vector<int> w(N + 1);
  v[0] = w[0] = 0;
  for(int i = 1; i <= N; i++){ cin >> v[i] >> w[i]; }

  vector<vector<int> > dp(N + 1, vector<int>(W + 1, 0));
  for(int i = 1; i <= N; i++){
    for(int j = 0; j <= W; j++){
      if(j - w[i] >= 0){
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
      }
      else{
        dp[i][j] = dp[i - 1][j];
      }
    }
  }

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

}

Measured memory_bytes: 6808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
const long long INF = 1LL<<60;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

int main(){
    int n;  cin >> n;
    string s; cin >> s;
    if (n%2==1){cout << "No"; return 0;}
    rep(i,n/2){
        if(s[i]!=s[i+n/2]) {cout << "No"; return 0;}
    }
    cout << "Yes";
    

    return 0;
}




Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

S = input()
N = len(S)

dict = defaultdict(list)

for i in range(N):
    dict[S[i]].append(i)

ans = float('inf')
for key, value in dict.items():
    value.insert(0, -1)
    value.append(N)

    length = 0
    for j in range(len(value) - 1):
        length = max(length, value[j + 1] - value[j])
    ans = min(ans, length)
print(ans - 1)

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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

long long s[maxn];

void solve(){
    int n;
    cin>>n;
    double sum = 0;
    for(int i=1;i<=n;i++)cin>>s[i];
    for(int i=1;i<=n;i++){
        sum += 1.0/s[i];
    }
    printf("%.10f\n",1.0/sum );
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
   // printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 384
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

T1,T2 = map(int,readline().split())
A1,A2 = map(int,readline().split())
B1,B2 = map(int,readline().split())

P = (A1 - B1) * T1
Q = (A2 - B2) * T2
if P > 0:
	P *= -1
	Q *= -1
 
if P + Q < 0:
	print(0)
elif P + Q == 0:
	print("infinity")
else:
	S = (-P) // (P + Q)
	T = (-P) % (P + Q)
	if T != 0:
		print(S * 2 + 1)
	else:
		print(S * 2)

Measured memory_bytes: 61956
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		long n=in.nextLong();
		if(n%2==1)
			System.out.println(0);
		else
		{
			long ans=0;
			long q=5;
			n=n/2;
			while(n>=q)
			{
				ans=ans+n/q;
				q=q*5;
			}
			System.out.println(ans);
		}		
	}
}
	


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

static const int MAX = 2000001;

int n = 0;
int H[MAX];

void maxHeapify(int i) {
	int l = 2 * i;
	int r = 2 * i + 1;
	int largest = i;
	if (l <= n && H[l] > H[largest]) largest = l;
	if (r <= n && H[r] > H[largest]) largest = r;

	if (largest != i) {
		swap(H[i], H[largest]); 
		maxHeapify(largest); 
	}
}

void insert(int key) {
	H[++n] = key;
	int i = n;
	while (i > 1 && H[i] > H[i / 2]) {
		swap(H[i], H[i / 2]);
		i /= 2;
	}
}

void extract() {
	cout << H[1] << endl;
	swap(H[1], H[n--]);
	maxHeapify(1);
}

int main() {
	string cmd;
	int key;
	while (1) {
		cin >> cmd;
		if (cmd == "insert") {
			cin >> key;
			insert(key);
		} else if (cmd == "extract") {
			extract();
		} else if (cmd == "end") {
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 5300
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
using namespace literals;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  const int MAX = 1e9;
  int N, K, S;
  cin >> N >> K >> S;
  int fill = (N - K > S ? MAX : 1 );
  for (int i = 0; i < N; ++i)
    cout << (i < K ? S : fill) << " ";
  cout << endl;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 100000

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    int f[N][10];
    int cost[N][11];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 10; j++){
            cin >> f[i][j];
        }
    }
    for(int i = 0; i < N; i++){
        for(int j =  0; j < 11; j++){
            cin >> cost[i][j];
        }
    }
    int ans = -(INF_INT + 1);
    for(int bit = 1; bit < 1 << 10; bit++){
        int temp = bit;
        int count[N];
        memset(count,0,sizeof count);
        for(int i = 0; i < 10; i++){
            if(temp & 1){
                for(int j = 0; j < N; j++){
                    count[j] += f[j][i];
                }
            }
            temp >>= 1;
        }
        int tempans  = 0;
        for(int i = 0; i < N;i++){
            tempans += cost[i][count[i]];
        }
        ans = max(ans,tempans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
using namespace std;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;	
int main() {
	ll n, ct[100010] = {};
	cin >> n;
	ll ans = 0;
	TFOR(i, n) {
		int nn; cin >> nn;
		if (nn > 100000)++ans;
		else {
			if (ct[nn-1] == nn)++ans;
			else ct[nn-1]++;
		}
	}
	TFOR(i, 100000) {
		if (ct[i] != i + 1)ans += ct[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }



int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
		return 0;
	}
	int a, b;
	cin >> a >> b;
	cout << a + b << endl;
	return 0;
}



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

public class MainClass
{
	public const long Giri = 1000000007;
	public class WarPair
	{
		public int Island1 {get; set;}
		public int Island2 {get; set;}
	}
	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		var t = Console.ReadLine();
		const string un = "UNRESTORABLE";
		if(s.Length < t.Length)
		{
			Console.WriteLine(un);
			return;
		}
		if(s.Length == t.Length)
		{
			Console.WriteLine(t);
			return;
		}
		var strs = new List<string>();
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < s.Length; i++)
		{
			bool substr = i + t.Length <= s.Length;
			for(int j = 0; substr && j < t.Length && i + j < s.Length; j++)
			{
				if(!(s[i+j] == '?' || s[i+j] == t[j]))
				{
					substr = false;
					break;
				}
			}
			if(substr)
			{
				for(int j = 0; j < s.Length; j++)
				{
					if(j >= i && j < i + t.Length)
					{
						sb.Append(t[j - i]);
					}
					else if(s[j] == '?')
					{
						sb.Append('a');
					}
					else
					{
						sb.Append(s[j]);
					}
				}
				strs.Add(sb.ToString());
				//Console.WriteLine("ibeg:" + i + ":" + sb.ToString());
				sb.Clear();
			}
			
		}
		if(strs.Count == 0)
		{
			Console.WriteLine(un);
		}
		else
		{
			strs.Sort();
			Console.WriteLine(strs[0]);
		}
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d=sc.nextInt();
		String ans="";

		switch(d) {
		case 22:
			ans="Christmas Eve Eve Eve";
			break;
		case 23:
			ans="Christmas Eve Eve";
			break;
		case 24:
			ans="Christmas Eve";
			break;
		case 25:
			ans="Christmas";
			break;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>

typedef long long ll;

using namespace std;

const string no = "No";
const string yes = "Yes";

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

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

  int max_value = 0;
  for (int i = 0; i < n; ++i) {
    int cur_value = arr[i];

    if (max_value >= cur_value + 2) {
      cout << no << endl;
      return 0;
    }
    max_value = max(max_value, cur_value);
  }

  cout << yes << endl;

  return 0;
}





Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
using namespace std;
char a[7];
int main()
{
	int i,n,m,s=0;
	for(i=1;i<=6;i++)
	{
		cin>>a[i];
		if(a[i]=='1')s++;
	}
	cout<<s;
	return 0;
}

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

int x[200001];
int y[200001];

int main(){
    
    
    int n;
    scanf("%d",&n);
    
    for(int i=1;i<=n;i++){
        scanf("%d",&x[i]);
        y[i] = x[i];
    }
    
    sort(y+1,y+n+1);
    int med = y[n/2];
    
    for(int i=1;i<=n;i++){
        if(x[i] > med) printf("%d\n",med);
        else printf("%d\n",y[n/2+1]);
    }
    
    return 0;
}

Measured memory_bytes: 3712
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        scan.close();

        Deque<String> queue = new ArrayDeque<String>();

        queue.add("a");

        while (queue.getFirst().length() < n) {
            String str = queue.poll();

            char[] charArray = str.toCharArray();
            char max = 'a';
            for (char c : charArray) {
                if (max < c) {
                    max = c;
                }
            }

            for (char c = 'a'; c <= max + 1; c++) {
                queue.add(str + c);
            }

        }

        for (String s : queue) {
            System.out.println(s);
        }
    }

}


Measured memory_bytes: 52420
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
ll n, W, w0, ans = 0;
vector <ll> v[4];

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> W;
    for (int i = 0; i < n; i++) {
        ll w, V;
        cin >> w >> V;
        if (i == 0) w0 = w;
        v[w - w0].push_back(V);
    }


    for (int i = 0; i < 4; i++) {
        sort(v[i].begin(), v[i].end());
        v[i].push_back(0);
        reverse(v[i].begin(), v[i].end());

        for (int j = 1; j < v[i].size(); j++) {
            v[i][j] += v[i][j-1];
        }
    }

    for (int i = 0; i < v[0].size(); i++) {
        for (int j = 0; j < v[1].size(); j++) {
            for (int k = 0; k < v[2].size(); k++) {
                for (int l = 0; l < v[3].size(); l++) {
                    ll tmp = v[0][i] + v[1][j] + v[2][k] + v[3][l];
                    if (W >= w0 * (ll)(i + j + k + l) + (ll)(j + 2 * k + 3 * l)) {
                        ans = max(ans, tmp);
                    }
                }
            }
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
<?php
list($n,$c,$k) = explode(" ",trim(fgets(STDIN)));
if($c == 1){
echo $n;
}else{
$i = 0;
$a = array();
while($i < $n){
$a[$i] = trim(fgets(STDIN));
++$i;
}
sort($a);
$ans = 0;
$t = 0;
foreach($a as $val){
if($t == 0){
$t = $val;
$n = 1;
++$ans;
}else{
if($val > $t + $k){
++$ans;
$t = $val;
$n = 1;
}else{
++$n;
if($n == $c){
$t = 0;
}
}
}
}
echo $ans;
}
?>

Measured memory_bytes: 22004
A, B, C, D = map(int, input().split())
if C>=B or A>=D:
    print(0)
elif C>=A:
    if D >= B:
        print(B-C)
    else:
        print(D-C)
elif A > C:
    if D >= B:
        print(B-A)
    else:
        print(D-A)

Measured memory_bytes: 9132
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

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

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vi a(n); for (int &x : a) cin >> x;
    int res = 0;
    fore(i, 0, n) {
        int cnt = 0;
        while (i + 1 < n && a[i] >= a[i + 1]) {
            ++cnt, ++i;
        }
        res = max(res, cnt);
    }
    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int n,k,input;
long long prefikspos[100005],prefikssum[100005],ans=0,temp;
int main()
{
	scanf("%d%d",&n,&k);
	prefikspos[0]=0;
	prefikssum[0]=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&input);
		prefikspos[i]=prefikspos[i-1]+((input>0)?input:0);
		prefikssum[i]=prefikssum[i-1]+input;
	}
	for(int i=1;i<=n-k+1;i++)
	{
		temp=prefikspos[n]-(prefikspos[i+k-1]-prefikspos[i-1])+max(prefikssum[i+k-1]-prefikssum[i-1],0LL);
		ans=max(ans,temp);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1920
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long c = sc.nextLong();
		long[] dists = new long[n + 2];
		dists[n + 1] = c;
		int[] values = new int[n + 1];
		long max = 0;
		long cur = 0;
		long[] leftMaxes = new long[n + 1];
		for (int i = 1; i <= n; i++) {
		    dists[i] = sc.nextLong();
		    values[i] = sc.nextInt();
		    cur += values[i] + dists[i - 1] - dists[i];
		    max = Math.max(max, cur);
		    leftMaxes[i] = max;
		}
		cur = 0;
		max = 0;
		long[] rightMaxes = new long[n + 1];
		for (int i = n; i >= 1; i--) {
		    cur += values[i] + dists[i] - dists[i + 1];
		    max = Math.max(max, cur);
		    rightMaxes[i] = max;
		}
		max = 0;
		max = Math.max(max, leftMaxes[n]);
		max = Math.max(max, rightMaxes[1]);
		for (int i = 1; i < n; i++) {
		    max = Math.max(max, leftMaxes[i] - dists[i] + rightMaxes[i + 1]);
		}
		for (int i = n; i > 1; i--) {
		    max = Math.max(max, rightMaxes[i] - (c - dists[i]) + leftMaxes[i - 1]);
		}
		System.out.println(max);
    }
}



Measured memory_bytes: 92852
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define f(i,s,n) for(int i=s;i<=n;++i)
const lli mx = 1e9+7;
const lli mn = 2e5+1;
vector<vector<int>> g(mn);
vector<bool> MyVisit(mn, false);

int n,m,a,b;

int dfs(int x){
    if(MyVisit[x]) return 0;
    MyVisit[x] = true;
    int val=0;
    for(auto vertex:g[x]){
        if(!MyVisit[vertex]){
            val+=dfs(vertex);
        }
    }
    return val+1;
}

int main(){
   
   cin>>n>>m;
    
    set<pair<int, int>> st;
    for(int i=0;i<m;++i){
        cin>>a>>b;
        if(st.find({a,b}) == st.end() && st.find({b,a}) == st.end()){
            g[a].push_back(b);
            g[b].push_back(a);
            st.insert({a,b});
            st.insert({b,a});
           
        }
    }
    int ans = 0;
    for(int i=1;i<=n;++i){
        if(!MyVisit[i]){
            ans = max(ans, dfs(i));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 42148
s = input()
ans = "Yes"
if s[::-1] != s:
    ans = "No"
elif s[:(len(s)-1)//2] != s[:(len(s)-1)//2][::-1]:
    ans = "No"
elif s[((len(s)+2) // 2):] != s[((len(s)+2) // 2):][::-1]:
    ans = "No"
print(ans)


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

const int INF = 1e9;

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

  bool g[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      g[i][j] = false;
    }
  }

  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    g[a-1][b-1] = true;
    g[b-1][a-1] = true;
  }

  vector<int> order(n);
  for(int i=0;i<n;i++) order[i] = i;

  int cnt = 0;
  do{
    if(order[0] != 0) continue;

    for(int i=0;i<n-1;i++){
      int prev = order[i];
      int next = order[i+1];

      if(!g[prev][next]) break;

      if(i == n-2) cnt++;
    }


  }while(next_permutation(order.begin(),order.end()));

  cout << cnt << endl;

}

Measured memory_bytes: 3616
#include<iostream>

int main()
{
		int arr[2], tmp;
		while(true)
		{
			std::cin >> arr[0] >> arr[1];
			if(arr[0] == 0 && arr[1] == 0) break;
			if(arr[0] > arr[1]) {
					tmp = arr[1];
					arr[1] = arr[0];
					arr[0] = tmp;
			}
			std::cout << arr[0] << " " << arr[1] << "\n";
		}
		return 0;
}

Measured memory_bytes: 1156
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 5e5 + 5;

int i,n,m,fact[N],ifact[N];

int power(int x,int y)
{
    int res=1;
    x%=mod;
    while(y>0)
    {
        if(y&1)
            res=(res*x)%mod;
        y>>=1;
        x=(x*x)%mod;
    }
    return res;
}
 
int modinv(int n)
{
    return power(n,mod-2);
}
 
int add(int a,int b)
{
    a%=mod,b%=mod;
    return a+b>=mod?a+b-mod:a+b;
}
int mul(int a,int b)
{
    a%=mod,b%=mod;
    return (a*b)%mod;
}

int C(int n,int r)
{
    if(n<r || r<0)
        return 0;
    return mul(fact[n],mul(ifact[r],ifact[n-r]));
}

int P(int n,int r)
{
    if(n<r || r<0)
        return 0;
    return mul(fact[n],ifact[n-r]);
}

void precompute()
{
    fact[0]=1;
    ifact[0]=1;
    for(int i=1;i<N;++i)
    {
        fact[i]=mul(fact[i-1],i);
        ifact[i]=mul(ifact[i-1],modinv(i));
    }
}

void solve()
{
    precompute();
    cin>>n>>m;
    int ans=1;
    for(i=1;i<=n;++i)
    {
        ans*=(m-i+1);
        ans%=mod;
    }
    ans*=ans;
    ans%=mod;
    for(i=1;i<=n;++i)
    {
        int rem=C(n,i);
        rem*=P(m,i);
        rem%=mod;
        rem*=P(m-i,n-i);
        rem%=mod;
        rem*=P(m-i,n-i);
        rem%=mod;
        if(i&1)
            ans-=rem;
        else
            ans+=rem;
        ans+=mod;
        ans%=mod;
    }
    cout<<ans;
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 11464
#include <cstdio>
#include <iostream>

using namespace std;

#define MAX_N 999

int N;

int main() {
    cin >> N;

    int r = 100;
    while (N / r > 0) {
        N = N - r;
    }
    r = 10;
        while (N / r > 0) {
            N = N - r;
        }

    //printf("%d\n", N);

    if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) printf("hon\n");
    else if (N == 0 || N == 1 || N == 6 || N == 8) printf("pon\n");
    else printf("bon\n");

    return 0;
}





Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define asll unsigned long long
#define pii pair<int,int>
#define st first
#define nd second

asll M=1e9+7;//20190518
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	srand(time(0));//20190709
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b)<<endl;
}



Measured memory_bytes: 256
'use strict'
function Main(input) {
  let arr = input.split("\n")[0].split(" ");
  let ans = 0;
  if(arr[1] != 1){
  	ans = arr[0] - arr[1];
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const int MAX = 500000;
int A[MAX];

void maxHeapify(int a[], int h, int i) {
  int right_id = 2 * i + 1;
  int left_id = 2 * i;
  int largest_id = i;

  if (right_id <= h) {
    int right_key = a[right_id];
    if (right_key <= a[i]) {
      largest_id = i;
    } else {
      largest_id = right_id;
    }
  }

  if (left_id <= h) {
    int left_key = a[left_id];
    if (left_key > a[largest_id]) {
      largest_id = left_id;
    }
  }
  if (largest_id != i) {
    int tmp = a[i];
    a[i] = a[largest_id];
    a[largest_id] = tmp;
    maxHeapify(A, h, largest_id);
  }
}

void buildHeap(int a[], int h) {
  for (int i = h / 2; i >= 1; i--) {
    maxHeapify(a, h, i);
  }
}

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

  buildHeap(A, n);
  for (int i = 1; i <= n; i++) cout << " " << A[i];
  cout << endl;
}



Measured memory_bytes: 4968
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
    long long n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    long long round=n/(a+b);
    long long ans1,ans2;
    ans1=round*a;ans2=round*b;
    round=n%(a+b);
    if (round>a) round=a;
    ans1+=round;
    printf("%lld\n",ans1);

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define double long double
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }
int c[4];
double dp[500][500][500];
int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(19); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		int x; cin >> x;
		c[x]++;
	}
	dp[0][0][0] = 0;
	for (int c3 = 0; c3 <= 500; ++c3) {
		for (int c2 = 0; c2 <= 500; ++c2) {
			for (int c1 = 0; c1 <= 500; ++c1) {
				if (c1 == 0 && c2 == 0 && c3 == 0) continue;
				if (c1 + c2 + c3 > n) continue; 
				double p1 = (double)c1 / (double)n;
				double p2 = (double)c2 / (double)n;
				double p3 = (double)c3 / (double)n;
				dp[c1][c2][c3] = (p1 * (c1 == 0 ? 0 : dp[c1 - 1][c2][c3]) + p2 * (c2 == 0 ? 0 : dp[c1 + 1][c2 - 1][c3]) + p3 * (c3 == 0 ? 0 : dp[c1][c2 + 1][c3 - 1]) + 1.0l) / (p1 + p2 + p3);
			}
		}
	}
	cout << dp[c[1]][c[2]][c[3]];
}

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

namespace arc065_b
{
	public class Unionfind
	{
		private static int[] par;//親
		private static int[] rank;//深さ
		public void init(int n)//初期化
		{
			par = new int[n]; rank = new int[n];
			for (int i = 0; i < n; i++)
			{
				par[i] = i;
				rank[i] = 0;
			}
		}
		public int root(int x)//根を求める
		{
			return par[x] == x ? x : par[x] = root(par[x]);
		}
		public int showpar(int n)//根を返す
		{
			return par[n];
		}
		public void unite(int x, int y)//集合を併合
		{
			x = root(x); y = root(y);
			if (x == y) return;
			else
			{
				if (rank[x] < rank[y]) par[x] = y;
				else
				{
					par[y] = x;
					if (rank[x] == rank[y]) rank[x]++;
				}
			}
		}
		public bool issame(int x, int y)//同じ集合に属しているか
		{
			return root(x) == root(y);
		}
	}
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			Unionfind tree = new Unionfind(); tree.init(x[0] * 2);
			for (int i = 0; i < x[1]; i++)
			{
				int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
				a[0]--; a[1]--;
				tree.unite(a[0], a[1]);
			}
			for (int i = 0; i < x[2]; i++)
			{
				int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
				a[0]--; a[1]--;
				tree.unite(a[0] + x[0], a[1] + x[0]);
			}
			Dictionary<Tuple<int, int>, int> dic = new Dictionary<Tuple<int, int>, int>();
			for (int i = 0; i < x[0]; i++)
			{
				Tuple<int, int> tup = new Tuple<int, int>(tree.root(i), tree.root(i + x[0]));
				if (!dic.ContainsKey(tup)) dic[tup] = 0;
				dic[tup]++;
			}
			for (int i = 0; i < x[0]; i++)
			{
				Tuple<int, int> tup = new Tuple<int, int>(tree.root(i), tree.root(i + x[0]));
				if (i != 0) Console.Write(" ");
				Console.Write(dic[tup]);
			}
			Console.WriteLine();
		}
	}
}

Measured memory_bytes: 34908
n = int(input())
a = list(map(int, input().split()))

dp = [0] * n
dp[0] = 1000
for i in range(1, n):
    dp[i] = dp[i-1]
    for j in range(i):
        dp[i] = max(dp[i], dp[j] // a[j] * a[i] + dp[j] % a[j])
print(dp[-1])


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


signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int n;
    cin>>n;
    map<string, int> m;
    m["AC"] = 0;
    m["WA"] = 0;
    m["TLE"] = 0;
    m["RE"] = 0;

    while(n--){
        string s;
        cin>>s;
        m[s]++;
    }

    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;


    return 0 ;
}


Measured memory_bytes: 3680
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c=0, d[100000], e[100000],f=0, count = 0;
	char ac,uc[100000];
	cin >>a>>b ;
	cout << (a - 1)*(b - 1) << endl;
		return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long K = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();

        if(K < A){
            System.out.println(1+K);
        } else if(A+2 > B){
            System.out.println(1+K);
        } else {
            long N = (K+1- A) / 2 * (B-A) + A + ((K+1- A) % 2);
            System.out.println(N);
        }

    }
}


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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

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

    if(N>=10) cout << R << endl;
    else cout << R+100*(10-N) << endl;
    return 0;
}

Measured memory_bytes: 256