akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

template <typename T>
map<T,int> frequencies(const vector<T>& v)
{
    map<T,int> m;
    for (int i = 0; i < v.size(); i++) {
        m[v[i]]++;
    }
    return m;
}

template<typename T>inline T get(){T x;cin>>x;return x;}
#define FN1(exp) [](auto _1){return exp;}
#define FN2(exp) [](auto _1,auto _2){return exp;}

int main()
{
    int n = get<int>();
    vector<int> a(n/2);
    vector<int> b(n/2);
    for (int i = 0; i < n/2; i++) {
        a[i] = get<int>();
        b[i] = get<int>();
    }

    auto bkt_a = frequencies(a);
    auto bkt_b = frequencies(b);
    vector<pair<int,int>> ra;
    vector<pair<int,int>> rb;
    for (auto p : bkt_a)
        ra.emplace_back(p.second,p.first); // freq,type
    sort(ra.begin(),ra.end(),greater<pair<int,int>>());
    for (auto p : bkt_b)
        rb.emplace_back(p.second,p.first);
    sort(rb.begin(),rb.end(),greater<pair<int,int>>());

    long ans = LONG_MAX;
    for (int i = 0; i < min(2, (int)ra.size()); i++)
        for (int j = 0; j < min(2, (int)rb.size()); j++)
            if (ra[i].second != rb[j].second)
                ans = min(ans, (long)n - ra[i].first - rb[j].first);

    if (ans == LONG_MAX)
        cout << n/2 << endl;
    else
        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6520
#![allow(non_snake_case, unused_mut)]
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::marker::Usize1;
//use std::collections::HashMap;
//use std::collections::HashSet;

#[fastout()]
fn main() {
    proconio::input! {
        N:usize, M:usize,K:usize,
        AB:[(Usize1,Usize1);M],
        CD:[(Usize1,Usize1);K]
    }
    let mut tree: UnionFind<usize> = UnionFind::new(N);
    let mut friends = vec![Vec::with_capacity(M); N];
    let mut blocks = vec![Vec::with_capacity(K); N];
    for &(a, b) in AB.iter() {
        tree.union(a, b);
        friends[a].push(b);
        friends[b].push(a);
    }
    for &(c, d) in CD.iter() {
        if tree.find(c) == tree.find(d) {
            blocks[c].push(d);
            blocks[d].push(c);
        }
    }
    let mut sizes = vec![0usize; N];
    for i in 0..N {
        sizes[tree.find(i)] += 1;
    }
    for i in 0..N {
        let ans = sizes[tree.find(i)] - 1 - friends[i].len() - blocks[i].len();
        print!("{} ", ans);
    }
}


Measured memory_bytes: 20576
# include<bits/stdc++.h>
using namespace std;
#define tmprep(i,n) for(int i=2;i<=(int)n;i++)
#define rep(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
unordered_map<ll,char> mp;

int main(){
  ll idx=0;
  for(int i=0;i<26;i++){
    mp[idx]=idx+'a';
    idx++;
  }
  //cout<< mp[25];
  
  ll N;
  cin >> N;
  ll cul[20];
  cul[0]=0;
  ll base=26;
  cul[1]=base;
  
  tmprep(i,11){
    base *= 26;
    cul[i] = cul[i-1] + base;
  }
  
  int ketasuu;
  rep(i,11) if(N<=cul[i]){ ketasuu=i;break;}
  
  ll n_th = N-cul[ketasuu-1]-1;
  //cout << n_th;
  //cout << ketasuu;
  string res="";
  ll tmp;
  for(int i=ketasuu;i>=1;i--){
    tmp = n_th%26;
    if(i!=0) res += mp[tmp];
    else res+= mp[n_th];
    n_th /= 26;
  }
  reverse(res.begin(),res.end());
  cout << res;
  return 0;
}

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

#define fi first
#define se second
#define ll long long

const int N = 303;

using namespace std;

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

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

        int n;
        cin >> n;
        int k = 1;
        while(n * k % 360){
                k += 1;
        }
        cout << k << "\n";
}


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

int main()
{
	int k,a,b;
	cin >> k >> a >> b;

	for (int i=k;i<=b;i+=k)
	{
		if ((i>=a)&&(i<=b))
		{
			cout << "OK" << endl;
			return 0;
		}

	}
	cout << "NG";
}






Measured memory_bytes: 3620
#include <iostream>
#include <sstream>
#include <map>
#include <cstring>
#include <string>
#include <iterator>

using namespace std;

int main(void){
  bool lastmonth[1000];
  bool thismonth[1000];
  map<int,int> times;
  int num, val;
  string str;

  memset(lastmonth, false, sizeof(lastmonth));
  memset(thismonth, false, sizeof(thismonth));
  while(getline(cin, str)){
    if(str.size() == 0) break;
    istringstream iss(str);
    iss >> num;
    iss.ignore();
    iss >> val;
    lastmonth[num] = true;
    times[num]++;
  }

  while(getline(cin,str)){
    if(str.size() == 0) break;
    istringstream iss(str);
    iss >> num;
    iss.ignore();
    iss >> val;
    thismonth[num] = true;
    times[num]++;
  }

  map<int,int>::iterator it = times.begin();
  for(;it!=times.end();++it){
    if(lastmonth[(*it).first] && thismonth[(*it).first]){
      cout << (*it).first << " " << (*it).second << endl;
    }
  }
}

