akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

vl ans;
void dfs(ll r){
  if(r>3234566667)return;
  ans.push_back(r);
  dfs(r*10+r%10);
  if(r%10 !=0)dfs(r*10+r%10-1);
  if(r%10 !=9)dfs(r*10+r%10+1);
  return;
}

int main() {
  int k;
  cin>>k;
  srep(i,1,10){
    dfs(i);
  }
  sort(rng(ans));
  //print(sz(ans));
  print(ans[k-1]);
  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string  str;
    cin >> str;
    if(str[0] != 'A'){
        cout << "WA\n";
        return 0;
    }
    string checkStr(begin(str) + 2, end(str) - 1);
    if(count(begin(checkStr), end(checkStr), 'C') != 1){
        cout << "WA\n";
        return 0;
    }
    int cnt = 0;
    for(int i = 1; i < str.size(); i++){
        cnt += 'A' <= str[i] && str[i] <= 'Z';
    }
    if(cnt == 1){
        cout << "AC\n";
    }else{
        cout << "WA\n";
    }
}

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

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> l(Q), r(Q), t(N);
  for(int i = 0; i < Q; i++){
    cin >> l.at(i) >> r.at(i);
  }
  
  for(int i = 0; i < N - 1; i++){
    if(S.at(i) == 'A' && S.at(i+1) == 'C') t.at(i + 1) = t.at(i)+1;
    else t.at(i+1) = t.at(i);
  }
  
  for(int i = 0; i < Q; i++) cout << t.at(r.at(i) - 1) - t.at(l.at(i) - 1) << endl;
}

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

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	vector<int>v;
	v.push_back(m);
	for(int i = 0; i < n; ++i){
		scanf("%d", &m);
		v.push_back(m);
	}
	sort(v.begin(), v.end());
	int ans = v[1] - v[0];
	for(int i = 0; i < v.size()-1; ++i){
		ans = __gcd(ans, v[i+1] - v[i]);
	}
	cout << ans << endl;



	return 0;
}

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

ll ppow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}

ll E[4000][4000];
int a[4000];

int main(){
	ll t=ppow(2,MOD-2);
	int n,q;scanf("%d%d",&n,&q);
	rep(i,n)scanf("%d",&a[i]);
	rep(i,n)rep(j,n){
		E[i][j]=(a[i]>a[j]);
	}
	rep(i,q){
		int x,y;scanf("%d%d",&x,&y);x--;y--;
		if(x>y)swap(x,y);
		rep(j,n){
			if(j==x||j==y)continue;
			E[j][x]=E[j][y]=(E[j][x]*t+E[j][y]*t)%MOD;
			E[x][j]=E[y][j]=(E[x][j]*t+E[y][j]*t)%MOD;
		}
		E[x][y]=E[y][x]=(E[x][y]*t+E[y][x]*t)%MOD;
	}
	ll ans=0;
	rep(i,n){
		for(int j=i+1;j<n;j++){
			(ans+=E[i][j])%=MOD;
		}
	}
	cout<<ans*ppow(2,q)%MOD<<endl;
}

Measured memory_bytes: 94208
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

int main(){
	int n,max_id,max_value,id,a,b;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		max_value = -1;

		for(int i = 0; i < n; i++){
			scanf("%d %d %d",&id,&a,&b);
			if(max_value < a + b){
				max_value = a + b;
				max_id = id;
			}
		}
		printf("%d %d\n",max_id,max_value);
	}

    return 0;
}

Measured memory_bytes: 2696
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  string s;cin>>s;
  int n=(int)s.size();
  rep(i, n-1){
    if(s[i+1]==s[i]){
      cout<<i+1<<" "<<i+2<<endl;return 0;
    }
  }
  rep(i, n-2){
    if(s[i]==s[i+2]){
      cout<<i+1<<" "<<i+3<<endl;return 0;
    }
  }
  cout<<"-1 -1"<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 512
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n;
	ll w;
	cin>>n>>w;
	ll val[n];
	ll weight[n];
	for(ll i=0;i<n;i++)
	{
		cin>>weight[i]>>val[i];
	}
	ll dp[n+1][w+1];
	for(ll i=0;i<n+1;i++)
	dp[i][0]=0;
	for(ll i=0;i<w+1;i++)
	dp[0][i]=0;
	for(ll i=1;i<=n;i++){
	for(ll j=1;j<=w;j++)
	{
		if(weight[i-1]<=j)
		{
			dp[i][j]=max(val[i-1]+dp[i-1][j-weight[i-1]],dp[i-1][j]);
		}
		else
		dp[i][j]=dp[i-1][j];
	}}
	cout<<dp[n][w]<<endl;
	return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stdio.h>
