akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define N 36
typedef struct {
  int value;
  char mark;
}card;

int main(){


  /*1 bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A
    2   flag = 1 // 逆の隣接要素が存在する
    3   while flag
    4     flag = 0
    5     for j が N-1 から 1 まで
    6       if A[j] < A[j-1]
    7         A[j] と A[j-1] を交換
    8         flag = 1
  */
  /*
    1 BubbleSort(C, N)
    2   for i = 0 to N-1
    3     for j = N-1 downto i+1
    4       if C[j].value < C[j-1].value
    5         C[j] と C[j-1] を交換
    6
    7 SelectionSort(C, N)
    8   for i = 0 to N-1
    9     minj = i
    10    for j = i to N-1
    11      if C[j].value < C[minj].value
    12        minj = j
    13    C[i] と C[minj] を交換
  */ 

  int n ,i ,j,c=0 , t ,min;
  char tc , nu;
    card arr[N],input[N];
  scanf("%d\n" ,&n);
  // scanf("%c" ,&nu );// /n
  
  for ( i = 0; i < n; i++){
    if ( i == n-1 ) {    scanf("%c%d",&arr[i].mark,&arr[i].value);
    }else{
    scanf("%c%d ",&arr[i].mark,&arr[i].value);
    //    printf("test%c%d\n",arr[i].mark,arr[i].value);
    }
    input[i].mark = arr[i].mark;
    input[i].value = arr[i].value;
  }

  // printf("test%c%d\n",arr[0].mark,arr[0].value);
  
  int flag = 1 ;
  while ( flag){
    flag = 0;
    for ( i = n - 1 ;  i >= 1; i--){
      if ( arr[i].value < arr[ i-1 ].value){
	t = arr[i].value; arr[i].value = arr[ i-1 ].value; arr[i-1].value = t;
	tc = arr[i].mark; arr[i].mark = arr[ i-1 ].mark; arr[i-1].mark = tc;
	c++;
	flag = 1;
      }
    }
  }

  // printf("test%c%d\n",arr[0].mark,arr[0].value);
  
  for ( i = 0; i < n; i++){
    printf("%c%d",arr[i].mark,arr[i].value);
    if ( i == n-1){printf("\n");}
    else {printf(" ");}
  }
printf("Stable\n");

  
//selection sort part

  for ( i = 0; i < n ;i++){
    min = i;
    for ( j = i; j < n; j++){
      if ( input[j].value < input[min].value){ min = j;}
    }
    if ( input[i].value != input[min].value ){
      c++;
    j = input[i].value; input[i].value = input[min].value; input[min].value = j;
    	tc = input[i].mark; input[i].mark = input[min].mark; input[min].mark = tc;
    }
  }
  
   for ( i = 0; i < n; i++){
    printf("%c%d",input[i].mark,input[i].value);
    if ( i == n-1){printf("\n");}
    else {printf(" ");}
  }



 
  flag = 1;
  for ( i = 0; i < n; i++){
    if( input[i].mark != arr[i].mark){
      flag =0;break;
    }
  }
  if (flag == 1){printf("Stable\n");}
  else if ( flag == 0)  { printf("Not stable\n");}
  
  return 0;
}



Measured memory_bytes: 2108
#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>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;

int x[N];
int dp[N][50];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&x[i]);

    int L,Q;
    scanf("%d%d",&L,&Q);
    for(int i=1; i<=n ;i++){
        int left=i+1,right=n;
        while(left<=right){
            int mid=(left+right)/2;
            if(x[mid]<=L+x[i])
                left=mid+1;
            else
                right=mid-1;
        }
        //int pos=upper_bound(x+1,x+1+n,x[i]+L)-x-1;
        if(x[i]+L>=x[n])
            dp[i][0]=n;
        else
            dp[i][0]=left-1;
    }

    for(int i=1; i<=30; i++)
        for(int j=1; j<=n; j++)
            dp[j][i]=dp[dp[j][i-1]][i-1];

    while(Q--){
        int a,b;
        scanf("%d%d",&a,&b);
        if(b<a)
            swap(a,b);
        LL res=0;
        for(int i=30; i>=0; i--){
            if(dp[a][i]<b){
                res+=(1<<i);
                a=dp[a][i];
            }
        }
        printf("%lld\n",res+1);
    }
    return 0;
}

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

int main() {
    int N, T, A;
    cin >> N >> T >> A;
    int B[N];
    for (int i=0; i<N; i++) cin >> B[i];
    double min_diff=10000000;
    int a;
    double x[N], diff[N];
    for (int i=0; i<N; i++){
        x[i]=T-B[i]*0.006;
        diff[i]=abs(x[i]-A);
        if (diff[i]<=min_diff){
            min_diff=diff[i];
            a=i;
        }
    }
    cout << a+1 << endl;
}


Measured memory_bytes: 256
from collections import Counter
def solve(N, S):
    d = 10**9 + 7
    c = Counter(S)
    ans = 1
    for ch, count in c.items():
        ans *= (count + 1)
    ans %= d
    return ans - 1