Measured memory_bytes: 0
import std.stdio,std.math,std.string,std.conv,std.typecons,std.format;
import std.algorithm,std.range,std.array;

T[] readarr(T=long)(){return readln.chomp.split.to!(T[]);}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}

//END OF TEMPLATE

void main(){
    ulong m,n;
    ulong[] a;
    scan(n,m);
    a=readarr!ulong;
    auto sum=sum(a);
    (a.filter!(x=>x.to!real>=sum.to!real/(4*m).to!real).array.length>=m?"Yes":"No").writeln;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BUF_SIZE 40
#define MAX_SIZE 11
#define DIVISOR 2

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

// <size of arr> <arr[0]> <arr[1]> .. <arr[n-1]>
int fget_array_with_size(int *arr) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    char *tmp = strtok(tmpbuf, " ");
    arr[0] = strtol(tmp, NULL, 10);
    tmpbuf = NULL;
    for(i = 1; i <= arr[0]; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtol(tmp, NULL, 10);
    }
#else
#error
#endif
    return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    for(i = 0; i < size; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtol(tmp, NULL, 10);
        tmpbuf = NULL;
    }
#else
#error
#endif
    return 0;
}

int main(void) {
    int switches, lights;
    get_int2(&switches, &lights);
    int switch_bits[MAX_SIZE] = {0};
    int arr[MAX_SIZE];
    int i, j;
    for(i = 0; i < lights; i++) {
        fget_array_with_size(arr);
        for(j = 1; j <= arr[0]; j++) {
            switch_bits[i] |= (1<<(arr[j]-1));
        }
    }
    fget_array(arr, lights);

    int ans = 0;
    int pattern;
    for(pattern = 0; pattern < (1<<switches); pattern++) {
        int flag = 1;
        for(j = 0; j < lights; j++) {
            int cnt = __builtin_popcount(pattern & switch_bits[j]);
            //printf("light %d -> %d <-> %d\n", j, cnt, arr[j]);
            if(cnt % DIVISOR != arr[j]) {
                flag = 0;
                break;
            }
        }
        ans += flag;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
import itertools
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
target= range(1,n+1)
p_len=0
q_len=0
for i,v in enumerate(itertools.permutations(target,n)):
    tmp=list(v)
    if p==tmp:
        p_len=i
    if q==tmp:
        q_len=i
print(abs(p_len-q_len))

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

int main() {
  char a,b;
  cin>>a>>b;
  if(a=='H'&&b=='H')
  cout << "H" << endl;
  if(a=='D'&&b=='H')
  cout << "D" << endl;
  if(a=='H'&&b=='D')
  cout << "D" << endl;
  if(a=='D'&&b=='D')
  cout << "H" << endl;

  
}


Measured memory_bytes: 256
//agc019_c.cpp
//Sun Sep 30 10:13:52 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll q,h,s,d,n;
	cin >> q >> h >> s >> d >> n;

	ll half = 0;
	if (2*q > h){
		half = h;
	}else {
		half = 2*q;
	}

	ll litter = 0;
	if (2*half > s){
		litter = s;
	}else {
		litter = 2*half;
	}

	ll doublelitter = 0;
	if (2*litter > d){
		doublelitter = d;
	}else {
		doublelitter = 2*litter;
	}

	ll ans = 0;
	if (n%2 == 0){
		ans = n/2 * doublelitter;
	}else {
		ans = n/2 * doublelitter + litter;
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
function Main(input) {
  if(input==""){
    input="2\n10000 JPY\n0.10000000 BTC";
  }
  input = input.split("\n");
  var S = input[0].split("/");
  var ans = "Heisei";
  if(parseInt(S[0])>=2020||(parseInt(S[0])>=2019&&parseInt(S[1])>=5)){
    ans ="TBD";
  }


  console.log('%s', ans);
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<stdio.h>

struct card{
    char suit;
    int value;
};

struct card c1[100],c2[100];
int n;

void bubbleSort(){
    struct card temp;
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(c1[j].value<c1[j-1].value){
                temp=c1[j];
                c1[j]=c1[j-1];
                c1[j-1]=temp;
            } 
        }
    }
}

void selectionSort(){
    int minj;
    struct card temp;
    for(int i=0;i<n;i++){
        minj=i;
        for(int j=i+1;j<n;j++){
            if(c2[minj].value>c2[j].value)minj=j;
        }
        temp=c2[i];
        c2[i]=c2[minj];
        c2[minj]=temp;
    }
}

void print(struct card c[]){
    for(int i=0;i<n;i++){
        if(i)printf(" ");
        printf("%c%d",c[i].suit,c[i].value);
    }
    printf("\n");
}

int  isStable(struct card c1[],struct card c2[]){
    for(int i=0;i<n;i++){
        if(c1[i].suit!=c2[i].suit)return 0;
    }
    return 1;
}

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

    for(int i=0;i<n;i++){
        scanf(" %c%d",&c1[i].suit,&c1[i].value);
        c2[i]=c1[i];
    }

    bubbleSort();
    selectionSort();
    print(c1);
    printf("Stable\n");
    print(c2);
    if(isStable(c1,c2))printf("Stable\n");
    else printf("Not stable\n");
    return 0;
}


Measured memory_bytes: 2744
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    let d: i64 = read();

    let mut max: i64 = a * c;

    if a * d > max {
        max = a * d
    };
    if b * c > max {
        max = b * c
    };
    if b * d > max {
        max = b * d
    };

    println!("{}", max);
}