#include <string.h>

#define rep(i, n) for (int i = 0; i < n; ++i)
typedef unsigned long long ll;

using namespace std;

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " <<  z << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main(){
	int n; cin >> n;
	int a = n / 2;
	int b = (n + 1) / 2;
	cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>	
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;

const int inf = int(2e9);
const int mod = inf + 7;
using namespace std;

void solve()
{
	int a[5];
	for(int i = 0; i < 5; ++i) cin >> a[i];
	int k;
	cin >> k;
	for(int i = 0; i < 5; ++i){
		for(int j = i + 1; j < 5; ++j){
			if(abs(a[i] - a[j]) > k) {
				cout << ":(";
				return;
			}
		}
	}
	cout << "Yay!";
}

int main()
{
	Red;
	solve();
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	fmt.Scan(&N)
	T := make([]int, N + 1)
	X := make([]int, N + 1)
	Y := make([]int, N + 1)
	T[0] = 0
	X[0] = 0
	Y[0] = 0
	for i := 0; i < N; i++ {
		fmt.Scan(&T[i + 1], &X[i + 1], &Y[i + 1])
	}

	ans := true
	for i := 0; i < N; i++ {
		dt := float64(T[i + 1] - T[i])
		dist := math.Abs(float64(X[i + 1] - X[i])) + math.Abs(float64(Y[i + 1] - Y[i]))
		if dt < dist {
			ans = false
		}
		if int64(dist) % 2 != int64(dt) % 2.0 {
				ans = false
				}
	}
	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 5504
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int cnt=0;
        for(int i=0;i<10;i++)for(int j=0;j<10;j++)for(int k=0;k<10;k++)for(int l=0;l<10;l++)if(i+j+k+l==n)cnt++;
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int n,k;
ll a[100005],dp[100005],s[100005];

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

cin>>n>>k;
rep(i,1,n)
{
	cin>>a[i];
	s[i]=s[i-1]+a[i];
	dp[i]=dp[i-1];
	if(a[i]>0)dp[i]+=a[i];
}
ll ans=0;
rep(i,k,n)
{
	ans=max(ans,max(dp[i-k]+dp[n]-dp[i],dp[i-k]+dp[n]-dp[i]+s[i]-s[i-k]));
}
ol(ans);
return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include <numeric>
// #include<string>
#include<vector>
#include <algorithm>
#include <cmath>
// #include <functional>
 
using namespace std;
 
int main()
{
    // Input
    unsigned long long H, W;
    cin >> H >> W;
 
    unsigned long long ans;
    if (H == 1 || W == 1) {
        ans = 1;
    } else if (H%2 == 0) {
        ans = H / 2 * W;
    } else {
        ans = ((H / 2) * 2 + 1) * (W / 2);
        if (W%2 == 1) {
            ans += H / 2 + 1;
        }
    }
 
    cout << ans;
 
    return 0;
}


Measured memory_bytes: 256
def main():
  n,d = map(int,input().split())
  ans = 0
  d = d ** 2
  for i in range(n):
    x, y = map(int,input().split())
    dis = x ** 2 + y ** 2
    if d >= dis:
      ans += 1
  print(ans)



if __name__ == '__main__':
  main()

Measured memory_bytes: 9184
# -*- coding: utf-8 -*-
import math
import sys

s = str(sys.stdin.readline().rstrip())
s = s.split("/")
s_n = int(s[0])*10000 + int(s[1])*100 + int(s[2])

if s_n <= 20190430:
  print("Heisei")
else:
  print("TBD")







Measured memory_bytes: 2940
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
    int F => int.Parse(Str);
    long FL => long.Parse(Str);
    int[] G => Strs.Select(int.Parse).ToArray();
    long[] GL => Strs.Select(long.Parse).ToArray();
    string Str => ReadLine();
    string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    const int MOD = 1000000007;
    public K()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        WriteLine(Solve());
        Out.Flush();
    }
    long Solve()
    {
        // (b,m)
        // 最初は (1,0)
        // B>=A+3 ならお金を使うべき
        // B<=A+2 なら地道にやる
        //   0              A-1       A       A+1      A+2         A+3         A+4
        // (1,0) => ... => (A,0) => (0,1) => (B,0) => (B-A,1) => (2B-A,0) => (2B-2A,1) => ...
        // (1,0) => ... => (A,0) => (A+1,0) => (A+2,0) => (A+3,0) => (A+4,0) => ...
        var I = G;
        int K = I[0], A = I[1], B = I[2];
        if (B <= A + 2 || K <= A) return K + 1;
        var r = K - A - 1L;
        return B + (r / 2) * (B - A) + r % 2;
    }
}