if __name__ == "__main__":
    N = int(input())
    S = input()
    print(solve(N, S))


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int m,k;
  cin>>m>>k;
  
  int upper_limit = (1<<m);
  if(k>=upper_limit){
    cout<<-1<<endl;
    return 0;
  }
  
  //mが1の時の処理を分ける必要がありそう
  if(m==1){
    if(k==0){
      cout<<0<<' '<<0<<' '<<1<<' '<<1<<endl;
      return 0;
    }else{
      cout<<-1<<endl;
      return 0;
    }
  }
  
  vector<int> ans;
  REP(i,upper_limit){
    if(i==k)continue;
    ans.push_back(i);
  }
  ans.push_back(k);
  for(int i=upper_limit-1;i>=0;i--){
    if(i==k)continue;
    ans.push_back(i);
  }
  ans.push_back(k);
  
  for(int a:ans){
    cout<<a<<' ';
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 2932
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	string str1,str2;
	cin>>str1>>str2;
	int len;
	len = str1.length();
	int i,cnt;
	cnt=0;
	for(i=0;i<len;i++)
	{
		if(str1[i]!=str2[i])
			cnt++;
	}
	cout<<cnt;
	return(0);
}	



Measured memory_bytes: 3856
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int N = 1001010;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s; cin >> s;
  int have = 700;
  for(int i = 0; i < 3; ++i) {
    have += 100 * (s[i] == 'o');
  }
  cout << have << endl;
}


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

#define MOD 1000000007
template<typename ty1,typename ty2>
inline int add(ty1 x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x += y; return x < MOD ? x : x - MOD;
}
template<typename ty1,typename ty2>
inline void addto(ty1 &x, ty2 y) {
		  if(y>=MOD)y%=MOD;
		  if(x>=MOD)x%=MOD;
	      x += y; if (x >= MOD) x -= MOD;
}
template<typename ty1,typename ty2>
inline int sub(ty1 x, ty2 y) {
		if(y>=MOD)y%=MOD;
		 if(x>=MOD)x%=MOD;
        x -= y; return x < 0 ? x + MOD : x;
}
template<typename ty1,typename ty2>
inline void subto(ty1 &x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x -= y; if (x < 0) x += MOD;
}
template<typename ty1,typename ty2>
inline int mul(ty1 x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        return 1ll * x * y % MOD;
}
template<typename ty1,typename ty2>
void multo(ty1 &x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        x=1ll * x * y % MOD;
}


long long int ppow(long long int i, long long int j){
		long long int res = 1LL;
		while (j){
			if ((j & 1LL)){
				res *= i;
				if (res >= MOD){
					res %= MOD;
				}
			}
			j >>= 1;
			i *= i;
			if (i >= MOD){
				i %= MOD;
			}
		}
		return res;
	}
class Combination{
	
public:
	vector<long long int> k;
	vector<long long int> r;
	void resize(int N){
		k.resize(N + 2);
		r.resize(N + 2);
		k[0] = 1;
		for (int i = 1; i < N+2; i++){
			k[i] = k[i - 1];
			k[i] *= i;
			if (k[i] >= MOD)k[i] %= MOD;
		}
		long long int al = k[k.size() - 1];
		long long int iv = ppow(k[k.size() - 1],MOD-2);
		r[k.size() - 1] = iv;
		for (int i = (int)(r.size()) - 2; i >= 0; i--){
			r[i] = r[i + 1] * (i + 1);
			if (r[i] >= MOD){
				r[i] %= MOD;
			}
		}
	}
	long long int C(int a, int b){
		if (a < b)return 0;
		long long int up = k[a];
		long long int dw = r[b] * r[a - b];
		dw %= MOD;
		up *= dw;
		up %= MOD;
		return up;
	}
	long long int H(int a, int b){
		return C(a + b - 1, b);
	}
	long long int catalan_number(int n){
		return (C(2 * n, n) + MOD - C(2 * n, n - 1)) % MOD;
	}
};
Combination C;


#define MAX 100002

