akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 086 B "1 21"
 *   https://abc086.contest.atcoder.jp/tasks/abc086_b/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		String a = in.next();
		String b = in.next();

		int join = Integer.parseInt(a + b);
		double sqrt = Math.sqrt(join);
		int sqrtIng = (int) sqrt;

		if (sqrt - sqrtIng > 0.0) {
			out.println("No");
		} else {
			out.println("Yes");
		}

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, String split) {
			String[][] ret = new String[h][];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


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

int main()
{
    double x, y;
    while (scanf("%lf %lf", &x, &y) != EOF) {
        if (x < 35.50 && y < 71) printf("AAA\n");
        else if (x < 37.50 && y < 77) printf("AA\n");
        else if (x < 40 && y < 83) printf("A\n");
        else if (x < 43 && y < 89) printf("B\n");
        else if (x < 50 && y < 105) printf("C\n");
        else if (x < 55 && y < 116) printf("D\n");
        else if (x < 70 && y < 148) printf("E\n");
        else printf("NA\n");
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n;cin>>n;
    if(n<=999) cout<<"ABC"<<endl;
    else cout<<"ABD"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repv(i,a,b) for(ll i=b-1;i>=a;i--)
#define MAXN 100005
#define endl "\n"

ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;}

double w,h,x,y;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>w>>h>>x>>y;
    double p=(w*h)/2.0;
    cout<<p<<" ";
    if(x==w/2 && y==h/2) cout<<1<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
N=int(input())
S=input()
if N%2!=0:
  print('No')
else:
  count=0
  for i in range(N//2):
    if S[i]==S[i+(N//2)]:
      count = count
    else:
      count = count+1
    
  if count==0:
    print('Yes')
  else:
    print('No')



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S;
    cin >> S;
    
    int l = S.size(), w = 0;
    
    for(int i=0;i<l;i++){
        if(S[i] == 'o')
            w++;
    }
    
    if((15-l) + w >= 8){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <queue>

#define ll long long

using namespace std;

ll
getBottom(vector<ll> & end, int start, int tail) {
  ll bottom = INT_MAX;
  int n = end.size() / 2;
  int left = start, right = tail;
  left += n, right += n;
  while (1) {
    if (left > right) break;

    if (right % 2 == 0) {
      bottom = min(bottom, end[right]);
      right--;
    }
    if (left % 2 == 1) {
      bottom = min(bottom, end[left]);
      left++;
    }

    right /= 2;
    left /= 2;
  }

  return bottom;
}

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

  int n;
  cin>>n;

  ll left, right;
  vector<pair<ll, ll>> data;
  for (int i=0; i<n; i++) {
    cin>>left>>right;
    data.push_back({left, right});
  }
  sort(data.begin(), data.end());

  vector<ll> end(n);
  for (auto p : data) end.push_back(p.second);
  for (int i=n-1; i>=0; i--) end[i] = min(end[i*2], end[i*2+1]);

  ll ans = 0;
  for (int i=0; i<n-1; i++) {
    ll current = 0;
    current += max((ll)0, getBottom(end, 0, i) - data[i].first + 1);
    current += max((ll)0, getBottom(end, i+1, n-1) - data[n-1].first + 1);
    ans = max(current, ans);
  }

  for (int i=1; i<n-1; i++) {
    ll current = 0;
    current += data[i].second - data[i].first + 1;
    current += max((ll)0, min(getBottom(end, 0, i-1), getBottom(end, i+1, n-1)) - data[n-1].first + 1);
    ans = max(current, ans);
  }

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



Measured memory_bytes: 4208
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), t;
		if(a > b) { t = a; a = b; b = t; }
		if(a > c) { t = a; a = c; c = t; }
		if(b > c) { t = b; b = c; c = t; }
		System.out.println(a + " " + b + " " + c);
	}
}

Measured memory_bytes: 26016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, a, b, c;
  cin >> n >> a >> b >> c;
  vll l(n);
  for (ll i = 0; i < n; i++) cin >> l[i];

  vll v(n, 0);
  ll ans = inf;
  for (ll i = 0; i < pow(4, n); i++) {
    ll subans = 0;
    vll cnt(4, 0), abc(4, 0);
    for (ll j = 0; j < n; j++) {
      cnt[v[j]]++;
      abc[v[j]] += l[j];
    }
    if (abc[1] > 0 && abc[2] > 0 && abc[3] > 0) {
      subans += abs(a - abc[1]);
      subans += abs(b - abc[2]);
      subans += abs(c - abc[3]);
      for (ll j = 1; j <= 3; j++) {
        subans += 10 * (cnt[j] - 1);
      }
      ans = min(ans, subans);
    }

    if (i == pow(4, n) - 1) break;
    ll x = n - 1;
    while (v[x] == 3) {
      v[x] = 0;
      x--;
    }
    v[x]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
import time
import re
import math
import fractions

def main():
    global N,A,B,C,D,memo,mx,mn,temp
    N=int(input())
    P=list(map(int,input().split()))
    count=0
    for a in range(1,N-1):
        lst=[P[a-1],P[a],P[a+1]]
        lst.sort()
        if lst[2]==lst[1]:
            if lst[0]==P[a]:
                count+=1
        elif lst[0]==lst[1]:
            if not lst[2]==P[a]:
                count+=1
        else:
            if lst[1]==P[a]:
                count+=1
    print(count)


start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global N,A,B,C,D,memo,mx,mn,temp



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

long long n;
vector<long long> a;
map<long long, long long> mp;

long long solve();

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

long long solve() {
  mp[0] = 1;
  long long res = 0, now = 0;
  for (int i = 0; i < n; ++i) {
    now += a[i];
    res += mp[now];
    ++mp[now];
  }
  return res;
}


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

int main() {
    int a,b,c,d; cin >> a >> b >> c >> d;
    cout << (b<=c || d<=a ? 0 : (a<=c && b<=d ? b-c : (c<=a && d<=b ? d-a :(a<c&&d<b ? d-c : b-a)))) << endl;
}

Measured memory_bytes: 256
class Kruskal_UnionFind():
    # 無向グラフであるという前提に注意
    def __init__(self, N):
        self.edges = []
        self.rank = [0] * N
        self.par = [i for i in range(N)]
        self.counter = [1] * N

    def add(self, u, v, d):
        """
        :param u: 始点
        :param v: 終点
        :param d: コスト
        """
        self.edges.append([u, v, d])

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            z = self.counter[x] + self.counter[y]
            self.counter[x], self.counter[y] = z, z
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def size(self, x):
        x = self.find(x)
        return self.counter[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def Kruskal(self):
        """
        :return: 最小全域木のコストの和
        """
        edges = sorted(self.edges, key=lambda x: x[2])  # costでself.edgesをソートする
        res = 0
        for e in edges:
            if not self.same(e[0], e[1]):
                self.unite(e[0], e[1])
                res += e[2]
        return res

V, E = map(int, input().split())
graph = Kruskal_UnionFind(V)
for i in range(E):
    s, t, w = map(int, input().split())
    graph.add(s, t, w)

print(graph.Kruskal())



Measured memory_bytes: 27168
#include <iostream>
#include<string>
#include<cstring>

using namespace std;

int main()
{
    string s,t;
    cin >> s >> t;
    string temp= t.substr(0,t.size()-1);
    if(s==temp){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3124
#include<stdio.h>

int main(void)
{
  int S, h, m, s;

  scanf("%d", &S);
  h = S / (60*60);
  m = (S % (60*60)) / 60;
  s = (S % (60*60)) % 60;

  printf("%d:%d:%d\n", h, m, s);
  return 0;
}



Measured memory_bytes: 2104
#include <stdio.h>
#include <math.h>
int main(void) {
	int A, B;
	scanf("%d%d", &A, &B);
	if ((A + B) % 2 == 0) {
		printf("%d", (A + B) / 2);
	}
	else {
		printf("IMPOSSIBLE");
	}


	return 0;

}

Measured memory_bytes: 128
use proconio::input;

fn main() {
  input! {
    mut a: isize,
    mut b: isize,
    mut k: isize,
  }
  let ka = a.min(k);
  a -= ka;
  k -= ka;
  let kb = b.min(k);
  b -= kb;
  k -= kb;
  println!("{} {}", a, b);
}


Measured memory_bytes: 2128
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

S = input().rstrip()
K = int(input())

S_rank = [ord(x)-ord('a') for x in S]

after = []

rest = K
for i,x in enumerate(S_rank[:-1]):
    n = (-x)%26
    if n > rest:
        n = 0
    x += n
    x %= 26
    rest -= n
    after.append(chr(x+ord('a')))
after.append(chr(ord('a')+(S_rank[-1]+rest)%26))

answer = ''.join(after)
print(answer)

Measured memory_bytes: 5748
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=4005;
int n,m,t,p,ans;
int d[N],first[N],v[N],w[N],_next[N];
struct Node{
    int u,v;
}e[N];
void add(int x,int y)
{
	t++;
	_next[t]=first[x];
	first[x]=t;
	v[t]=y;
}
void dfs(int x,int father)
{
	int i,j;
	for(i=first[x];i;i=_next[i])
	{
		j=v[i];
		if(j==father)
		  continue;
		d[j]=d[x]+1;
		dfs(j,x);
	}
}
int main()
{
	int x,y,z,i,k,u;
	scanf("%d%d",&n,&k);
	m=k/2;
	ans=0x3f3f3f3f;
	for(i=2;i<=n;++i)
	{
		scanf("%d%d",&x,&y);
		e[i].u=x;
		e[i].v=y;
		add(x,y);
		add(y,x);
	}
	if ((k&1)==0){
		int res=0;
		for (int i=1;i<=n;i++){
			res = d[i] = 0;
			dfs(i,i);
            for (int j=1;j<=n;j++) if(d[j]>m) ++res;
            ans = min(ans,res);
		}
	}
	else{
		int res = 0;
       	for (int i=2;i<=n;i++){
            d[e[i].u] = d[e[i].v] = res = 0;
            dfs(e[i].u,e[i].v);
			dfs(e[i].v,e[i].u);
            for (int j=1;j<=n;j++) if(d[j]>m) ++res;
            ans = min(ans,res);
        }
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(void) {
  int n;
  cin >> n;
  vector<int> as(n);
  for (int &a : as) cin >> a;
  sort(as.begin(), as.end());
  reverse(as.begin(), as.end());

  int sign = 1;
  int result = 0;
  for (const int &a : as) {
    result += sign * a;
    sign = sign == 1 ? -1 : 1;
  }

  cout << result << endl;
  return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            List<int> nums = new List<int>();
            for(int i = 0; i < input.Length; i++)
            {
                nums.Add(int.Parse(input[i]));
            }
            nums.Sort();
            Console.WriteLine(nums[0] + " " + nums[1] + " " + nums[2]);

           
        }
    }
}



Measured memory_bytes: 16000
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
G = []

class Edge:
    def __init__(self, to, id):
        self.to = to
        self.id = id

ans = []

def dfs(v, fr, c):
    k = 1
    for g in G[v]:
        to = g.to
        id = g.id
        if to != fr:
            if k == c:
                k += 1
            ans[id] = k
            k += 1
            dfs(to, v, ans[id])
    

def main():
    global G, ans
    n = int(input().strip())
    ans = [0] * (n-1)
    G = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = list(map(int, input().strip().split()))
        G[a-1].append(Edge(b-1, i))
        G[b-1].append(Edge(a-1, i))
    dfs(0, -1, -1)

    print(len(set(ans)))
    for v in ans:
        print(v)

if __name__ == '__main__':
    main()


Measured memory_bytes: 100892
import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    public static void main (String[] args) throws IOException
    {
    	Scanner sc = new Scanner(System.in);
     	int N = sc.nextInt();
     	int K = sc.nextInt();
     	int ans;
     	String D[] = new String [K];
     	
     	for (int i = 0 ; i <= K-1 ; i++){
     		D[i] = sc.next();
     	}
     	
     	ans = N;
     	
     	for (int i = 0 ; (Dis(D,N+i,K)) ; i++){
     		ans += 1;
     		
     	}
    	
     	System.out.println(ans);
    }
    
    static boolean Dis (String D[] , int x , int k){
    	String X = String.valueOf(x);
    	
    	for (int i = 0 ; i <= k-1 ; i++){
    		if (X.contains(D[i])){
    			return true;
    		}
    	}
    	
    	return false;
    }
}
   

Measured memory_bytes: 14412
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
visited = [0]*(n+1)
pos = 1
steps = 0
while visited[pos] == 0:
	visited[pos] = steps
	steps += 1
	pos = a[pos]
#print(visited)
if k>=steps:
	k -= visited[pos]
	k %= (steps-visited[pos])
	#print(k)
	for i in range(1,n+1):
		if visited[i] == visited[pos]+k:
			print(i)
			break
else:
	for i in range(1,n+1):
		if visited[i] == k:
			print(i)

Measured memory_bytes: 32352
n, k, q = gets.chomp.split(' ').map(&:to_i)
ans = []
q.times do
  ans.push(gets.chomp.to_i)
end

scores = Array.new(n, k - q)
q.times do |i|
  correct_human = ans[i] - 1
  scores[correct_human] += 1
end

# p scores

scores.each do |v|
  if v > 0
    print 'Yes' + "\n"
  else
    print 'No' + "\n"
  end
end


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	cin >> k;
	int ans;
	if (k % 2 == 0) cout << (k / 2) * (k / 2) << endl;
	else cout << ((k - 1) / 2) * ((k + 1) / 2) << endl;
	return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k, z, N;
string s, t, d, c;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> s >> t;
	ll n = s.length();
	for(ll i=0;i<n;i++) {
		cout<<s[i];
		if(i < t.length()) cout<<t[i];
	}
	newl;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3596
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())

black = [[0] * w for _ in range(h)]

for j in range(w):
    for i in range(h):
        if i == 0 and j == 0:
            if s[i][j] == '#':
                black[i][j] = 1
            else:
                black[i][j] = 0

        if i > 0 and j == 0:
            if s[i][j] == '#':
                if s[i - 1][j] == '#':
                    black[i][j] = black[i - 1][j]
                else:
                    black[i][j] = black[i - 1][j] + 1
            else: # s[i][j] == '.'
                black[i][j] = black[i - 1][j]
                    
        if i == 0 and j > 0:
            if s[i][j] =='#':
                if s[i][j - 1] =='#':
                    black[i][j] = black[i][j - 1]
                else:
                    black[i][j] = black[i][j - 1] + 1
            else:
                    black[i][j] = black[i][j - 1]
                    
        if i > 0 and j > 0:
            if s[i][j] =='#':
                if s[i][j - 1] =='#' and s[i - 1][j] == '#':
                    black[i][j] = min(black[i][j - 1], black[i - 1][j])
                elif s[i][j - 1] =='#'and s[i - 1][j] == '.':
                    black[i][j] = min(black[i][j - 1], black[i - 1][j] + 1)
                elif s[i][j - 1] =='.'and s[i - 1][j] == '#':
                    black[i][j] = min(black[i][j - 1] + 1, black[i - 1][j])
                else:
                    black[i][j] = min(black[i][j - 1] + 1, black[i - 1][j] + 1)
            else:
                    black[i][j] = min(black[i][j - 1], black[i - 1][j])
                
print(black[h-1][w-1])

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


#define ull unsigned long long
#define testcases() int var;  cin>>var; while(var--)

int length(ull n)
{
    int cnt = 0;
    while(n)
    {
        cnt++;
        n>>=1;
    }
    return cnt;
}

void solve(long long N, std::vector<long long> A){
    long long tmp = 0;
    for(long long a:A)tmp ^= a;
    for(int i=0;i<N;++i){
        A[i] &= (1ll<<62) - 1 - tmp;
    }
    vector<long long> lengths(N);
    for(int i=0; i<N; i++)lengths[i] = length(A[i]);

    // put all numbers with same bit-length in one bucket --> buckets[]
    vector<ull> buckets[65];
    for(int i=0; i<N; i++)buckets[lengths[i]].push_back(A[i]);

    // this array will have a number from each bucket --> modified_array[]
    ull modified_array[100], m_index = 0;

    for(int i=64; i>0; i--) //since long long is 8 byte = 64 bit long
    {
        if(buckets[i].size()) //if there exist at least one element in bucket[i]
        {
            // put first value from bucket in modified_array[]
            modified_array[m_index++]=buckets[i][0];

            // and put remaining elements from same bucket again in corresponding 
            // buckets after ex-oring 
            for(int j=1; j<buckets[i].size(); j++)
            {
                ull temp = buckets[i][0] ^ buckets[i][j];
                int len = length(temp);
                buckets[len].push_back(temp);
            }
        }
    }

    // Step 4 according to the explained procedure
    // make ans = k for codechef and ans = 0 for spoj :)
    ull ans = 0;
    for(int i=0; i<m_index; i++) 
        if(ans < (ans ^ modified_array[i]))
            ans = (ans ^ modified_array[i]);

    // Step 5 according to the explained procedure
    cout<<tmp + ans * 2<<endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 27484
def main(): 
    s=list(input())

    if not len(s)%2 == 0:
        print('No')
        return

    for i in range(len(s)):
        if i%2 == 0:
            if not s[i] == "h":
                print('No')
                return
        else:
            if not s[i] == "i":
                print('No')
                return
    
    print('Yes')

main()

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

using namespace std;

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

#define X first
#define Y second

const int N=2e5+10;
const int MOD=1e9+7;
const int inf=1e9+10;
const int maxv=40;

int n,a[N];
int solve(){
    a[0]=-1;
    ll ans=1;
    ii cur=ii(0,0);
    for(int i=1;i<=n;){
        while (i<=n){
            a[i]=min(a[i],cur.X*2+1);
            if (a[i]<cur.X*2+1) break;
            else i++,cur.X++;
        }
        while (i<=n&&a[i]==a[i-1]+1) i++,cur.Y++;
        while (cur.Y){
            ans=ans*(cur.X+1)%MOD;
            if (cur.Y>=2) cur.X++;
            cur.Y=max(0,cur.Y-2);
        }
    }
    for(int i=1;i<=cur.X;i++) ans=ans*i%MOD;
    return ans;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    cout<<solve();
}


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

int main(){
    int N; cin >> N;
    int cur = -1, tar = 0, cnt = 0,ans = 0;
    for(int i=0;i<N;i++){
        cin >> tar;
        if(cur>=tar){
            cnt++;
            ans = max(ans,cnt);
        }else cnt=0;
        cur = tar;
    }
    cout << ans << endl;
}

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

vector<ll> enum_div(ll n) {
  vector<ll> ret;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      ret.push_back(i);
      if(i != 1 && i*i != n) {
        ret.push_back(n/i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

bool isprime(ll x) {
  ll i;
  if(x < 2) return 0;
  else if(x == 2) return 1;
  if(x%2 == 0) return 0;
  for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
  return 1;
}

int main() {
  ll n;
  cin >> n;
  if(isprime(n)) cout << n-1 << endl;
  else {
    vector<ll> vec = enum_div(n);
    vec.push_back(n);
    ll ans = LLONG_MAX;
    rep(i, vec.size()) {
      ll m = vec.at(i) + n/vec.at(i) - 2;
      ans = min(ans, m);
    }
    ans = min(ans, n-1);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 384
n,m=map(int, input().split())
ab=[list(map(int,input().split()))  for i in  range(m)]

ab=sorted(ab, key=lambda x:(x[0],x[1]), reverse=True)
#print(ab)
now=10**5+1

preb=-1
ans=0
for i in range(m):
  if ab[i][1]==preb:
    continue
  if ab[i][1]<=now:
    now=ab[i][0]
    preb=ab[i][1]
    ans+=1
    #print("now",now)
print(ans)


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

using namespace std;

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

int main(){
  int N; cin >> N;
  vector<int> a(N+1);
  a.at(0) = 0;
  rep(i, N) cin >> a.at(i+1);

  int num = a.at(1);
  if (num == 2) {
    cout << 1 << endl;
    return 0;
  }
  else {
    rep(i, N) {
      if (a.at(num) == 2) {
        cout << i+2 << endl;
        return 0;
      }
      num = a.at(num);
    }
    cout << -1 << endl;
  }
  return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


int N;
int A[100], B[100];

signed main(){
    cin >> N;
    REP(i, N - 1) cin >> B[i];
    A[0] = B[0];
    FOR(i, 1, N - 1) A[i] = min(B[i - 1], B[i]);
    A[N - 1] = B[N - 2];
    int ans = 0;
    REP(i, N) ans += A[i];
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


total = 0
N = int(input())
for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(1,N+1):
            total += gcd(i, j, k)

print(total)


Measured memory_bytes: 74908
main(){float f;for(;~scanf("%f",&f);)puts(f>91?"heavy":f>81?"light heavy":f>75?"middle":f>69?"light middle":f>64?"welter":f>60?"light welter":f>57?"light":f>54?"feather":f>51?"bantam":f>48?"fly":"light fly");return 0;}

Measured memory_bytes: 604
#include<iostream>
#include<cstdio>
using namespace std;
const int MAX_SIZE = 100001;
const int MOD = 1000000000+7;
int n,t[MAX_SIZE],a[MAX_SIZE],T[MAX_SIZE],A[MAX_SIZE];
long long sum = 1;
int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		scanf("%d",&t[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	T[0] = -1*t[0];
	A[n-1] = -1*a[n-1];
	for(int i = 1;i<n;i++){
		if(t[i] > t[i-1]){
			T[i] = t[i]*(-1);
		}
		else T[i] = t[i];
		if(a[n-1-i] > a[n-i]){
			A[n-1-i] = a[n-1-i]*(-1);
		}
		else A[n-1-i] = a[n-1-i]; 
	}
	
	for(int i=0;i<n;i++){
		cerr << T[i] << " ";
	}
	cerr << endl;
	for(int i=0;i<n;i++){
		cerr << A[i] << " ";
	}
	cerr << endl;
	
	for(int i=0;i<n;i++){
		if(A[i]>0 && T[i]>0){
			sum *= A[i]>T[i] ? T[i] : A[i];
		}
		else if ( A[i]>0 && T[i] < 0){
			if(A[i] < T[i]*(-1)) sum *= 0;
		}
		else if(A[i] < 0 && T[i] > 0){
			if(A[i]*(-1) > T[i]) sum *= 0;
		}
		else if(A[i] < 0 && T[i] < 0){
			if(A[i]!= T[i]) sum*=0;
		}
		sum %= MOD;
		cerr << sum << " ";
	}

	cerr << endl;
	cout << sum;
	return 0;
}

Measured memory_bytes: 1792
n,k=map(int,input().split())
inf=1000000007

def combi(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

for i in range(k):
    if n-k>=i:
        ans=combi(n-k+1, i+1) * combi(k-1, i)
    else:
        ans=0
    print(ans%inf)

Measured memory_bytes: 3316
def main(argv)
  (n, m) = gets.chomp.split(' ').map(&:to_i)
  
  a = [0] * (n + 1)
  m.times do |i|
    (l, r) = gets.chomp.split(' ').map(&:to_i)
    a[l - 1] += 1
    a[r] -= 1
  end
  
  s = 0
  c = 0
  n.times do |i|
    s += a[i]
    if s >= m then
      c += 1
    end
  end
  puts c.to_s
end

if self.to_s === 'main' then
  main(ARGV)
end

Measured memory_bytes: 2556
#include<iostream>
#define T 0
#define N 1
#define W 2
#define S 3
#define E 4 
#define B 5

using namespace std;

int dice[6] = {1,2,3,5,4,6};//T-0,N-1,W-2,S-3,E-4,B-5


void roll(string op){

  if(op == "north"){
    dice[B] = dice[N];
    dice[N] = dice[T];
    dice[T] = 7-dice[B];
    dice[S] = 7-dice[N];
  }
  else if(op == "south"){
    dice[S] = dice[T];
    dice[T] = dice[N];
    dice[N] = 7-dice[S];
    dice[B] = 7-dice[T];
  }
  else if(op == "east"){
    dice[E] = dice[T];
    dice[T] = dice[W];
    dice[W] = 7-dice[E];
    dice[B] = 7-dice[T];
  }
  else if(op == "west"){
    dice[W] = dice[T];
    dice[T] = dice[E];
    dice[E] = 7-dice[W];
    dice[B] = 7-dice[T];
  }
  else{
    cout << "what" << endl;
  }
  

}



int main(){
  int n;
  string op;
  while(cin >> n && n){
    dice[T] = 1; dice[N] = 2; dice[W] = 3; dice[S] = 5; dice[E] = 4;dice[B] = 6;
    for(int i=0;i<n;i++){
      cin >> op;
      roll(op);
    }
    cout << dice[T] << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
package main

import "fmt"

func main() {
  var K, S, count int
  fmt.Scan(&K, &S)
// 0 <= X, Y, Z <= K
  for X := 0; X <= K; X++ {
    for Y := 0; Y <= K; Y++ {
      Z := S - X - Y
      if X + Y + Z == S && Z >= 0 && K >= Z{
        count += 1
      }
    }
  }
  fmt.Println(count)
}

Measured memory_bytes: 512
// g++ A.cpp -Wall -Wextra -Woverflow -Wshadow -O2
#include <iostream>
#include <algorithm>
#include <utility>
#include <map>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <bitset>

using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;

const int MAXN = 1 << 17;
int n;
int a[MAXN];
vector<int> b;
LL BIT[4 * MAXN];

LL read(int idx) {
  LL sum = 0;
  while (idx > 0) {
    sum += BIT[idx];
    idx -= (idx & -idx);
  }
  return sum;
}

void update(int idx, LL val) {
  while (idx < 4 * MAXN) {
    BIT[idx] += val;
    idx += (idx & -idx);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b.push_back(a[i]);
  }
  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());
  int L = 0, R = b.size() - 1;
  while (L < R) {
    int mid = (L + R + 1) / 2;
    int x = b[mid];
    int pref = 0;
    LL cnt = 0;
    memset(BIT, 0LL, sizeof(BIT));
    update(MAXN, 1LL);
    for (int i = 0; i < n; i++) {
      int val = (a[i] >= x ? 1 : -1);
      pref += val;
      LL tot = read(MAXN + pref); 
      cnt += tot;
      update(MAXN + pref, 1LL);
    }
    if (cnt >= (LL)n * (LL)(n + 1LL) / 4LL) {
      L = mid;
    } else {
      R = mid - 1;
    }
  }
  cout << b[L] << endl;
} 

Measured memory_bytes: 8272
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <climits>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
using namespace std;
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define fi first
#define se second
#define ii pair<int, int>
#define ll long long
#define endl "\n"
long double pi = 3.14;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("Test.inp", "r", stdin);
	//freopen("Test.out", "w", stdout);
	int n;
	cin >> n;
	cout << pi * 2 * n;
	return 0;
}

Measured memory_bytes: 3756
N = int(input())
divisors = []
for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        divisors.append(i)
        if i != N // i:
            divisors.append(N//i)

divisors.sort()

n = len(divisors)
i = len(divisors) // 2

A, B = 0, 0
if n % 2 == 0:
    A, B = divisors[i - 1], divisors[i]
else:
    A, B = divisors[i], divisors[i]

print(A - 1 + B - 1)

Measured memory_bytes: 9352
H, W = map(int, input().split())
I = [input() for _ in range(H)]
X = [[[0, 1][a=="#"] for a in inp] for inp in I]
k = 21
def r():
    global H, W, I
    I = ["".join([I[H - 1 - j][i] for j in range(H)]) for i in range(W)]
    H, W = W, H
def st1(s):
    return int(s.replace("#", "1" * k).replace(".", "0" * k), 2)
def st2(s):
    return int(s.replace("#", "0" * (k - 1) + "1").replace(".", "0" * k), 2)
def getsum(x):
    for i in range(8):
        x += x >> (k << i)
    return x & ((1 << k) - 1)

ans = 0
for _ in range(4):
    A1 = [st1(inp) for inp in I]
    A2 = [st1("".join([I[i][j] for i in range(H)])) for j in range(W)]
    B = [st2(inp[::-1]) for i, inp in enumerate(I)]
    for j in range(W):
        s, t = 0, 0
        m = (1 << j * k) - 1
        for i in range(H)[::-1]:
            s = ((B[i] >> (j + 1) * k) + (s << k)) & m
            t += A1[i] >> (W - j) * k & A2[j] >> (H - i) * k & s
        ans += getsum(t)
    r()
print(ans)

Measured memory_bytes: 5108
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}


int main() {
	file();
	fast();
	string a, b; cin >> a >> b;
	b.pop_back();
	if (a == b)
		cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3664
W, H, N = map(int, input().split())

max_x = W
min_x = 0
max_y = H
min_y = 0

for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        min_x = max(min_x, x)
    elif a == 2:
        max_x = min(max_x, x)
    elif a == 3:
        min_y = max(min_y, y)
    else:
        max_y = min(max_y, y)

if max_x > min_x and max_y > min_y:
    print(max(0, (max_x - min_x) * (max_y - min_y)))
else:
    print(0)


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

using namespace std;

int main(){
	long long K;
	cin>>K;
	
	int N=50;
	long long s=(long long)(K/N);
	long long t=K%N;
    vector <long long>a;
    
	for(int i=0 ; i<N ; i++){
		a.push_back(N-1);
		a[i]+=s;
	}
	for(int i=0 ; i<t ; i++){
		a[i]+=N-t+1;
	}
	for(int i=t ; i<N ; i++){
		a[i]-=t;
	}
	
	cout<<N<<endl;
	for(int i=0 ; i<N ; i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
	

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


Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let s = sc.chars();
    let t = sc.chars();
    let mut ans = 0;
    for i in 0..3 {
        if s[i] == t[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#define LIM 1000000007

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> T(N),A(N);
	for (int i = 0; i < N; ++i) {
		cin >> T[i];
	}
	for (int i = 0; i < N; ++i) { 
		cin >> A[i];
	}

	int tmh,amh;
	vector<int> tc(N),ac(N);
	tmh = T[0];
	amh = A[N-1];
	tc[0] = ac[N-1] = 1;

	vector<bool> mt(N,false),ma(N,false);
	mt[0] = ma[N-1] = true;
	for (int i = 1; i < N; ++i) {
		if (tmh < T[i]) {
			tc[i] = 1;
			tmh = T[i];
			mt[i] = true;
		}
		else {
			tc[i] = tmh;
		}

		if (amh < A[N-i-1]) {
			ac[N-i-1] = 1;
			amh = A[N-i-1];
			ma[N-i-1] = true;
		}
		else {
			ac[N-i-1] = amh;
		}
	}

	bool wr = false;
	for (int i = 0; i < N; ++i) {
		if (mt[i]) {
			if (T[i] > A[i]) {
				wr = true;
			}
		}
		if (ma[i]) {
			if (A[i] > T[i]) {
				wr = true;
			}
		}
	}

	long long res = 1;
	if (wr) {
		res = 0;
	}
	else {
		for (int i = 0; i < N; ++i) {
			res *= min(tc[i],ac[i]);
			res = res%LIM;
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in), 1000000);
    StringTokenizer tok = new StringTokenizer("");
    StringBuilder out = new StringBuilder();

    String next() throws IOException {
        if (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

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

    int n = 0;
    int k = 0;

    void go(int a, int b, int mask, char removed) {
        if (removed == k - 1) {
            out.append(a + " " + b + " ");
        } else {
            int k1 = 0;
            for (int i = 0; i < k; i++) {
                if ((mask & (1 << i)) == 0 && ((a ^ b) & (1 << i)) > 0) {
                    mask |= (1 << i);
                    removed++;
                    k1 = i;
                    break;
                }
            }
            int a1 = 0;
            for (int j = 0; j < k; j++) {
                if ((mask & (1 << j)) == 0) {
                    a1 = a ^ (1 << j);
                    break;
                }
            }
            go(a, a1, mask, removed);
            go((a1 ^ (1 << k1)), b, mask, removed);
        }
    }

    void slave() throws IOException {
        k = nextInt();
        int A = nextInt();
        int B = nextInt();
        n = 1 << k;
        if (Integer.bitCount(A ^ B) % 2 == 0) {
            out.append("NO");
        } else {
            out.append("YES\n");
            go(A, B, 0, (char) 0);
        }
        System.out.print(out);
    }

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

Measured memory_bytes: 48716
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;

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

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) (x).begin(), (x).end()

void No(){
	printf("No\n"); exit(0);
}
void Yes(){
	printf("Yes\n"); exit(0);
}

int p[200500]; int N;
int main(){
	scanf("%d",&N);
	repp(i,N) scanf("%d",&p[i]);
	int mx = -1, mn = 1e9;
	repp(i,N){
		mx = max(mx, p[i]);
		mn = min(mn, p[i]);
	}

	if( mx - mn > 1 ) No();

	if( mx == mn ){
		if( mx == N-1 ) Yes();
		if( mx*2 <= N ) Yes();
		No();
	}

	int cnt = 0;
	repp(i,N) if( p[i] == mn ) cnt++;
	int C = N-cnt;

	if( mx-cnt != mn-(cnt-1) ) No();
	if( mx-cnt <= 0 && C ) No();
	if( (mx-cnt)*2 > C ) No();
	Yes();

}





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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9
#define MAX 1000

typedef long long ll;

int main(){
    int N;
    cin >> N;
    int h[N+1];
    h[0] = 0;
    int M = -1;
    Rep(i,N){
        cin >> h[i+1];
        M = max(M,h[i+1]);
    }
    int cnt = 0;
    int ans = 0;
    while(M > 0){
        cnt = 0;
    Rep(i,N+1){
        if(h[i] != 0){
            cnt++;
            while(h[i] != 0 && i < N+1){
                h[i]--;
                //cout << h[i] << sp;
                i++;
            }
        }
        //cout << h[i] << sp;
    }
    //cout << sp;
    //cout << M << sp << cnt << endl;
    M--;
    ans += cnt;
    }
    cout << ans << endl;
    //cin >> N;
}

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

#define io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pii pair<ll, ll>
#define piii pair<ll, pair<ll, ll>>
#define debug(x) cout<<#x<<" = "<<x<<endl

using namespace std;
const int N = 200005;
ll t, n, m, k, q, a, b, x, y, ans, arr[N];
ll mod = 998244353;
string s;
bool vis[N];

ll getPow(ll x) {
    return x * x * x * x * x;
}

int main() {
    io;
    t = 1;
//    cin >> t;
    while (t--) {
        cin >> x;
        bool found = false;
        for (b = -1000; b <= 1000 && !found; ++b) {
            for (a = -1000; a <= 1000 && !found; ++a) {
                if (getPow(a) == x + getPow(b)) {
                    cout << a << " " << b << endl;
                    found = true;
                }
            }
        }
    }
    return 0;
}
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long;

const int INF = 1e9;
const long long  LLINF = 1e15;

using namespace std;

int ind;
string S;

string dfs(){
  string ret = "";
  char c = S[ind];
  if(c == '['){
    ind++;
    string rev = dfs();
    ind++;
    reverse(rev.begin(), rev.end());
    ret += rev;
    ret += dfs();
  }else if(('A'<=S[ind] && S[ind]<='A'+26) || S[ind]=='?'){
    char ac;
    if(S[ind]=='?') ac = 'A';
    else ac = S[ind];
    ret += ac;
    ind++;
    ret += dfs();
  }else if(S[ind] == '+' || S[ind] == '-'){
    int cnt = 0;
    while(S[ind] == '+' || S[ind] == '-'){
      if(S[ind] == '+') cnt++;
      else cnt--;
      ind++;
    }
    if(S[ind]=='?') ret += 'A';
    else ret += 'A' + (S[ind]-'A'+cnt+2600)%26;
    ind++;
    ret += dfs();
  }
  return ret;
}

int main() {
  while(1){
    cin>>S;
    if(S==".") break;
    ind = 0;
    cout<<dfs()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3156
/// Coded by Dhiman Sarker Bappi (Dhimanda) - RMSTU

#include<bits/stdc++.h>
using namespace std;
#define    in_file     freopen("input.txt", "r", stdin)
#define    out_file    freopen("output.txt", "w", stdout)
#define    fast        ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define    F           first
#define    S           second
#define    pb          push_back
#define    popb        pop_back
#define    pf          push_front
#define    popf        pop_front
#define    lcm(a,b)    (a*b)/gcd(a,b)
#define    gcd(a,b)    __gcd(a,b)
#define    pi          2*acos(0)
#define    elif        else if
#define    ll          long long
#define    nl          '\n'
#define    endl        '\n'
#define    fori(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define    for0(i,n)   for(int (i)=0; (i) < (n); (i)++)
#define    sp          fixed << setprecision
#define    all(x)      x.begin(),x.end()

// ===================== DEBUG  ==========================

vector<string>vec_spltr(string s){s+=',';vector<string>res;while(!s.empty())
res.push_back(s.substr(0, s.find(','))),s=s.substr(s.find(',')+1);return res;}
void dbg_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,
__attribute__((unused))int LINE_NUM){cerr<<endl;}template<typename Head,typename... Tail>
void dbg_out ( vector <string> args, int idx, int LINE_NUM, Head H, Tail... T)
{if(idx>0)cerr<<", ";else cerr << "Line(" << LINE_NUM << ") ";stringstream ss;ss<<H;
cerr<<args[idx]<<" = "<<ss.str();dbg_out(args,idx+1,LINE_NUM, T...);}
#define debug(...) dbg_out(vec_spltr(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)

// ===================== custom function ==========================
ll pow_mod(ll nn, ll pp, ll mm) { ll res = 1; while(pp > 0) { if(pp&1) res = (res * nn) % mm; pp = pp >> 1; nn = (nn * nn) % mm; } return res; }
void dhimanda();
// ===================== Main function ==========================
int main()
{
    //in_file;
    //out_file;
    int t=1;
    //cin >> t;
    fori(i,1,t){
        //printf("Case %d: ", i);
        dhimanda();
    }
    //main();
    return 0;

}
void dhimanda(){
    ll n;
    cin >> n;
    string a="0abcdefghijklmnopqrstuvwxyz";
    string ans = "";
    while(n) {
        ll x = n%26;
        if(x==0) x = 26;
        ans += a[x];
        debug(x,ans,n);
        n /= 26;
        if(x==26) n--;
    }
    reverse(all(ans));
    cout<<ans<<endl;

}

// Contact : chessdhiman@gmail.com


Measured memory_bytes: 3636