Measured memory_bytes: 13268
#include<cstdio>
#include<cstring>
const int N=1e5+10;
char s[N];
int main()
{
	int i;
	scanf("%s",s+1);
	int l=strlen(s+1);
	for (i=2;i<=l;i++)
	  if (s[i]=='C'&&s[i-1]=='A')
	  {
	    printf("Yes");
	    return 0;
		}
	printf("No");
}

Measured memory_bytes: 128
#include<stdio.h>
#define N 100000
int main()
{
    int a[N],b[N],i,n;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        b[a[i]-1]=i+1;
    }
   for(i=0;i<n;i++)
    {
        printf("%d ",b[i]);
    }
}


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

int main (){
    int a,b;

    cin >> a >> b ;
    
    
    
    cout << a/b << " " << a%b << " " << fixed << setprecision(6) << (double)a/(double)b << endl;
    return 0;
    
}

Measured memory_bytes: 3212
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	int m;
	cin>>m;
	vint x(n);
	vint y(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--,b--;
		if(a>b) swap(a,b);
		if(a==0) x[b]=1;
		if(b==n-1) y[a]=1;
	}
	rep(i,n){
		if(x[i]&&y[i]){
			cout<<"POSSIBLE"<<endl;
			return;
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

int main(){
  int N;
  cin >> N;
  vector<int64_t> l(2);
  l.at(0)=2;
  l.at(1)=1;
  for(int i=2;i<=N;i++){
    int64_t tmp=l.at(0)+l.at(1);
    l.at(0)=l.at(1);
    l.at(1)=tmp;
  }
  cout << l.at(1) << endl;
  return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define __              ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i,a,b) 		for(int i=a;i<b;i++)
#define repb(i,a,b) 	for(int i=a;i>=b;i--)
#define inp(a,n)		for(int i=0 ; i<n ; i++){cin >> a[i];} 



int bs(int a[] , int s , int e, int x){
	if(s<=e){
		int m = (s+e)/2;
		if(a[m]==x)
			return m;
		else if(a[m] > x)
			return bs(a,s,m-1,x);
		else return bs(a,m+1,e,x);
	}
	return -1;
}

int32_t main(){	

	int k,n;
	cin >> k >> n;
	int a[n];
	inp(a,n);

	int d[n];
	int s=0;

	rep(i,0,n-1){
		d[i] = abs(a[i+1]-a[i]);
		s+=d[i];
	//	cout << d[i] << " ";
	}
	d[n-1] = k-s;

//	cout << d[n-1];
	int m = d[0];
	rep(i,0,n){
		if(m < d[i])
			m = d[i];
	}

	cout << k-m << endl;
		
}





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

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

  double ans=0;

  for(int i=1;i<N+1;i++){
    int hold = i;
    int count = 0;
    while(hold<K){
      hold *= 2;
      ++count;
    }
    double CC = pow(0.5,count);
    double NN = N;
    ans += (1/NN) * CC;
  }
  cout << fixed << setprecision(20);
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

vector<double> x, y;

double calc(double px, double py, int n){
    double maxdist2 = 0.0;
    for(int i = 0; i < n; i++){
        double dist2 = (px-x[i])*(px-x[i]) + (py-y[i])*(py-y[i]);
        maxdist2 = max(maxdist2, dist2);
    }
    return maxdist2;
}

double ternery_search(double x, int n){
    double l = -1.0;
    double r = 1001.0;

    while(abs(l-r)>1e-8){
        double midl = l+(r-l)/3.0;
        double midr = l+(r-l)*2.0/3.0;
        if(calc(x, midl, n) < calc(x, midr, n)){
            r = midr;
        }else{
            l = midl;
        }
    }
    return calc(x, l, n);
}

double ternery_search2(int n){
    double l = -1.0;
    double r = 1001.0;

    while(abs(l-r)>1e-8){
        double midl = (2.0*l+r)/3.0;
        double midr = (l+2.0*r)/3.0;
        if(ternery_search(midl, n) < ternery_search(midr, n)){
            r = midr;
        }else{
            l = midl;
        }
    }
    return sqrt(ternery_search(l, n));
}

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

    x.resize(n); y.resize(n);
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
    }
    double mindist = ternery_search2(n);



    printf("%.10f\n",mindist);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
#include<bitset>

using namespace std;



int main(){
  string s; cin>>s;
  string date[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};

  for(int i=0;i<7;i++){
    if(date[i]==s){
      cout<<7-i<<endl;
    }
  }

}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    String t=sc.next();
    Map<Character,Character> mp=new HashMap<>();
    for(int i=0;i<s.length();i++){
      if(mp.containsKey(s.charAt(i))){
        if(mp.get(s.charAt(i))!=t.charAt(i)){
          System.out.println("No");
          return;
        }
      }else{
        mp.put(s.charAt(i),t.charAt(i));
      }
    }
    Set<Character> st=new HashSet<>();
    int cnt=0;
    for(Map.Entry<Character,Character> me:mp.entrySet()){
      st.add(me.getValue());
      cnt++;
    }
    if(st.size()<cnt){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
}

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

int main()
{
    int a,b,c,i,n,sum=0;
    cin>>a>>b;
    cin>>c;
    int k = c;
    for(i = 1;i <a;i++){
        cin>>n;
        if(n>=c+b){
            sum = sum+b;
            c = n;
        }
        if(n < c+b){
            sum = sum+(n-c);
            c = n;
        }
    }
    sum = sum+b;
    sum = sum-k;
    cout<<sum;
}


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

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int N = sc.nextInt();
		int[] ary = new int[N];
		for (int i = 0; i < N; i++) {
			ary[i] = sc.nextInt();
		}
		double sum = 0;
		for (int i = 0; i < N; i++) {
			sum += (double) 1 / ary[i];
		}
		System.out.println(1 / sum);

	}

}

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

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

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

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

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

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

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

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

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