int n;
vector<long long int> v;
int main(){
	cin>>n;
	for(int i=0;i<n+1;i++){
		int a;
		scanf("%d",&a);
		v.push_back(a);
	}
	auto nd=v;
	for(int i=(int)v.size()-2;i>=0;i--){
		v[i]+=v[i+1];
	}
	long long int cur=1;
	long long int mx=0;
	for(int i=1;i<v.size();i++){
		cur*=2;
		cur=min(cur,v[i]);
		mx+=cur;
		cur-=nd[i];
		//cerr<<cur<<endl;
		if(cur<0LL){
			puts("-1");
			return 0;
		}
	}
	long long int leaf=mx;
	v=nd;
	if(leaf){
		if(v[0]){
			puts("-1");
			return 0;
		}
		if(v[0]==0){
			cout<<mx+1<<endl;
			return 0;
		}
	}
	else{
		if(v[0]==1){
			cout<<v[0]<<endl;
		}
		else{
			cout<<-1<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5036
program main
  implicit none

  integer :: x, y, z, n, i, k
  integer,allocatable :: p(:)

  read(*,*) x, n

  if(n == 0) then
     write(*,*) x
     stop
  end if
  
  allocate(p(n))
  read(*,*) p


  call heapsort(p)

  do i = 1, n
     if(p(i) == x) then
        k = i
        exit
     else
        k = -1
     end if
  end do

  if(k == -1) then
     write(*,*) x
     stop
  else
     if(k == 1) then
        y = x-1
     else
        
        do i = 1, k-1
           if(p(k-i) /= x-i) then
              y = x-i
              exit
           else
              y = x - k
           end if
        end do
     end if

     if(k == n) then
        z = x + 1
     else
        
        do i = 1, n-k
           if(p(k+i) /= x+i) then
              z = x+i
              exit
           else
              z = x + (n - k + 1)
           end if
        end do
     end if
     
  
  end if
  
  if(abs(y-x) <= abs(z-x))then
     write(*,*) y
  else
     write(*,*) z
  end if

  stop
        

  contains
  subroutine heapsort(array)
  implicit none
  integer, intent(inout) :: array(:)
  
  integer :: i,k,j,l
  double precision :: t
  
  if(n <= 0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n == 1)return

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j <= k)
        if(j < k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo

  return
end subroutine heapsort

end program main


Measured memory_bytes: 2860
d1 = gets.split.map(&:to_i)
d2 = gets.split.map(&:to_i)
dt = Array.new(6)
t = 0
f = 0
2.times do |i|
  idx = 0
  d1.each_with_index do |dir, j|
    if ((dir == d2[i]) && (d1[5-j] == d2[5-i]))
      idx = j
      break
    end
  end
  dt[i] = d1[idx]
  dt[-(i+1)] = d1[5-idx]
  t = idx + 1 if (i == 0)
  f = idx + 1 if (i == 1)
  d1[idx] = nil
  d1[5-idx] = nil
end
case t
when 1,6
  s = [2,3,5,4]
  while (s.include?(f))&&(s[0] != f) do
    s.unshift(s.pop)
  end
  idx = (t == 1) ? s[1] - 1 : s[-1] - 1
when 2,5
  s = [1,4,6,3]
  while (s.include?(f))&&(s[0] != f) do
    s.unshift(s.pop)
  end
  idx = (t == 2) ? s[1] - 1 : s[-1] - 1
when 3,4
  s = [1,2,6,5]
  while (s.include?(f))&&(s[0] != f) do
    s.unshift(s.pop)
  end
  idx = (t == 3) ? s[1] - 1 : s[-1] - 1
else
  puts "No"
end
dt[2] = d1[idx]
dt[3] = d1[5-idx]
puts (dt == d2) ? "Yes" : "No"

Measured memory_bytes: 8616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  int n, k;
  cin >> n >>k;
  string s;
  cin >> s;
  if(s[k-1]=='A') s[k-1]='a';
  if(s[k-1]=='B') s[k-1]='b';
  if(s[k-1]=='C') s[k-1]='c';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
s = gets.chomp
t = gets.chomp

n = 0
pos = 0
t.chars.each do |c|
  while true
    if i = s.index(c, pos)
      pos = i + 1
      break
    end
    unless s.index(c)
      puts(-1)
      exit
    end
    n += 1
    pos = 0
  end
end
p n * s.length + pos


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

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();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve()
{
  LL N; cin >> N;
  LL ans = LLINF;
  int root = sqrt(N);
  REP1(i, root) 
  {
      if (N % i == 0) ans = min( ans, (N/i - 1) + (i - 1) );
  }
  cout << ans;
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Node {
    //children
    vector<int> c;
};
vector<Node> tree;
vector<int> dp;
int recursive(int i) {
    if(dp[i] >= 0) return dp[i];
    int len = tree[i].c.size();
    if(!len) {
        return dp[i] = 0;
    }
    for (int j = 0; j < len; j++) {
        dp[i] = max(dp[i], recursive(tree[i].c[j]) + 1);
    }
    return dp[i];
}
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, M, ans = -1;
    cin >> N >> M;
    tree = vector<Node>(N);
    dp = vector<int>(N);
    for(int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        tree[x].c.push_back(y);
    }
    for(int i = 0; i < N; i++) {
        dp[i] = -1;
    }
    for(int i = 0; i < N; i++) {
        ans = max(ans, recursive(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 998244353
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000

int main(void) {
	int h, w, x; cin >> h >> w >> x;
	int ans = 0;
	vector<vector<char>> c(h,vector<char>(w));

	rep(i, h) {
		rep(j, w) {
			cin >> c[i][j];
		}
	}

	rep(i, 1 << (h + w)){
		int cnt = 0;
		set<int> ch, cw;
		for (int j = 0; j < h + w; j++) {
			if (i&(1 << j)) {
				if (j < h) {
					ch.insert(j);
				}
				else {
					cw.insert(j - h);
				}
			}
		}

		rep(k, h) {
			rep(l, w) {
				if (ch.count(k)==0 && cw.count(l) == 0) {
					if (c[k][l] == '#') {
						cnt++;
					}
				}
			}
		}
		if (cnt == x) {
			ans++;
		}
	}

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


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

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max(0, min(b, d) - max(a, c)) << endl;
}

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

const int maxn = 200010;
int n, a[maxn];
unordered_map<int, int> mp;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i]; mp[a[i]]++;
    }
    sort(a + 1, a + n + 1);
    int ans = 0;
    for (int i = n; i; i--) if (mp[a[i]]) {
        mp[a[i]]--;
        for (long long j = 1; j <= 2e9; j *= 2) {
            if (j > a[i] && mp[j - a[i]]) {
                mp[j - a[i]]--, ans++; break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 29556
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string s; cin >> s;
  for(int i=0; i<s.size(); i++) {
    cout << s[i];
    if (i==3) {
      cout << ' ';
    }
  }
  cout << endl;
}

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


int main()
{
    int n, k;
    cin >> n >>k;
    double ans = 0.0;
    for(int i = 1;i <= n;i++)
    {
        if(i < k)
        {
            long long curr = i;
            int step = 0;
            while(curr < k)
            {
                step++;
                curr *= 2ll;
            }
            ans += 1.0/(double)n / pow(2,step);
            
        }
        else
        {
            ans += 1.0/(double)n;
        }
    }
    cout << fixed ;
    cout.precision(10);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long n,sum=0;
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)
	{
		if(i%3==0||i%5==0)
		{
			continue;
		}
		else
		{
			sum+=i;
		}
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 3232
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

ll board[1500][1500];
ll dp[1500][1500];

int main(void){
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>board[i+1][j+1];
            dp[i+1][j+1]=2000;
        }
    }
    for(int i=1;i<=w;i++){
        if(board[1][i])dp[1][i]=0;
        else dp[1][i]=1;
    }
    for(int i=1;i<=h;i++){
        if(board[i][1])dp[i][1]=0;
        else dp[i][1]=1;
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(board[i][j]==1)dp[i][j]=0;
            else{
                dp[i][j]=min(dp[i-1][j]+1,min(dp[i][j-1]+1,dp[i-1][j-1]+1));
            }
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    ll ans = 0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            ans = max(ans,dp[i][j]);
        }
    }
    cout<<ans*ans<<endl;
    return 0;
}


Measured memory_bytes: 35920
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    a = [int(_) for _ in input().split()]
    M = max(a)
    p = len(format(M, 'b'))
    l = [0 for _ in range(p)]
    ans = 0
    for i in range(n):
        a_s = format(a[i], '0' + str(p) + 'b')
        for c in range(p):
            if a_s[c] == '1':
                l[c] += 1
    for i in range(p):
        c1 = l[i]
        ans += (2**(p - i - 1)) * c1 * (n - c1)
        ans %= (10**9 + 7)
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

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


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

int main() {
    ll a,b,c;
    cin >> a >> b >> c;

    ll r = (c - a -b);
    if( r <=0) {
        cout << "No" << endl;
        return 0;
    }
    ll r2 = r * r;
    ll l2 = 4*a*b;

    if(l2 < r2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int INF = 1LL << 30;

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  int n, c; cin>>n>>c;
  int d[30][30];
  rep(i, c) rep(j, c) cin>>d[i][j];

  int a[3][30] = {};
  rep(i, n) rep(j, n) {
    int ct; cin>>ct; --ct;
    rep(k, c) a[(i+j)%3][k] += d[ct][k];
  }

  int ans = INF;
  rep(i, c) rep(j, c) rep(k, c) {
    if (i==j || j==k || k==i) continue;
    ans = min(ans, a[0][i]+a[1][j]+a[2][k]);
  }
  print(ans);

  return 0;
}

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


int main() {

    ll n,m; cin >> n >> m;
    if(n >= m/2) cout << m/2;
    else{
        cout << n + (m-2*n)/4;
    }
    return 0;
}











Measured memory_bytes: 3604
#include <stdio.h>
 
int main(void) {
	int num;
	double weight, height,BMI;
	while(scanf("%d,%lf,%lf",&num,&weight,&height) != EOF){
		BMI = weight/height/height;
		if(BMI>=25){
			printf("%d\n",num);
		}
 
	}
 
	return 0;
}

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

const int mod = 1000000007;

int main(){
    int n;
    cin >> n;
    long long a[n],sum = 0,ans = 0;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        sum += a[i];
    }
    for(int i = 0;i < n;i++){
        sum -= a[i];
        long long x = (a[i]%mod)*(sum%mod)%mod;
        ans = (ans + x)%mod;
    }

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


Measured memory_bytes: 4720
#include<bits/stdc++.h>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> A(n,0);
    REP(i,n) cin >> A[i];

    map<int, int> mp;
    REP(i,n) mp[A[i]]++;
    vector<pair<int, int> > nums;
    for(pair<int,int> x : mp){
        nums.push_back(x);
    }
    if(mp.size()==3){
        if( ((nums[0].first^nums[1].first) == nums[2].first) and 
            ((nums[2].first^nums[0].first) == nums[1].first) and 
            ((nums[1].first^nums[2].first) == nums[0].first) and
            (nums[0].second == nums[1].second and nums[1].second == nums[2].second)
            )
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    else if(mp.size()==2){
        sort(ALL(nums));
        // for(auto x : nums){
        //     cout << x.first << " " <<x.second << endl;
        // }
        if(nums[0].first != 0){
            cout << "No" << endl;
        }
        else{
            if(nums[0].second * 2 == nums[1].second)
                cout << "Yes" << endl;
            else
                cout << "No" << endl;
        }
    }
    else{
        if(nums[0].first == 0) 
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 5372
import math
import sys

# N, K = map(int, input().split())
# h = list(map(int, input().split()))

N = int(input())
A = str(input())
B = str(input())
C = str(input())

ans = 0
for i in range(N):
	if (A[i] != B[i] and B[i] != C[i] and A[i] != C[i]):
		ans += 2
	elif (A[i] != B[i] or B[i] != C[i] or A[i] != C[i]):
		ans += 1

print(ans)
	

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define SUBL freopen("/home/ajinkya/Desktop/input.txt","r",stdin); freopen("/home/ajinkya/Desktop/output.txt","w",stdout); 
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;




int main()
{
    fastio 
    // SUBL
  	ll a, b, c, d;
  	cin >> a >> b >> c >> d;
  	ll ans = b/c - a/c + b/d - a/d;
  	ll lcm = c*d/GCD(c,d);
  	ans -= b/lcm - a/lcm;
  	if(a%c==0) ans++;
  	if(a%d==0) ans++;
  	if(a%lcm==0) ans--;
  	cout << b - a - ans + 1;
    return 0;
}         	

Measured memory_bytes: 256
main = do
    [a, b, c] <- map read . words <$> getLine
    k <- readLn
    putStrLn $ show $ ans a b c k

ans a b c k =
    let
        maxv = foldl1 max [a, b, c]
        rec acc 0 k = acc
        rec acc n k = rec (acc * k) (n - 1) k
        tmp = rec maxv k 2
    in
        a + b + c + tmp - maxv


Measured memory_bytes: 508
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
	ll i,j,k,l,r,n,m;
	cin>>n;
	string s;
	map<string,int>m1;
	fl(i,n) {
		cin>>s;
		m1[s]++;
	}
	cout<<m1.size()<<"\n";
}

int main() {
    speedup;
    ll i=0,t;
    //cin>>t;
    t=1;
    while(t--) {
        comp();
    }
    return 0;
}

Measured memory_bytes: 19200
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;

int main(){
  long int n,m;
  long long int ans=1;
  cin>>n>>m;
  if(abs(n-m)>1){
    cout<<0<<endl;
  }
  else{
    if(n==m){
      for(int i=n;i>0;i--){
        ans=(ans*i)%1000000007;
      }
      for(int i=n;i>0;i--){
        ans=(ans*i)%1000000007;
      }
      cout<<(ans*2)%1000000007<<endl;
    }
    else{
      for(int i=max(n,m);i>0;i--){
        ans=(ans*i)%1000000007;
      }
      for(int i=min(n,m);i>0;i--){
        ans=(ans*i)%1000000007;
      }
      cout<<ans<<endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
class Node{
public:
  int location;
  int p,l,r;
  Node(){}
};
class Point {
public:
  int id,x,y;
  Point(){}
  Point(int id,int x,int y):id(id),x(x),y(y){}
  bool operator < (const Point &p)const{
    return id < p.id;
  }
  void print(){
    printf("%d\n",id);
  }
};
static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1,const Point &p2){return p1.x<p2.x;}
bool lessY(const Point &p1,const Point &p2){return p1.y<p2.y;}

int makeKDTree(int l,int r,int depth){
  if(!(l<r))return NIL;
  int mid=(l+r)/2;
  int t=np++;
  if(depth%2==0)sort(P+l,P+r,lessX);
  else sort(P+l,P+r,lessY);
  T[t].location=mid;
  T[t].l=makeKDTree(l,mid,depth+1);
  T[t].r=makeKDTree(mid+1,r,depth+1);
  return t;
}
void find(int v,int sx,int tx,int sy,int ty,int depth,vector<Point> &ans){
  int x=P[T[v].location].x;
  int y=P[T[v].location].y;

  if(sx<=x && x<=tx && sy<=y && y<=ty)ans.push_back(P[T[v].location]);

  if(depth%2==0){
    if(T[v].l!=NIL){
      if(sx<=x)find(T[v].l,sx,tx,sy,ty,depth+1,ans);
    }
    if(T[v].r!=NIL){
      if(x<=tx)find(T[v].r,sx,tx,sy,ty,depth+1,ans);
    }
  }
  else{
    if(T[v].l!=NIL){
      if(sy<=y)find(T[v].l,sx,tx,sy,ty,depth+1,ans);
    }
    if(T[v].r!=NIL){
      if(y<=ty)find(T[v].r,sx,tx,sy,ty,depth+1,ans);
    }
  }
}
int main(){
  int x,y;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d %d",&x,&y);
    P[i]=Point(i,x,y);
    T[i].l=T[i].r=T[i].p=NIL;
  }
  np=0;
  int root=makeKDTree(0,N,0);

  int q;
  scanf("%d",&q);
  int sx,tx,sy,ty;
  vector<Point> ans;
  for(int i=0;i<q;i++){
    scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
    ans.clear();
    find(root,sx,tx,sy,ty,0,ans);
    sort(ans.begin(),ans.end());
    for(int j=0;j<ans.size();j++)ans[j].print();
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 16412
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,M,a,aa,ans=0;
  cin >>N >>M;
  M*=2;
  vector<long long>A(N,0);
  for(int i=0; i<N; i++){
    cin >>a;
    A[i]=a;
  }
  aa=A[0];
  a=aa;
  for(int i=1; i<N; i++){
    long long d,b;
    d=A[i];
    b=d;
    long long c=a%b;
    while(c>0){
      a=b;
      b=c;
      c=a%b;
    }
    a=aa*d/b;
    aa=a;
//   cout<<"i:"<<i<<"a:"<<a<<" b:"<<b<<endl;
  }
  for(int i=0; i<N; i++){
    if((a/A[i])%2==0) break;
    if(i==N-1) ans=M/a-M/(a*2);
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

bool full(vector<int> &v){
    for(int a: v){
        if(a == 0) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s;
    cin >> s;
    vector<vector<int>> A(s.size(), vector<int>(26));
    vector<int> cnt(26);
    int grp = 0;
    for(int i = (int)s.size() - 1; i >= 0; i--) {
        cnt[(s[i] - 'a')]++;
        if(full(cnt)){
            cnt.assign(26, 0);
            grp++;
        }
        A[i] = cnt;
    }
    string ans = "";
    rep(i, s.size()){
        int ind = -1;
        rep(j, 26){
            if(A[i][j] == 0) {
                ind = j;
                ans += 'a' + j;
                break;
            }
        }
        while(s[i] != 'a' + ind && i < s.size()) {
            i++;
        }
    }
    output(ans);
    
    return 0;
}

Measured memory_bytes: 27028
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {



		Scanner scan = new Scanner(System.in);

		String chara = scan.nextLine();

		if(Character.isUpperCase(chara.charAt(0))) {
			System.out.println("A");
		}else {
			System.out.println("a");
		}
		scan.close();

	}

}


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


template<typename T, typename E>
struct SegmentTree {
    using F = function<T(T, T)>;
    using G = function<T(T, E)>;
    using H = function<E(E, E)>;
    int n, height;
    F f;
    G g;
    H h;
    T ti;
    E ei;
    vector<T> dat;
    vector<E> laz;
    SegmentTree(F f, G g, H h, T ti, E ei) : f(f), g(g), h(h), ti(ti), ei(ei){}
    void init(int n_){
        n = 1; height = 0;
        while(n < n_) n<<=1, height++;
        dat.assign(2*n, ti);
        laz.assign(2*n, ei);
    }
    void build(const vector<T>& v){
        int n_ = v.size();
        init(n_);
        for(int i = 0;i < n_;i++) dat[n+i] = v[i];
        for(int i = n-1;i;i--) dat[i] = f(dat[(i<<1)|0], dat[(i<<1)|1]);
    }
    inline T reflect(int k){
        return laz[k] == ei ? dat[k] : g(dat[k], laz[k]);
    }
    inline void propagate(int k){
        if(laz[k] == ei) return;
        laz[(k<<1)|0] = h(laz[(k<<1)|0], laz[k]);
        laz[(k<<1)|1] = h(laz[(k<<1)|1], laz[k]);
        dat[k] = reflect(k);
        laz[k] = ei;
    }
    inline void thrust(int k){
        for(int i = height;i;i--) propagate(k>>i);
    }
    inline void recalc(int k){
        while(k>>=1) dat[k] = f(reflect((k<<1)|0), reflect((k<<1)|1));
    }
    //0-indexed [a, b)
    void update(int a, int b, E x){
        if(a >= b) return;
        thrust(a+=n);
        thrust(b+=n-1);
        for(int l = a, r = b+1;l < r;l>>=1, r>>=1){
            if(l&1) laz[l] = h(laz[l], x), l++;
            if(r&1) --r, laz[r] = h(laz[r], x);
        }
        recalc(a);
        recalc(b);
    }
    void setVal(int a, T x){
        thrust(a+=n);
        dat[a] = x; laz[a] = ei;
        recalc(a);
    }
    //0-indexed [a, b)
    T query(int a, int b){
        if(a >= b) return ti;
        thrust(a+=n);
        thrust(b+=n-1);
        T vl = ti, vr = ti;
        for(int l = a, r = b+1;l < r;l>>=1, r>>=1){
            if(l&1) vl = f(vl, reflect(l++));
            if(r&1) vr = f(reflect(--r), vr);
        }
        return f(vl, vr);
    }
    //0-indexed
    T operator[](int i){
        return query(i, i+1);
    }
};


int n, q;


signed main(){
    cin >> n >> q;
    auto f = [](pair<int, int> a, pair<int, int> b){ return make_pair(a.first+b.first, a.second+b.second); };
    auto g = [](pair<int, int> a, int b){ return make_pair(a.first+a.second*b, a.second); };
    auto h = [](int a, int b){ return a+b; };
    SegmentTree<pair<int, int>, int> seg(f, g, h, make_pair(0, 1), 0);
    seg.build(vector<pair<int, int>>(n, make_pair(0, 1)));
    while(q--){
        int qt, s, t;
        cin >> qt >> s >> t;
        s--;
        if(qt == 0){
            int x;
            cin >> x;
            seg.update(s, t, x);
        }
        else cout << seg.query(s, t).first << endl;
    }

    return 0;
}


Measured memory_bytes: 10428
#include <bits/stdc++.h>
using namespace std;
long long ans;
int fa[200005];
int n,i,a[200005],vis[200005],par[200005];
int fnd(int x){
	if(fa[x]==x) return x;
	return fa[x]=fnd(fa[x]);
}
struct node{
	int s0,s1;
}cur[200005];
bool operator <(node x,node y){
	return 1ll*x.s1*y.s0>1ll*y.s1*x.s0;
}
void add(node x,node y){
	ans+=1ll*x.s1*y.s0;
}
priority_queue<pair<node,int> > pq;
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		fa[i]=i;
	}
	for(i=2;i<=n;i++){
		scanf("%d",&par[i]);
	}
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		cur[i]=(node){a[i]==0,a[i]==1};
		if(i!=1) pq.push(make_pair(cur[i],i));
	}
	for(i=1;i<n;){
		int x=pq.top().second;
		node tmp=pq.top().first;
		pq.pop();
		if(vis[x]) continue;
		if(cur[x].s0!=tmp.s0) continue;
		if(cur[x].s1!=tmp.s1) continue;
		i++;
		int f=fnd(par[x]);
		add(cur[f],cur[x]);
		fa[x]=f;
		cur[f].s0+=cur[x].s0;
		cur[f].s1+=cur[x].s1;
		vis[x]=1;
		if(f!=1){
			pq.push(make_pair(cur[f],f));
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 9076
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int n;
    cin >> n;
    vector<P> pairs(n);
    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        pairs[i] = pair<int,int>(b,a);
    }
    sort(pairs.begin(),pairs.end());
    int times=0;
    for(int i=0;i<n;i++){
        times += pairs[i].second;
        if(times>pairs[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LB lower_bound
#define UB upper_bound
#define EQ equal_range
#define prako ios::sync_with_stdio(0); cin.tie(0);
#define deb(x) cout<<x<<"\n";
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
typedef long long int ll;
typedef pair<int,int> pi;
#define rep(i,a,b) for(ll i=a; i<=b; i++)

void solve(){
	string n;cin>>n;
	ll sum=0;
	rep(i,0,n.size()-1){
		sum+=(int)n[i]-48;
	}
	if(sum%9==0) cout<<"Yes"<<"\n";
	else cout<<"No"<<"\n";
}
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    prako
    solve();
	return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    int A[N];
    int ans[N];
    
    for(int i = 0; i <= N;i++){
        
        ans[i] = 0;
        
    }
    
    for(int i = 2; i <= N;i++){
        
        cin >> A[i];
        
    }
    
    for(int i = 2; i <= N; i++){
        
        ans[A[i]]++;
        
    }
    
    for(int i = 1; i <= N; i++){
        
        cout << ans[i] << endl;
        
    }
    
    
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

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

    int S = pow(100, D);

	if (N <= 99) {
		cout << S * N << endl;
	}else{
		cout << S * 101 << endl;
	}
    
    return 0;
}

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

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

    if(b - a + 1 < 2 * k){
        for(int i=a; i<=b; ++i)
            cout << i << endl;
    }
    else{
        for(int i=a; i<a+k; ++i)
            cout << i << endl;
        for(int i=b-k+1; i<=b; ++i)
            cout << i << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
i = map(int, input().split())
i = list(i)

grey = 0
brown = 0
green = 0
cyan = 0
blue = 0
yellow = 0
orange = 0
red = 0

minimo = 0
maximo = 0
coresLivres = 8

for valor in i:
    if 1 <= valor <= 399:
        if grey == 0:
            minimo += 1
            coresLivres -= 1
        grey += 1
    elif 400 <= valor <= 799:
        if brown == 0:
            minimo += 1
            coresLivres -= 1
        brown += 1
    elif 800 <= valor <= 1199:
        if green == 0:
            minimo += 1
            coresLivres -= 1
        green += 1
    elif 1200 <= valor <= 1599:
        if cyan == 0:
            minimo += 1
            coresLivres -= 1
        cyan += 1
    elif 1600 <= valor <= 1999:
        if blue == 0:
            minimo += 1
            coresLivres -= 1
        blue += 1
    elif 2000 <= valor <= 2399:
        if yellow == 0:
            minimo += 1
            coresLivres -= 1
        yellow += 1
    elif 2400 <= valor <= 2799:
        if orange == 0:
            minimo += 1
            coresLivres -= 1
        orange += 1
    elif 2800 <= valor <= 3199:
        if red == 0:
            minimo += 1
            coresLivres -= 1
        red += 1
    else:
        maximo += 1
 
if coresLivres == 8:
    print(1, maximo)

else:
    print(minimo, minimo+maximo)

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

using namespace std;

int a[100000];

int main(){
    int N; cin >> N;
    for(int i = 0 ; i < N ; i ++) cin >> a[i];
 
    map<int , int> mp;
    for(int i = 0 ; i < N ; i ++) mp[a[i]]++;
    
    int ans = 0;
    
    for(auto p : mp){
        int x = p.first;
        int y = p.second;
        if(y < x) ans += y;
        else ans += y - x;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
int main() {
  int n;
  	cin>>n;
  //long long int sum=0;
  vector<long long int>vec(n);
  
  for(int i=0;i<n;i++){
	long long int a;
    	cin>>a;
    vec[i]=a;
  }
  //ここまではいい
  
  sort(vec.begin(), vec.end());
  
  vector<long long int>A(n);
  vector<long long int>B(n);
  //ここまではいい
  
  A[0]=vec[0];
  B[n-1]=vec[n-1];  
  
    for(int j=1;j<n;j++){
	A[j]=__gcd(A[j-1],vec[j]);
      //cout<<A[j];
     }
  
  for(int j=n-2;j>=0;j--){
    B[j]=__gcd(B[j+1],vec[j]);
     //cout<<B[j]<<endl;
  }
  for(int i=0;i<n;i++){
    //cout<<A[i]<<B[i]<<endl;
  }
  vector<long long int>C(n);
  C[0]=B[1];
  C[n-1]=A[n-2];
  for(int i=1;i<n-1;i++){
    C[i]=__gcd(B[i+1],A[i-1]);
    //cout<<C[i]<<endl;
}
 //for(int i=0;i<n;i++){
	//cout<<C[i]<<endl;
 // }
  sort(C.begin(), C.end());
  cout<<C[n-1]<<endl;
  //cout<<__gcd(B[2],A[0])<<endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    string S;
    cin >> S;

    int W = 0, B = 0;
    int len = S.size();

    int ans = 0;
    int res = 0;

    for(int i = S.size() - 1; i > 0; i--){
        if(S[i] != S[i-1]) res++;
    }

    for(int i = 0; i < S.size() - 1; i++){
        if(S[i] != S[i+1]) ans++;
    }

    cout << min(ans, res) << endl;

}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
    int i,j,n,flag = 0;
    scanf("%d",&n);
    
    for(i = 1; i <= 9; i++){
        for(j = 1; j <= 9; j++){
            if(n == i*j){
                flag = 1;
                break;
            }
        }
    }
    if(flag == 1) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M,C,n=0,ans=0;
  cin>>N>>M>>C;
  
  int B[M],A[N][M];
      for(int i=0;i<M;i++){
      cin>>B[i];
      }
  
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>A[i][j];
    }
  }
  
  for(int i=0;i<N;i++){
    n=0;
    for(int j=0;j<M;j++){
      n+=A[i][j]*B[j];
    }
    if((n+C)>0)
      ans++;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  string s;
  int k;
  cin >> s >> k;
  
  vector<string> x;
  for(int i = 0; i < s.size(); i++){
    for(int j = 1; j <= 5; j++){
      x.push_back(s.substr(i, min(j, (int) s.size() - i)));
    }
  }
  
  sort(x.begin(), x.end());
  
  if(k == 1){
    cout << x.at(0) << endl;
    return 0;
  }
  
  int count = 1;
  for(int i = 1; i < x.size(); i++){
    if(x.at(i - 1) != x.at(i)) count++;
    if(count == k){
      cout << x.at(i) << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
    int N;
    LL W;
    cin >> N >> W;
    LL dp[N+1][W+1];
    for(int i=0;i<N+1;i++){
        for(int j=0;j<W+1;j++){
            dp[i][j]=0;
        }
    }
    LL v[N],w[N];
    for(int i=0;i<N;i++){
        cin >> v[i] >> w[i];
    }
    for(int i=1;i<N+1;i++){
        for(int j=1;j<W+1;j++){
            if(0<=(j-w[i-1])&&(j-w[i-1])<=W){
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
            }
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector< vector<ll> > cnt(10, vector<ll>(10, 0));
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        string s = to_string(i);
        cnt[s.front() - '0'][s.back() - '0']++;
    }

    ll ans = 0;
    for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 10; ++j) {
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << "\n";
    return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n, m; cin >> n >> m; vector<vector<int>>d(n, vector<int>(n, INF));
	vector<int>a(m), b(m), c(m);
	rep(i, 0, n)d[i][i] = 0;
	rep(i, 0, m) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
		d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]);
		d[b[i]][a[i]] = min(d[b[i]][a[i]], c[i]);
	}
	rep(k, 0, n) {
		rep(i, 0, n) {
			rep(j, 0, n) {
				d[i][j] = min(d[i][j], d[i][k]+ d[k][j]);
			}
		}
	}
	int ans = m;
	rep(i, 0, m) {
		bool check = false;
		rep(j, 0, n) {
			if (d[j][a[i]] + c[i] == d[j][b[i]])check = true;
		}
		if (check)ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 2147483647
#include <math.h> /* M_PI */
int main()
{
    int a, b, m;
    cin >> a >> b >> m;
    ll min1 = INF;
    vector<ll> A(a);
    vector<ll> B(b);
    ll min2 = INF;
    ll min3 = INF;
    rep(i, a)
    {
        ll a = 0;
        cin >> a;
        A[i] = a;
        min2 = min(A[i], min2);
    }
    rep(i, b)
    {

        cin >> B[i];
        min3 = min(B[i], min3);
    }
    rep(i, m)
    {
        ll x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        ll u = A[x] + B[y] - c;
        min1 = min(min1, u);
    }
    cout << min(min1, min2 + min3);
}


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

int main() {
    auto char_repeat = [](char c, int count) {
        string ret = "";
        for (int i = 0; i < count; i++) {
            ret += c;
        }
        return ret;
    };

    string n;
    cin >> n;
    for (char c : n) {
        string tmp = char_repeat(c,3);
        if(n.find(tmp) != string::npos){
            cout <<"Yes"<<endl;
            return 0;
        }
    }
    cout << "No"<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split())) 
y = list(map(int, input().split()))
c = [abs(x[i]-y[i]) for i in range(n)]
for p in range(1, 4):
  ans = 0
  for s in c:
    ans += s**p
  print("{:.6f}".format(ans**(1/p)))
print("{:.6f}".format(max(c)))


Measured memory_bytes: 5652
A, B, C, K = map(int, input().split()) #A,B,C,Kの入力
total = 0

while K > 0:
    if A > 0:
        if K > A:
            total = total + A
            K = K - A
            A = 0;
        else:
            total = total + K
            K = 0
            A = A - K
    elif B > 0:
        if K > B:
            K = K - B
            B = 0;
        else:
            K = 0
            B = B - K
    elif C > 0:
        if K > C:
            total = total - C
            K = K - C
            C = 0;
        else:
            total = total - K
            K = 0
            C = C - K

print(total)


Measured memory_bytes: 9140