Measured memory_bytes: 2132
#include<iostream>
#include<string>

using namespace std;
    
#define NMAX 1000

struct S{
	int e,w;
	string n;
};

int main(void){
       
   int N,Q;
   int q;
   S year[NMAX];

   while(1){
	   cin>>N>>Q;
	   if(N==0&&Q==0) break;
	   for(int i=0;i<N;i++){
		   cin>>year[i].n>>year[i].e>>year[i].w;
	   }
	   for(int i=0;i<Q;i++){
		   cin>>q;
		   for(int i=0;i<N;i++){
			   if(q>=year[i].w-year[i].e+1&&q<=year[i].w){
				   cout<<year[i].n<<" "<<q-(year[i].w-year[i].e)<<endl;
				   break;
			   }
			   if(i==N-1) cout<<"Unknown"<<endl;
		   }
	   }
   }

   return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<long long> a(n + 1), b(n);
	long long ans = 0;
	for (int i = 0; i < n + 1; i++) {
		cin >> a.at(i);
	}
	for (int i = 0; i < n; i++) {
		cin >> b.at(i);
	}
	for (int i = 0; i < n; i++) {
		if (b.at(i) < a.at(i)) {
			a.at(i) -= b.at(i);
			ans += b.at(i);
		}
		else {
			b.at(i) -= a.at(i);
			ans += a.at(i);
			if (b.at(i) < a.at(i + 1)) {
				a.at(i + 1) -= b.at(i);
				ans += b.at(i);
			}
			else {
				ans += a.at(i + 1);
				a.at(i + 1) = 0;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
using namespace std;
int main(){
int i,n,ans;
cin >> n;
vector <int> p(n);
for(i=0;i<n;i++){
cin >> p[i];
}
ans = 0;
for(i=0;i<n-1;i++){
if(p[i]==i+1){
  p[i+1] = p[i];
ans +=1;
}
}
if(p[n-1] == n){
ans +=1;
}
cout << ans <<endl;
}

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

int a[20][20];
int c[20];

const int inf = 1LL << 60;

signed main(void){
  
  int n,m,x; cin >> n >> m >> x;
  for(int i = 0; i < n; i++){ 
    cin >> c[i];
    for(int j = 0; j < m; j++){ 
      cin >> a[i][j];
    }
  }
  
  int ans = inf;
  
  for(int bit = 0; bit < ( 1<<n ) ; bit++ ){ 
    
    int sum = 0;
    
    vector<int> make_sense(m,0);
    
    for(int i = 0; i < n; i++){ 
      
      if( bit >> i & 1 ){ 
        
        sum += c[i];
        
        for(int j = 0; j < m; j++){ 
          
          make_sense[j] += a[i][j];
          
        }
      }
    }
    
    bool flag = true;
    
    for(int k = 0; k < m; k++){ 
      if( make_sense[k] < x ){ 
        flag = false;
      }
      }
    if(flag){ ans = min(ans,sum);
            }
  }
  
  if(ans == inf ){ ans = -1;}
  
  cout << ans << endl;
  
  return 0;
}
      

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>

using namespace std;

inline bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }

typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef long long ll;
typedef unsigned long long ull;

#define For(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };
const int mod = 1000000007;
const int INF = 1e9;

int main()
{
	int n;
	while (cin >> n && n){
		vector<int> px[51][8], py[51][8];
		rep(i, n + 1){
			int m;
			cin >> m;

			int qx, qy;
			int x, y;
			cin >> x >> y;
			qx = -x, qy = -y;
			px[i][0].push_back(0); py[i][0].push_back(0);
			px[i][1].push_back(0); py[i][1].push_back(0);
			px[i][2].push_back(0); py[i][2].push_back(0);
			px[i][3].push_back(0); py[i][3].push_back(0);

			rep(j, m - 1){
				int tx, ty;
				cin >> tx >> ty;
				px[i][0].push_back((tx + qx)); py[i][0].push_back((ty + qy));
				px[i][1].push_back((ty + qy)); py[i][1].push_back(-(tx + qx));
				px[i][2].push_back(-(tx + qx)); py[i][2].push_back(-(ty + qy));
				px[i][3].push_back(-(ty + qy)); py[i][3].push_back((tx + qx));
			}

			rep(j, 4){

				px[i][j + 4].push_back(0);
				py[i][j + 4].push_back(0);
				int qx = -px[i][j][m - 1];
				int qy = -py[i][j][m - 1];
				For(k,1, m){
					px[i][j + 4].push_back(px[i][j][m - k - 1] + qx);
					py[i][j + 4].push_back(py[i][j][m - k - 1] + qy);
				}
			}
		}

		auto tx = px[0][0];
		auto ty = py[0][0];

		vector<int> ans;
		For(i, 1, n+1){
			bool f = false;
			rep(j, 8){
				if (tx == px[i][j] && ty == py[i][j]){
					f = true;
				}
			}
			if (f)ans.push_back(i);
		}
		rep(i, ans.size()){
			cout << ans[i] << endl;
		}
		rep(i, 5)cout << "+";
		cout << endl;

	}
	return 0;
}

Measured memory_bytes: 1308
//h13-1 電飾
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
namespace boost_multiprecision = boost::multiprecision;
#define LL long long
#define CINT boost_multiprecision::cpp_int
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)


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

    int last;
    cin >> last;
    vector<int> l;
    l.push_back(0);
    l.push_back(1);
    for(int i=1; i<N; i++){
        int tmp;
        cin >> tmp;
        if(tmp != last){
            last = tmp;
            l.back()++;
        }
        else{
            l.push_back(1);
        }
    }
    l.push_back(0);

    int ans = 0;
    for(int i=1; i<l.size()-1; i++){
        ans = max(ans, l[i-1] + l[i] + l[i+1]);
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for(int i = 0; i < N; i++){
    int a;
    cin >> vec.at(i);
   }
  for (int i=0; i < N; i++){
    if(i!=N-1) cout << vec.at(N-i-1) << " ";
    else cout << vec.at(N-i-1)<<endl; 
  }
    
}


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

int main(){
    int pt=0,px=0,py=0;
    int t=0,x=0,y=0;
    int flag=1;
    int n;
    int ans;

    cin >>n;
    cin >>pt>>px>>py;

    if(((px+py)%2==0)){
        if((pt)%2==1)flag=0;
    }else{
        if((pt)%2==0)flag=0;
    }

    if((abs(px)+abs(py)) > (pt))flag=0;

    for (int i = 0; i < n-1; i++){
        cin >>t>>x>>y;

        if((abs(x-px)+abs(y-py))%2==0){
            if((t-pt)%2==1)flag=0;
        }else{
            if((t-pt)%2==0)flag=0;
        }
        
        if((abs(x-px)+abs(y-py)) > (t-pt))flag=0;

        pt=t;
        px=x;
        py=y;
    }
    
    
    //cout << ans <<endl;
    if(flag==1)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=0;i<b;i++)
#define REP(i,a,b) for(int i=0;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout <<(f?"Yes":"No")<<endl//fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout <<(f?"yes":"no")<<endl
#define YES(f) cout <<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())

using namespace std;

const int mod=1e9+7;

int last_two=2;
int last_one=1;
signed main(){
    int n;
    cin >> n;
    int ans=1;
    rep(i,n-1)
    {
        ans=last_one+last_two;
        last_two=last_one;
        last_one=ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//cout << fixed << setprecision();
//priority_queue<ll, vector<ll>, greater<ll>> q;


struct BIT
{
private:
	vl bit;
	ll n;
public:
	void init(ll k){
		n=k;
		bit.resize(n+10,0);
	}
	void add(ll ind,ll a){
		for(ll i=ind; i<=n ; i+=i&-i){
			bit[i]+=a;
		}
	}
	ll get_sum(ll a){
		ll ret=0;
		if(a==0)return ret;
		for(ll i=a; i>0; i-=(i&-i)){
			ret+=bit[i];
		}
		return ret;
	}
	ll get_sum(ll l,ll r){
		ll ret1=get_sum(l-1);
		ll ret2=get_sum(r);
		return ret2-ret1;
	}
};


signed main(){
	ll n; cin>>n;
	string s; cin>>s;
	BIT vbit[30]; rep(i,0,26)vbit[i].init(n);
	rep(i,0,n){
		vbit[s[i]-'a'].add(i+1,1); //1-indxed
	}
	ll q; cin>>q;
	while(q--){
		ll t; cin>>t;
		if(t==1){
			ll i; char c; cin>>i>>c;
			--i;
			vbit[s[i]-'a'].add(i+1,-1);
			s[i]=c;
			vbit[s[i]-'a'].add(i+1,1);
		}
		else{
			ll l,r; cin>>l>>r;
			ll ans=0;
			rep(i,0,26){
				if(vbit[i].get_sum(l,r)>0)ans++;
			}
			cout<<ans<<'\n';
		}
	}
	
	return 0;
}

Measured memory_bytes: 105340
import java.util.Scanner;

public class Main {
    private static final int MOD = 2019;

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

        int L = sc.nextInt();
        int R = sc.nextInt();

        System.out.println(solve(L, R));
    }

    private static int solve(int L, int R) {
        int min = 2018;

        if (R-L >= 2019) return 0;

        L %= MOD;
        R %= MOD;
        if (L>R) return 0;

        for (int i=L; i<R; i++) {
            for (int j=L+1; j<=R; j++) {
                min = Math.min(min, i*j%MOD);
            }
        }

        return min;
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
typedef complex<long double> com;

ll n;
vector <vector<ll>> graph;
map <ii,ll> mapp;
ll temp = 0;

void dfs1(ll u = 1,ll p = 0){
	for (int z=0;z<graph[u].size();z++){
		if (graph[u][z] == p) continue;
		if (graph[u][z] < u) mapp[make_pair(graph[u][z],u)] = graph[u][z];
		else mapp[make_pair(u,graph[u][z])] = graph[u][z];
		dfs1(graph[u][z],u);
	}
}

bool dfs(ll u ,ll v,ll p = 0){
	if (u == v) return true;
	for (int z=0;z<graph[u].size();z++){
		if (graph[u][z] == p) continue;
		if(dfs(graph[u][z],v,u)){
			if (graph[u][z] < u) {
				temp |= ll(1) << mapp[make_pair(graph[u][z],u)];
			}
			else {
				temp |= ll(1) << mapp[make_pair(u,graph[u][z])];
			}
			return true;
		}
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	graph.resize(n+1);
	for (int z=0;z<n-1;z++){
		ll u,v;
		cin >> u >> v;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	ll m;
	cin >> m;
	vector <ii> rules(m);
	for (int z=0;z<m;z++){
		cin >> rules[z].first >> rules[z].second;
	}
	dfs1();
	vector <ll> edges(m,0);
	for (int z=0;z<m;z++){
		temp = 0;
		dfs(rules[z].first,rules[z].second);
		edges[z] |= temp;
	}
	ll i = 0;
	ll ans = ll(1) << (n-1);
	ll tt = 0;
	for (int i=0;i<(ll(1) << m);i++){
		if (__builtin_popcountll(i) < 1) continue;
		tt = 0;
		for (int z=0;z<m;z++){
			if (i & (ll(1) << z)){
				tt |= edges[z];
			}
		}
		ll hh = __builtin_popcountll(tt);
		if (__builtin_popcountll(i) & 1) ans -= ll(1) << (n-1-hh);
		else ans += ll(1) << (n-1-hh);
	}
	cout << ans << endl;
}
 


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

int main(){
  int N, X;
  cin >> N >> X;
  
  vector<int> L(N);
  
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  
  int D = 0, count = 0;
  
  while (D <= X) {
    D = D + L.at(count);
    count++;
    if (count == N) {
      if (D <= X) {
        count++;
      }
      break;
    }
  }
  
  cout << count << endl;
  
  return 0;
}

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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            bool ret = false;
            int retint = 0;
            string retstr = string.Empty;
            var ins = Console.ReadLine().Split(' ');
            var num = ins.Select(x => c2i(x)).ToList();
            var HP = num[0];
            var HIT = num[1];
            while (!ret)
            {
                HP -= HIT;
                retint++;
                if (HP <= 0)
                {
                    ret = true;
                }

            }

            Console.WriteLine(retint);
            //Console.ReadLine();
        }
            
        static int c2i(string c) { return int.Parse(c); }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    for(ll i=0;i<N;++i)cin>>A[i];
    ll ans=1;
    for(ll i=0;i<N;++i){
        if(A[i]==0){prt(0)return 0;}
    }
    for(ll i=0;i<N;++i){
        if(A[i]>(ld)((ld)powl(10,18)/(ld)ans)){prt(-1)return 0;}
        ans*=A[i];
        if(ans>powl(10,18)){prt(-1)return 0;}
    }
    prt(ans)
    
    return 0;
}


Measured memory_bytes: 3980
using System;
using System.Linq;

namespace ITP1_11_B
{
	class Dice
	{
		public static int[] label = new int[6];
		public static void Roll(string s)
		{
			foreach (char c in s)
			{
				switch (c)
				{
					case 'E': { East(); break; }
					case 'N': { North(); break; }
					case 'S': { South(); break; }
					case 'W': { West(); break; }
				}
			}
		}
		static void East()
		{
			int x = label[0];
			label[0] = label[3]; label[3] = label[5];
			label[5] = label[2]; label[2] = x;
		}
		static void North()
		{
			int x = label[0];
			label[0] = label[1]; label[1] = label[5];
			label[5] = label[4]; label[4] = x;
		}
		static void South()
		{
			int x = label[0];
			label[0] = label[4]; label[4] = label[5];
			label[5] = label[1]; label[1] = x;
		}
		static void West()
		{
			int x = label[0];
			label[0] = label[2]; label[2] = label[5];
			label[5] = label[3]; label[3] = x;
		}
	}
	class Program
	{
		static void Main(string[] args)
		{
			Dice.label = Console.ReadLine().Split().Select(int.Parse).ToArray();
			string[] c = new string[] { "E", "N", "S", "W", };
			int n = int.Parse(Console.ReadLine());
			for (int i = 0; i < n; i++)
			{
				int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
				Random rand = new Random();
				while (!(Dice.label[0] == a[0] && Dice.label[1] == a[1]))
				{
					int b = (int)(rand.NextDouble() * 100000);
					Dice.Roll(c[b % 4]);
					rand = new Random(b);
				}
				Console.WriteLine(Dice.label[2]);
			}
		}
	}
}


Measured memory_bytes: 16380
import java.util.Scanner;

//????????????????????????????°?????????¨??§???????????\????????????????????????????????????????????????
//??¢????????????????????\???????????????????????????????????????????????????
public class Main{
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();

		//char?????????????????£?¨?
		//Character???????????§??????????????§???????°???????????????\??§?????????
		char [] csen = s.toCharArray();
		for(int i = 0; i < csen.length; i++){

			//?????°???char??????????????§??????(isUpperCase)????°???????(isLowerCase)????????????????????????
			//????????£???????????°true???????????§???????????°false??????????????????
			if(Character.isUpperCase(csen[i])){
				//toLowerCase??§????°????????????????????????????????????????
				csen[i] = Character.toLowerCase(csen[i]);
			}else{
				//toUpperCase??§?????§???????????????????????????????????????
				csen[i]=Character.toUpperCase(csen[i]);
			}
		}

		//?????????Char??????String????????????
		String ans = "";
		for(int i = 0; i < csen.length; i++){
			ans += csen[i];
		}

		//????????????
		System.out.println(ans);
		sc.close();
	}
}

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

list_AB.sort()
ans = 0
for i in range(n):
    l = list_AB[i]
    if l[1] > m:
       ans += l[0]*m
       break
    else:
        ans += l[0]*l[1]
        m -= l[1]

print(ans)

Measured memory_bytes: 27812
#include <stdio.h>
#include <stdlib.h>
 
#define MAX 14
 
int main()
{
    int card[MAX+3];
    int max;
    int i, j, d[5];
     
    while (scanf("%d,%d,%d,%d,%d", &d[0], &d[1], &d[2], &d[3], &d[4]) == 5) {
        for (i = 1; i <= MAX; i++) card[i] = 0;
        max = 0;
        for (i = 0; i < 5; i++) {
            if (++card[d[i]] > max) max = card[d[i]];
            if (d[i] == 1) card[14] = 1;
        }
        if (max == 4) {
            puts("four card");
            goto DONE;
        }
        if (max == 3) {
            for (i = 1; i < MAX; i++) {
                if (card[i] == 2) {
                    puts("full house");
                    goto DONE;
                }
            }
        }
        if (max == 1) {
            for (i = 1; i <= 10; i++) {
                for (j = 0; ; j++) {
                    if (j >= 5) {
                        puts("straight");
                        goto DONE;
                    }
                    if (card[i + j] != 1) break;
                }
            }
        }
        if (max == 3) {
            puts("three card");
            goto DONE;
        }
        if (max == 2) {
            for (i = 1; card[i] < 2; i++);
            for (j = i + 1; j < MAX; j++) {
                if (card[j] == 2) {
                    puts("two pair");
                    goto DONE;
                }
            }
            puts("one pair");
            goto DONE;
        }
        puts("null");
    DONE:;
    }
    return 0;
}


Measured memory_bytes: 1980
#include <bits/stdc++.h>
using namespace std;
int obs[100100],ans[100100]={0},a[100100]={0};
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>obs[i];
    }
    while(m--){
        int x,y;
        cin>>x>>y;
        if(obs[x]<obs[y]) ans[x]=-1;
        else if(obs[y]<obs[x]) ans[y]=-1;
        else if(obs[x]==obs[y]) {
            ans[x]=-1;
            ans[y]=-1;
        }
        if(obs[x]>obs[y]&&ans[x]!=-1) ans[x]=1;
        else if(obs[y]>obs[x]&&ans[y]!=-1) ans[y]=1;
        a[x]=y;
        a[y]=x;
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(ans[i]==1) cnt+=1;
        if(a[i]==0) cnt+=1;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 4760
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
LL a[10000];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
    }
    LL ans=0;
    while(true)
    {
        LL maxn=a[1];
        int id=1;
        for(int i=2; i<=n; i++)
        {
            if(maxn<a[i])
            {
                maxn=a[i];
                id=i;//---
            }
        }
        if(maxn<=n-1)
            break;////////------
        for(int i=1; i<=n; i++)
        {
            if(i==id)
            {
                a[i]=maxn%n;

            }
            else
            {
                a[i]+=maxn/n;
            }
        }
        ans+=maxn/n;//
    }
    printf("%lld\n",ans);
}


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

int main()
{
    int N,checker=101,ans=0;
    cin >> N;
    int a[N];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    sort(a,a+N);
    for(int i=N-1; i>=0; i--){
        if(checker > a[i]){
            ans++;
            checker = a[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
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);
    rep(i, N) cin >> a.at(i);
    rep(i, N)  a.at(i)--;
    int now = 0;
    int cnt = 0;
    for (;;){
        if(now==1){
            break;
        }
        if(cnt>N){
            puts("-1");
            return 0;
        }
        cnt++;
        now = a.at(now);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
)

func solve() {
	var N int
	var D int
	fmt.Scan(&N, &D)

	ans := N / (2 * D + 1)
	if N % (2 * D + 1) != 0 {
		ans += 1
	}
	fmt.Println(ans)
}

func main() {
	solve()
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}



int main() {
	int n;
	cin >> n;
	int a[2][100];
	REP(i, 2)REP(j, n)cin >> a[i][j];

	ll ans = 0;
	REP(i, n) {
		ll tmp = 0;	
		REP(j, i + 1)tmp += a[0][j];
		FOR(j, i, n) tmp += a[1][j];
		if (tmp > ans)ans = tmp;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
   using namespace std;
   using pii = pair<int, int>;
   using ll = long long;
   #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
   const ll MOD = 1000000007;
   const ll INF = 1LL << 60;

   int main() {
     ll N, ans = 0;
     cin >> N;

     for (ll i = 1; i < N + 1; i++) {
       if (i % 3 != 0 && i % 5 != 0) ans += i;
     }

     cout << ans << endl;
   }


Measured memory_bytes: 3672
import java.util.*;
public class Main {
    public static void main(String args[]) {
     Scanner sc = new Scanner(System.in);
     
   int h = sc.nextInt();
   int  n =sc.nextInt();
   int s =0;
   int[] a = new int[n];
   for(int  i=0;i<n;++i){
       a[i]= sc.nextInt();
       s+=a[i];
   }
   if(s>=h){
       System.out.println("Yes");
   }else{
        System.out.println("No");
   }
    }
}

Measured memory_bytes: 49608
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

int main(){
  	string s;
	cin >> s;
  	int i = 0;
  	char pre = ' ';
    int ans = 0; 
    bool foundr = false;
  	for(auto c: s){
      	if(c == 'R') foundr = true;
    	if(i != 0){
        	if(pre == c && c == 'R') ans++;
        }
        pre = c;
      	i++;
    }
  	if(foundr) ans++;
  	cout << ans << endl;
}

Measured memory_bytes: 3624
while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    a = []
    for i in range(n):
        a.append(int(input()))
        count = 0
    for i in range(k):
        count += a[i]
        ans = count
    for i in range(k, n):
        count += a[i]
        count -= a[i - k]
        ans = max(ans, count)
    print(ans)


Measured memory_bytes: 9612
#include <bits/stdc++.h>
using namespace std;
bool a[10000001];
int main(){
  long long b[5000]={0},c=0,i,j;
  for(i=2;i<10000001;i++){
    if(!a[i])for(j=i+i;j<10000001;j+=i)a[j]=1;
  }
  for(i=5;i<10000001-9;i++)if(a[i]==0&&a[i+2]==0&&a[i+6]==0&&a[i+8]==0)b[c++]=i+8;
  while(scanf("%d",&j),j){
    for(i=0;i<c;i++){
      if(j<b[i])break;
    }
    if(i--);
    cout<<b[i]<<endl;
  }
}

Measured memory_bytes: 12932
while True:
	h,w = [int(s) for s in input().split(' ')]
	if h==0 and w==0:
		break
	else:
		top_bottom = '#'*w + '\n'
		low = '#' + '.'*(w-2) + '#\n'
		rectangle = top_bottom + low*(h-2) + top_bottom
		print(rectangle)

Measured memory_bytes: 7724
import java.io.*;
import java.util.*;
import java.math.*;
 
public class Main{ 
   static class Fast{
     public BufferedReader br;
     public StringTokenizer st;
     
     public Fast(){
          br =new BufferedReader(new InputStreamReader(System.in));
     }
     
     String next(){
          while(st==null || !st.hasMoreTokens()){
               try{
                    st=new StringTokenizer(br.readLine());
               }
               catch(IOException e){
                    throw new RuntimeException(e);
               }
               
          }
               return st.nextToken();
          }
     int nextInt(){
          return Integer.parseInt(next());
     }
 
     long nextLong(){
          return Long.parseLong(next());
     }
 
     double nextDouble(){
          return Double.parseDouble(next());
     }

     String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
 
 }  
   
    static  Fast f=new Fast();
    static PrintWriter out = new PrintWriter(System.out);


    static void readArray(int a[]) 
      {
        
        for (int i=0;i<a.length;i++ ) a[i]=f.nextInt();
        
      }
    
    
     
  public static void main(String[] args)throws Exception{
  //StringTokenizer st;//! @ % & * () _ {} # ~ : < > ? "" | ^
         
 
        //StringBuilder res=new StringBuilder();

         int primes[]=new int[1000010];
              primes[0]=0;
              primes[1]=1;
              for (int i=2;i*i<=primes.length;i++ ) {
                if (primes[i]==0) {
                  primes[i]=i;
                  for (int j=i*i;j<primes.length ;j+=i ) {
                    if (primes[j]==0) {
                      primes[j]=i;
                    }
                    
                  }
                }
              }
               
          
              for (int i=2;i<primes.length;i++ ) {
                if (primes[i]==0) {
                  primes[i]=i;
                  //l.add(i);
                }
              }


         int n=f.nextInt();
  
       
       // while(t-->0){

         long ans=0;
        
          for (int c=1;c<n ;c++ ) {
            int k=n-c;
            long ans2=1;
            while(primes[k]!=1) {
              int temp=primes[k];
              int count=0;
              while(temp==primes[k]) {
                count++;
                k/=temp;
              }
              ans2*=(count+1);
            }
            ans+=ans2;
          }

          out.println(ans);
          
         
        
          
      //  }
          
   
        

        out.close();
 
}
}

Measured memory_bytes: 37972
#include <cstdio>

using namespace std;

int main() {
    int n, a, b;
    
    scanf("%d %d %d", &n, &a, &b);
    
    if ((b - a) % 2 == 0) {
        puts("Alice");
    } else {
        puts("Borys");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

#include<string.h>

int main()
{
int a[49834],i,j,k,b,c,n,count=0;
char ch[49396633],s[5466336] ;
scanf("%s",&s) ;
scanf("%s",&ch) ;
b=strlen(s) ;
for(i=0 ; i<b ; i++)
{
    if(s[i]!=ch[i])
        count++ ;
}
printf("%d",count) ;
return 0 ;
}


Measured memory_bytes: 2128
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    m=min(A); M=max(A)

    # 種類数が x だとして
    # 自分の色が他にいない -> x-1
    # 自分の色が他にいる -> x
    # よって M-m は1以下
    if(M-m>1):
        print("No")
        return

    # もし全員が同じ数字を言っている場合
    if(m==M):
        if(m==n-1): # 全てが1色ずつならOK
            print("Yes")
            return
        elif(m<=n//2): # 全てが2色以上ずつ用意できるならOK
            print("Yes")
            return
        else:
            print("No")
            return

    # もしズレがある場合
    s=A.count(m) # 自分だけの色を持つ数
    t=A.count(M) # 複数で色を共有する数
    # 色の種類は最小でs+1、最大でs+t//2
    if(s+1<=M<=s+t//2):
        print("Yes")
    else:
        print("No")

resolve()

Measured memory_bytes: 52676
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b, c = map(int, input().split())
    r = 0
    if a % 2 == b % 2 == c % 2:
        pass
    else:
        # 奇数が１つ → 偶数に+1
        if (a + b + c) % 2 == 1:
            a += 1 if a % 2 == 0 else 0
            b += 1 if b % 2 == 0 else 0
            c += 1 if c % 2 == 0 else 0
        # 奇数が２つ → 奇数に+1
        else:
            a += 1 if a % 2 == 1 else 0
            b += 1 if b % 2 == 1 else 0
            c += 1 if c % 2 == 1 else 0
        r += 1
    r += ((max(a, b, c) * 3 - (a + b + c)) // 2)
    print(r)

if __name__ == '__main__':
    main()

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

int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	if(a > b){
		swap(a, b);
	}
	while(b--){
		printf("%d", a);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,a[200040];
string s;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout<<fixed<<setprecision(12);
	cin>>n;
	for(;n--;)cout<<"ACL";
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
using namespace std;
int main() {
    string n;
    cin>>n;
    bool cont=false;
    
    if(n[0]==n[1]&&n[1]==n[2]) cont = true;
    else if(n[1]==n[2]&&n[2]==n[3]) cont = true;
    
    if(cont==true) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int i;
    int ch;
    while((ch = getchar()) != EOF ){
        if(ch >= 'a' && ch <='z'){
            ch = 'A' + ch - 'a';
        }
        else if(ch >= 'A' && ch <= 'Z'){
            ch = 'a' + ch - 'A';
        }
        printf("%c", ch);
    }
    return 0;
}

Measured memory_bytes: 524
//#define _GLIBCXX_DEBUG
#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;
using namespace atcoder;

#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,Q; cin>>N>>Q;
  dsu uf(N);
  rep(i,Q){
    ll t,u,v; cin>>t>>u>>v;
    if(!t) uf.merge(u,v);
    else cout<<uf.same(u,v)<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3996
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define EPS 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f3f3f3f3f
#define MEM(a, b) memset(a, b, sizeof(a))
#define PPER(i, n, m) for (int i = n; i >= m; i--)
#define REPP(i, n, m) for (int i = n; i <= m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define PER(i, n, m) for (int i = n; i > m; i--)
#define SA(n) scanf("%d", &(n))
#define SLLA(n) scanf("%lld", &(n))
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define DE(val) cout << #val << ": " << val << endl;

const int dx44[6] = {0, -1, -1, 1, 1};
const int dy44[6] = {0, -1, 1, -1, 1};
const int dx4[6] = {0, 1, 0,-1};
const int dy4[6] = {-1, 0, 1,0};
const int dx8[9] = {0, -1, 0, 1, 0, 1, 1, -1, -1};
const int dy8[9] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
const int dx82[9] = {0, -1, -1, 1, 1, 2, 2, -2, -2};
const int dy82[9] = {0, 2, -2, 2, -2, 1, -1, 1, -1};
void update(ll& x,ll v){
    if(x==-1)x=v;
    else if(x>v)x=v;
}

ll po(ll a, ll b, ll mod)
{
    ll res = 1;
    a %= mod;
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
void extgcd(ll a, ll b, ll &d, ll &x, ll &y)
{
    if (!b)
    {
        d = a;
        x = 1;
    }
    else
    {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}
ll inverse(ll a, ll n)
{
    ll d, x, y;
    extgcd(a, n, d, x, y);
    return d == 1 ? (x + n) % n : -1;
}
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const int maxn = 3e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
/*************************************************************************/

int k;
string val;
void solve() {
    cin>>k>>val;

    string ans;
    REP(i,0,val.length()) {
        int kt = val[i] - 'A';
        char t = (kt + k)%26 + 'A';
        ans.push_back(t);
    }
    cout<<ans<<endl;
}


int main()
{
#ifndef ONLINE_JUDGE
  //freopen("i.txt", "r", stdin);
  //freopen("o.txt", "w", stdout);
#endif
  solve();
  return 0;
}





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


int main() {
	int r,g,b,n,ans=0;
	vector<int> rgb(3);
	cin >> rgb[1] >> rgb[2] >> rgb[3] >> n;
	sort(rgb.begin(),rgb.end());
	r = rgb[3];
	g = rgb[2];
	b = rgb[1];

	for (int i = 0; i <= n / r; i++) {
		for (int j = 0; j <= (n - (r * i)) / g; j++) {
			if ((n - (r * i) - (g * j) )% b == 0)ans++;
			}
		}
	
	cout << ans << endl;
	return 0;
}	

Measured memory_bytes: 256
import java.util.Scanner;

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

		int N = Integer.parseInt(sc.next());
		String s = sc.next();

		sc.close();

		if(N % 2 == 1) {
			System.out.println("No");
			return;
		}

		System.out.println(s.substring(0, N / 2).equals(s.substring(N / 2, N)) ? "Yes" : "No");
//		System.out.println(s.substring(N / 2, N));

//		System.out.println(s.substring(N / 2, N));
//		FastScanner fs = new FastScanner();
//		int N = fs.nextInt();


	}
}



Measured memory_bytes: 21844