Measured memory_bytes: 21204
n = int(input())
P = []
for _ in range(n):
  x, y, h = map(int, input().split())
  P.append([h, x, y])
P.sort(reverse=True)

for cx in range(101):
  for cy in range(101):
    H = P[0][0] + abs(P[0][1]-cx) + abs(P[0][2]-cy)
    for i in range(1,n):
      if max(H-abs(P[i][1]-cx)-abs(P[i][2]-cy), 0) != P[i][0]:
        break
    else:
      print(cx, cy, H)
      exit()

Measured memory_bytes: 9024
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	if s == "1" {
		fmt.Println("0")
	} else if s =="0" {
		fmt.Println("1")
	}
}


Measured memory_bytes: 1772
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,x,n) for(int i=(x);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
using namespace std;
int main(){
	int ans=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='1'){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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


class Prog
{
	static void Main()
	{
		var adjL = new List<List<int>>();
		var n = int.Parse(Console.ReadLine());
		for(int i =0;i<n;i++)
		{
			adjL.Add(Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList());

		}
		foreach(var adj in adjL)
		{
			if(adj[1] == 0)
			{
				for(var i = 0;i<n;i++)
				{
					if(i!=0)Console.Write(" ");					
					Console.Write("0");
				}
				if(adj[0] != n)Console.WriteLine("");
			}
			else
			{
				int c = 1;
				for(var i = 1;i<=n;i++)
				{
					if(i!=1)Console.Write(" ");					
					if(adj[c+1]==i){Console.Write("1");if(c!=adj[1])c++;}
					else Console.Write("0");
				}
				Console.WriteLine("");
			}
		}

	}
}

Measured memory_bytes: 5764
#include<stdio.h>

int abs(int a){
  return a > 0 ? a : -a;
}

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

Measured memory_bytes: 1536
inf=998244353


N,K=map(int,input().split())
SS=[list(map(int,input().split())) for i in range(K)]

SS.sort()

table = [0 for k in range(N)] 
diff = [0 for k in range(N-1)]

table[0]=1
diff[0]=-1

for i in range(N-1):
    if table[i]!=0:
        for s in SS:
            lef=s[0]
            rig=s[1]
            if i+lef-1<N-1:
                diff[i+lef-1]+=table[i]
            if i+rig<N-1:
                diff[i+rig]-=table[i]
    table[i+1]=table[i]+diff[i]
    table[i+1]%=inf

print(table[N-1])

Measured memory_bytes: 25180
A,B,C,D,E,F=map(int,input().split())
satoumizu=100*A
satou=0
for a in range(31):
  for b in range(16):
    for c in range(F-100*A*a-100*B*b):
      for d in range(F-100*A*a-100*B*b-C*c):
        if a==0 and b==0 and c==0 and d==0:
          continue
        if E*(A*a+B*b)>=C*c+D*d and 100*(A*a+B*b)+C*c+D*d<=F:
          if (C*c+D*d)/(100*(A*a+B*b)+C*c+D*d)>satou/satoumizu:
            satoumizu=100*(A*a+B*b)+C*c+D*d
            satou=C*c+D*d
print(satoumizu,satou)

Measured memory_bytes: 44396
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  vector<int> A(3);
  for (int i=0; i<3; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  if (A.at(0)==5 && A.at(1)==5 && A.at(2)==7) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = 25;
int a[maxn],b[maxn],c[maxn];
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	for(int i = 1;i <= n; ++i)
	{
		scanf("%d",&a[i]);
	}
	int sum = 0;
	for(int i = 1;i <= n; ++i)
	{
		scanf("%d",&b[i]);
		sum += b[i];
	}
	for(int i = 1;i <= n - 1; ++i)
	{
		scanf("%d",&c[i]);
	}
	for(int i = 1;i <= n - 1; ++i)
	{
		if(a[i] + 1 == a[i + 1])
		{
			sum += c[a[i]];
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e14
#define dd double
#define MOD 1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl cout<<endl
#define fill(a,val) memset(a,val,sizeof(a))
#define mp make_pair
#define endl "\n"
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
ll power(ll x, ll y){ll res=1;x=x%MOD;while(y>0){if(y&1)res = (res*x)%MOD;y = y>>1;x = (x*x)%MOD;}return res%MOD;}  
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
void ceilsearch(ll ar[],ll low,ll high,ll x,ll &y){if(low>high)return;ll mid=(low+high)/2;if(ar[mid]>=x){y=mid;ceilsearch(ar,low,mid-1,x,y);}else{ceilsearch(ar,mid+1,high,x,y);}}
signed main()
{
    fastio();   
    ll N;
    cin>>N;
    string s;
    cin>>s;
    ll ar[3][N];
    for(ll i=0;i<N;i++)
    {
        ar[0][i]=0;
        ar[1][i]=0;
        ar[2][i]=0;
    }
    map<char,ll> m;
    m['R']=0;
    m['G']=1;
    m['B']=2;
    for(ll i=0;i<N;i++)
    {
        ar[m[s[i]]][i]=1;
    }
    ll dp[3][N];
    for(ll i=0;i<N;i++)
    {
        dp[0][i]=0;
        dp[1][i]=0;
        dp[2][i]=0;
    }
    dp[0][N-1]=ar[0][N-1];
    dp[1][N-1]=ar[1][N-1];
    dp[2][N-1]=ar[2][N-1];
    for(ll i=N-2;i>=0;i--)
    {
        for(ll j=0;j<3;j++)
            dp[j][i]=ar[j][i]+dp[j][i+1];
    }
    ll ans=0;
    for(ll i=0;i<N;i++)
    {
        ll p=m[s[i]];
        for(ll j=i+1;j<N-1;j++)
        {
            if(p!=m[s[j]])
            {
                ans+=dp[3-p-m[s[j]]][j+1];
                if(2*j-i<N)
                    ans-=ar[3-p-m[s[j]]][j+(j-i)];
            }
        }
    }
    cout<<ans<<endl;
}   

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

using namespace std;

#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define dump(x) cerr << "~ " << #x << " = " << x << endl

#define N 300005

long long rowCnt,colCnt,row[N],col[N],tot,a,b,ans;
pair<int,int> ar[N];

int main() {

	fast_cin;
	
    int n,m,k,x,y;

    cin >> n >> m >> k;

    for(int i = 1; i <= k; i++) {
        cin >> x >> y;
        row[x]++; col[y]++;

        ar[i] = make_pair(x,y);
    }

    a = b = -1;

    for(int i = 1; i <= n; i++) {
        if(a < row[i]) {
            a = row[i];
        }
    }

    for(int i = 1; i <= m; i++) {
        if(b < col[i]) {
            b = col[i];
        }
    }

    
	
    for(int i = 1; i <= n; i++) {
        if(row[i] == a) {
            rowCnt++;
        }
    }

    for(int i = 1; i <= m; i++) {
        if(col[i] == b) {
            colCnt++;
        }
    }

    tot = rowCnt * colCnt;

    for(int i = 1; i <= k; i++) {
        x = ar[i].first, y = ar[i].second;

        if(row[x] == a and col[y] == b) {
            tot--;
        }
    }

    ans = a+b;
    if(tot == 0) ans--;
	
    cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 10656
#include <cmath>
#include <vector>
#include <stdio.h>
#include <iostream>
using namespace std;


//-----------------------------------------
class DataUnit{
    public: int our_favorite[30] = {0};
};


double judge(DataUnit d, int n, int m){

    int ans = 0;

    for(int i=0; i<=m; i++){
        if(d.our_favorite[i]==n){
            ans++;
        };
    };
    return ans;
}


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

    DataUnit data;
    for(int i=0; i<N; i++){
        int K; cin >> K;
        for(int k=0; k<K; k++){
            int a; cin >> a; --a;
            data.our_favorite[a]++;
        };
    };
    out = judge(data, N, M);
    cout << out << endl;

    return 0;
}


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

const int inf=1e9;
struct data {
  int r,a,w,t;
};
bool asc(const data &l,const data &r) {
  return l.t+l.r>r.t+r.r;
}

int n;
vector<data> v;
int dp[2005][4005][2]={0};//dp[i][j][k][l]:i個目まで歌って容量がjでkのboolは歌ってるかどうか
//これだとそこのスタートのそれがそうなので無理
void chmax(int &a,int b){
  a=max(a,b);
}

int solve() {
  sort(v.begin(),v.end(),asc);
  int ans=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<=4000;j++)
      dp[i][j][1]=-inf;
  for(int i=0;i<n;i++){
    int t=v[i].t,r=v[i].r,a=v[i].a,w=v[i].w;
    for(int j=4000;j-r>0;j--){
      chmax(dp[i][min(t,j-r)][1],dp[i][j][0]+a);
      if(dp[i][j][1]!=-inf)chmax(dp[i][min(t,j-r)][1],dp[i][j][1]+w);
    }
    for(int j=4000;j>0;j--)dp[i+1][j][0]=max(dp[i][j][0],dp[i][j][1]);
  }
  for(int i=0;i<n;i++)
    for(int j=1;j<=4000;j++){
      chmax(ans,dp[i][j][0]);
      chmax(ans,dp[i][j][1]);
    }
  return ans;
}

int main() {
  cin>>n;
  v.resize(n);
  for(int i=0;i<n;++i)
    cin>>v[i].r>>v[i].a>>v[i].w>>v[i].t;
  cout<<solve()<<endl;
  return 0;
}



Measured memory_bytes: 65792
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int L = scan.nextInt();

		BigDecimal a = new BigDecimal(String.valueOf(L));
		BigDecimal div = new BigDecimal("3.0");
		a = a.divide(div, 7, RoundingMode.DOWN);
		
		BigDecimal length = new BigDecimal(String.valueOf(a));
		BigDecimal ans = length.multiply(length);
		ans = ans.multiply(length);
		
		System.out.print(ans);
	}

}


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

int main() {
    int n, minv, minv2 = 2000000000;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    sort(a.begin(), a.end());

    minv = a[0];
    vector<int> ans(n);
    while (1)
    {
        for (int i = 0; i < n; i++)
        {
            if (a[i] % minv == 0)
            {
                ans[i] = minv;
            }
            else
            {
                ans[i] = a[i] % minv;
            }
            minv = min(minv, ans[i]);
        }

        
        if (minv == minv2)
        {
            break;
        }
        minv2 = min(minv, minv2);
    }
    
    cout << minv << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    int n;
    cin >> n;
    vector<ll> t(n);
    for(int i=0; i<n; i++) cin >> t[i];
    
    int m;
    cin >> m;
    vector<ll> p(m);
    vector<ll> x(m);
    for(int i=0; i<m; i++) cin >> p[i] >> x[i];

    ll total = 0;
    ll ans = 0;
    for(int i=0; i<n; i++) total += t[i];
    
    for(int i=0; i<m; i++) {
        ans = total - t[p[i]-1] + x[i];
        cout << ans << endl;
        //cout << endl << i << " " << p[i] << " " << t[p[i]] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>


using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int A,B;
  cin >> A >> B;
  for(int i = 1;i <= 100000;i++){
    double a = i*0.08;
    double b = i*0.1;
    if(int(a)==A && int(b)==B){
      cout << i << endl;
      break;
    }
    if(i == 100000)cout << -1 << endl; 
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
using ull = unsigned long long;

// 2 で割り切れる回数を返す
int f(int x) {
 int res = 0;
 while (x % 2 == 0) {
   x /= 2;
   res++;
 }
 return res;
}


int main() {

 int N, M;
 cin >> N >> M;

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

 // 入力を 2 で割る
 for (int i = 0; i < N; i++) {
   if (a[i] % 2 == 1) {
     cout << 0 << endl;
     return 0;
   }
   a[i] /= 2;
 }

 // 2 で割り切れる回数が a[0] から a[N - 1] まで、全部同じじゃないとダメ
 // 同じ場合は、2^t で割る
 int t = f(a[0]);
 for (int i = 0; i < N; i++) {
   if (f(a[i]) != t) {
     cout << 0 << endl;
     return 0;
   }
   // a[i] /= 2^t
   a[i] >>= t;
 }

 // M /= 2^t
 M >>= t;

 // 2^t で割った a[0] から a[N - 1] までの lcm を求める。
 // lcm が M を超えるとダメ
 long long lcm_ = 1;
 for (int i = 0; i < N; i++) {
   lcm_ =  boost::math::lcm((ull)lcm_, (ull)a[i]);
   if (M < lcm_) {
     cout << 0 << endl;
     return 0;
   }
 }

 // 2^t で割った M = lcm * answer を満たす必要があり、
 // answer は奇数じゃないとダメなので、奇数の個数が答えになる
 M /= lcm_;
 int answer = (M + 1) / 2;
 
 cout << answer << endl;
 
 return 0;

}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	cout << min(a,b) << " " << max(0,a+b-n) << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	bool ok = true;
	int N; cin >> N;
	vector<int> a(N);
	rep(i,N) cin >> a[i];

	sort(all(a));
	int small = a[0];
	int large = a[N-1];
	if (small != large) {
		if (small+1 != large) ok = false;
		int r = 0;
		int s = 0;
		rep(i,N) {
			if (a[i] == small) r++;
			else s++;
		}
		if (small < r || s < (small-r+1)*2) ok = false;
	} else {
		if (N != small+1 && N < 2*small) ok = false;
	}

	cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <utility>
#include <queue>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio {
  int it, len;
  char s[LEN + 5];
  fastio() {
    it = len = 0;
  }
  char get() {
    if(it < len) return s[it++];
    it = 0, len = fread(s, 1, LEN, stdin);
    return len ? s[it++] : EOF;
  }
  bool notend() {
    char c;
    for (c = get();c == ' ' || c == '\n' || c == '\r';c = get());
    if (it) it--;
    return c != EOF;
  }
  void put(char c) {
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush() {
    fwrite(s, 1, it, stdout);
  }
}buff, bufo;
inline int getint() {
  char c; int res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if(c == '-') sig = -1;
  for (;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll() {
  char c; ll res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if (c == '-') sig = -1;
  for (; c >= '0' && c <= '9'; c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char() {
  char c;
  for (c = buff.get(); c == ' ' || c == '\n' || c == '\r'; c = buff.get());
  return c;
}

int main() {
  int k = getint(), a = getint(), b = getint();
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      puts("OK");
      return 0;
    }
  }
  puts("NG");
  return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define sz(v) (v).size()
// #define int long long
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
bool desc_sort(const int & lhs,const int & rhs)
{
    return lhs>rhs;
}
bool desc_pii_sort(const pii & lhs , const pii & rhs)
{
    return lhs>rhs;
}
bool second_sort(const pii & lhs , const pii & rhs)
{
    pii a,b;
    a.F = lhs.S;
    a.S = lhs.F;
    b.F = rhs.S;
    b.S = rhs.F;
    return a<b;
}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
#else
    #define trace(...)
#endif


// #define int long long
#define modd 1000000007



inline ll fast_expo(ll base,ll power,ll modulo=modd){
    base%=modulo;
    if (base<0LL) base+=modulo;
    ll x=base,cnt=power,ans=1LL;
    while(cnt){
        if (cnt&1LL) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1LL;
    }
    // int tmp=ans;
    return ans;
}
inline ll inv(ll base,ll modulo=modd){
    return fast_expo(base,modulo-2LL,modulo);
}



signed main()
{
    #ifdef _SUBLIME
    ifstream cin("input.txt");
    ofstream cout("output.txt");
    #endif
    fio;
    ll n;
    cin>>n;
    if(n==1)
    {
        d1(0);
    }
    else
    {
        ll a = fast_expo(10,n);
        ll b = fast_expo(9,n);
        ll c = fast_expo(8,n);
        a = (a - b)%modd;
        a = (a-b)%modd;
        a = (a+c)%modd;
        a = (a+modd)%modd;
        d1(a);
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n,maxim=0,count;
	cin >> n;
	int a[2][n];
	for(int i=0;i<2;i++){
		for(int k=0;k<n;k++){
			cin >> a[i][k];
		}
	}
	for(int i=0;i<n;i++){
		count = 0;
		for(int k=0;k<=i;k++){
			count = count + a[0][k];
		}
		for(int p=i;p<n;p++){
			count = count + a[1][p];
		}
		maxim = max(maxim,count);
	}
		cout << maxim << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define H_MAX 105
#define W_MAX 10
typedef long long ll;

using namespace std;

ll dp[H_MAX][W_MAX];
const int mod = 1000000007;

int main() {
    int H, W, K;

    cin >> H >> W >> K;

    for (int i = 1; i < W; i++) {
        dp[0][i] = 0;
    }
    dp[0][0] = 1;

    for (int i = 1; i <= H; i++) {
        for (int j = 0; j < W; j++) {
            int x, y, z;
            x = 0, y = 0, z = 0;

            for (int k = 0; k < 1 << (W - 1); k++) {
                bool flag = true;
                for (int l = 0; l < W - 2; l++) {
                    if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
                        flag = false;
                    }
                }
                if (flag) {
                    if (j >= 1 && (k >> (j - 1)) & 1) {
                        y++;
                    } else if (j <= W - 2 && (k >> j) & 1) {
                        z++;
                    } else {
                        x++;
                    }
                }
            }
            dp[i][j] = (dp[i - 1][j] * x) % mod;
            if (j >= 1) dp[i][j] += (dp[i - 1][j - 1] * y) % mod;
            if (j <= W - 2) dp[i][j] += (dp[i - 1][j + 1] * z) % mod;
        }
    }

    cout << dp[H][K - 1] % mod << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<string>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<chrono>
//#include<time.h>
//#include<windows.h>
using namespace std;
 
//#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")
struct edge {int /*from,*/to,cost;};


signed main(){
    string a,b,c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;

    return 0;
}


Measured memory_bytes: 256