akhauriyash/Code-Regression huggingface dataset:
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	set := make(map[int]int)
	for i := 0; i < N; i++ {
		set[sc.nextInt()]++
	}
	ans := 0
	for key, count := range set {
		if count == key {
			continue
		} else if count < key {
			ans += count
		} else {
			ans += count - key
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N-1);
  vector<int> B(N);
  for(int i = 0; i < N-1; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  for(int i = 0; i < N-1; i++) {
    B.at(A.at(i)-1)++;
  }
  for(int i = 0; i < N; i++) {
    cout << B.at(i) << endl;
  }
}



Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
   ll n,k;
   cin>>n>>k;
   unordered_map<ll,ll> m;
   while(k--)
   {
      ll di;
      cin>>di;
      while(di--)
      {
          ll x;
          cin>>x;
          m[x]++;
      }
   }
   ll ans=0;
   for(ll i=1;i<=n;i++)
   {
       if(m[i]==0)
       {
           ans++;
       }
   }
   cout<<ans;
   return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
ll n,a,b,c,d,e;
str s1,s2,s3;
int main() 
{

 fast();
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt","w",stdout);
  // #endif
  cin >>s1;
  if(s1=="Sunny")
  {
    cout<<"Cloudy";
  }
 else if(s1=="Cloudy")
  {
    cout<<"Rainy";
  }
  else
    cout<<"Sunny";
 
  cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256
def f(M,A):
  c=0
  s=sum(A)
  for a in A:
    if a>=s/4/M:c+=1
    if c>=M:return("Yes")
  return("No")
N,M=map(int,input().split())
A=[int(x) for x in input().split()]
s=sum(A)
print(f(M,A))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using ll=long long int;
using namespace std;

template <typename t>
void print(const t & v){
    for (auto i :v)
        cout << i << " ";
    cout << endl;
}

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

    int i=0, j=0;
    while (i<m.size() or  j< n.size()){
        if (j < m.size () ){ 
            s.push_back (m[j]) ;
        }
        if ( i < n.size() ){
            s.push_back(n[i]);
        }
        i++ ; 
        j++ ;
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
n,m,q = map(int,input().split())
abcd = [list(map(int,input().split())) for i in range(q)]
ls = [1]
ans=0
def dfs(n,m,i,ls):
    global ans
    global abcd
    temp=0
    if len(ls)==n:
        for j in abcd:
            if ls[j[1]-1] - ls[j[0]-1] == j[2]:
                temp+=j[3]
        ans=max(ans,temp)
    else:
        for j in range(i,m+1):
            dfs(n,m,j,ls+[j])
dfs(n,m,1,ls)
print(ans)

Measured memory_bytes: 71380
#include <iostream>
using namespace std;
 
int main()
{
  int a,b,c,d;
  cin >> a>>b>>c>>d;
  string ans;
  if(a+b==c+d) ans="Balanced";
  if(a+b>c+d) ans="Left";
  if(a+b<c+d) ans="Right";
  cout<< ans <<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF (9223372036854775807LL)
#define EPS (1e-10)
#define endl ('\n')
//#define MOD 1000000007LL
#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[](auto f,auto... args){return f(f,args...);};

int main(){
    lint n,m;
    cin>>n>>m;
    if(abs(n-m)<=1){
        cout<<"Brown"<<endl;
    }else{
        cout<<"Alice"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;
char grid[1005][1005];
# define pii pair<int,int>

int shortestPath[1005][1005];
int R, C;
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};

bool inside(int r, int c){
  return 0<=r && r<R && 0<=c && c<C;
}

int bfs(){
  queue<pii> q;
  memset(shortestPath, -1, sizeof(shortestPath));

  for(int i=0; i<R; i++){
    for(int j=0; j<C; j++){
      if(grid[i][j] == '#'){
        shortestPath[i][j] = 0;
        q.push(make_pair(i, j));
      }
    }
  }
  
  int ans = 0;
  while(!q.empty()){
    pii now = q.front(); q.pop();
    int row = now.first;
    int col = now.second;

    ans = max(ans, shortestPath[row][col]);

    for(int d = 0; d < 4; d++){
      int nxr = row+dx[d];
      int nxc = col+dy[d];
      if(!inside(nxr, nxc)) continue;
      if(shortestPath[nxr][nxc] != -1) continue;
      shortestPath[nxr][nxc] = shortestPath[row][col] + 1;
      q.push(make_pair(nxr, nxc));
    }
  }

  return ans;
}

int main() {
  cin >> R >> C;
  for(int i=0; i<R; i++){
    for(int j=0; j<C; j++){
      cin >> grid[i][j];
    }
  }

  cout << bfs() << endl;
}

Measured memory_bytes: 16184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
bool isPrime(int x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(){
    string n;
    cin >> n;
    if(n[n.size()-1]=='2'||n[n.size()-1]=='4'||n[n.size()-1]=='5'||n[n.size()-1]=='7'||n[n.size()-1]=='9')    cout << "hon" << endl;
    else if(n[n.size()-1]=='3')   puts("bon");
    else    puts("pon");

    return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define dump(x) cerr << #x << " : " << x << '\n'

bool solve() {
    int N; cin >> N;
    vector<int> H(N);
    rep(i, 0, N) cin >> H[i];
    H[0]--;
    rep(i, 1, N) {
        int dif = H[i-1] - H[i];
        if(dif >= 1) return false;
        else if(dif == 0) continue;
        else H[i]--;
    }
    return true;
}

int main() {
    cout << (solve() ? "Yes" : "No") << '\n';
    return 0;
}


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

#include <iostream>
#include <string>
using namespace std;

int A, B, T;
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> A >> B >> T;

	long long ans = 0;
	for(int t=A; t <= T; t += A){
		ans += B;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

char map[50][50];
bool memoB[50][50];
bool memoW[50][50];

void search(int x, int y, int w, int h, char color) {
  if (color == 'B') memoB[x][y] = true;
  else memoW[x][y] = true;

  if (x > 0 && map[x-1][y] == '.') {
    if ((color == 'B' && !memoB[x-1][y]) || (color == 'W' && !memoW[x-1][y])) {
      search(x-1, y, w, h, color);
    }
  }
  if (y > 0 && map[x][y-1] == '.') {
    if ((color == 'B' && !memoB[x][y-1]) || (color == 'W' && !memoW[x][y-1])) {
      search(x, y-1, w, h, color);
    }
  }
  if (x < w-1 && map[x+1][y] == '.') {
    if ((color == 'B' && !memoB[x+1][y]) || (color == 'W' && !memoW[x+1][y])) {
      search(x+1, y, w, h, color);
    }
  }
  if (y < h-1 && map[x][y+1] == '.') {
    if ((color == 'B' && !memoB[x][y+1]) || (color == 'W' && !memoW[x][y+1])) {
      search(x, y+1, w, h, color);
    }
  }
}

int main() {
  int w, h, cntB, cntW, resB, resW;
  char tmp;
  string s;
  while (cin >> w >> h, w | h) {
    cntB = cntW = 0;
    for (int j = 0; j < h; j++) {
      cin >> s;
      for (int i = 0; i < w; i++) {
        tmp = s[i];
        map[i][j] = tmp;
        if (tmp == '.') memoB[i][j] = memoW[i][j] = false;
        if (tmp == 'B') memoB[i][j] = true, memoW[i][j] = false, cntB++;
        if (tmp == 'W') memoB[i][j] = false, memoW[i][j] = true, cntW++;
      }
    }
    for (int i = 0; i < w; i++) {
      for (int j = 0; j < h; j++) {
        if (map[i][j] != '.')search(i, j, w, h, map[i][j]);
      }
    }
    resB = resW = 0;
    for (int i = 0; i < w; i++) {
      for (int j = 0; j < h; j++) {
        if (memoB[i][j] && !memoW[i][j]) resB++;
        if (!memoB[i][j] && memoW[i][j]) resW++;
      }
    }
    cout << resB-cntB << " " << resW-cntW << el;
  }
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
using namespace std;
int n,i,j,e,c,m,k,a,b;
int main(){
  cin>>n;
  vector<vector<int>> x(2,vector<int>(n));
  for(;i<2;i++)for(j=0;j<n;j++)cin>>x[i][j];
  while(k<n){
    c=0;
    a=0;b=0;
    for(i=0;i<=n;i++){
      c+=x[a][b];
      if(i==k)a++;
      else b++;
    }
    k++;
    m=max(m,c);
  }
  cout<<m;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
ll n, q, s[N], sa[N+1];
V<ll> a;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q;
  FOR(i, 0, n){
    ll t;
    cin >> t;
    a.pb(t*3);
    sa[i+1] = sa[i] + a[i];
  }
  s[0] = a[0];
  s[1] = a[1];
  FOR(i, 2, n) s[i] = s[i-2] + a[i];
  FOR(i, 0, q){
    ll x;
    cin >> x;
    x = x*3-1;
    ll l = -1, r = (ll)100*IINF, m;
    while(r>l+1){
      m=(r+l)/2;
      auto it1 = upper_bound(all(a), x+m);
      auto it2 = lower_bound(all(a), x-m);
      if(a.end() - it1 >= it1 - it2){
        l = m;
      }else{
        r = m;
      }
    }
    auto it1 = upper_bound(all(a), x+l);
    auto it2 = lower_bound(all(a), x-l);
    ll su = sa[n] - sa[it1-a.begin()];
    if(a.end()-it1 == it1-it2){
      if(it2 != a.begin()) su += s[(it2-a.begin())-1];
    }else{
      if(it2-a.begin() > 1) su += s[(it2-a.begin())-2];
    }
    printf("%lld\n", su/3);
  }
}

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

def judge(x):
    B = [A[i] for i in range(N) if i!=x]
    now = A[x]
    
    for Bi in B:
        if Bi>2*now:
            return False
            
        now += Bi
    
    return True

def binary_search():
    l, r = 0, N-1
    
    while l<=r:
        m = (l+r)//2
        
        if judge(m):
            r = m-1
        else:
            l = m+1
    
    return l
    
N = int(input())
A = list(map(int, input().split()))
A.sort()
print(N-binary_search())

Measured memory_bytes: 158768
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n = get_int()
    W = get_li()
    lower = W[0]
    upper = sum(W[1:])
    ans = abs(lower - upper)
    for w in W[1:-1]:
        lower += w
        upper -= w
        ans = min(ans, abs(lower - upper))
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


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

const double PI = acos(-1);

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int x;
    cin >> x;

    pair<double, double> c(0.0, 0.0);
    double dist = 1.0;
    double a;
    a = 0.0;
    c.first = dist * cos(a);
    c.second = dist * sin(a);
    // cout << c.first << ' ' << c.second << '\n';
    int cnt = 1;
    while (true) {
        int angle = (x * cnt) % 360;
        double rad = (double)angle * PI / 180.0;
        if (angle == 90 || angle == 270) c.first += dist * 0;
        else c.first += dist * cos(rad);
        if (angle == 0 || angle == 180) c.second += dist * 0;
        else c.second += dist * sin(rad);
        // cout << c.first << ' ' << c.second << '\n';
        cnt++;
        double eX = abs(0 - c.first);
        double eY = abs(0 - c.second);
        if (eX <= (double)1e-10 && eY <= (double)1e-10) break ;
    }

    cout << cnt << '\n';
    return 0;
}

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

int main() {
#ifdef HOME
    freopen("dat.in", "r", stdin);
    freopen("dat.out", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string str, t;
    int n, ant, mn, l;

    mn = 2e9;

    cin >> t;
    for (char ch = 'a'; ch <= 'z'; ++ch) {
        bool flag = true;

        str = t; n = t.size();

        for (int i = 0; i < n; ++i)
            if (str[i] == ch)
                flag = false;

        if (flag)
            continue;

        flag = true;
        for (ant = 0; flag && n; ++ant, --n) {
            flag = false;
            flag|= (str[n - 1] != ch);
            for (int i = 0; i < n - 1; ++i) {
                if (str[i + 1] == ch && str[i] != ch) {
                    str[i] = ch;
                    flag = true; } } }

        mn = min(mn, ant - 1); }
    cout << max(mn, 0) << '\n';

    return 0; }


Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))
s = 0
ans =10**6
a,b = min(li),max(li)
for i in range(a,b+1):
    for j in range(len(li)):
        s += (i-li[j])**2
    ans = min(ans,s)
    s = 0

print(ans)
    

Measured memory_bytes: 3060
/* Author : Harshit Jain a.k.a. iharshit009 */
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define sortrev(x)       sort(all(x), greater<int>())
#define debug(x)         cout << '>' << #x << ':' << x << endl;
#define int              long long
#define ld               long double
#define endl 			 "\n";
#define mp 				 make_pair
#define pii 			 <int, int>
#define lb 				 lower_bound
#define ub				 upper_bound
#define len(a)           int((a).size())
#define prec(n)          fixed<<setprecision(n)
#define cnt(n)           __builtin_popcountll(n)
#define pi               pair<int, int>
const int mod = 1000000007;
using namespace std;
using namespace std::chrono;
// const int N = 1e5 + 5; 
// int n;
// int a[N];



int32_t main(){
auto start = high_resolution_clock::now(); // starting clock
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
t = 1;
// cin >>t;
while(t--){

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

while(a>=b){
	b = b*2;
	k--;
}
if(k < 0){
	cout << "No" ;
	return 0;
}
while(b>=c){
	c = c*2;
	// debug(c)
	// debug(b)
	k--;
}
// debug(k)
if(k<0){
	cout << "No";
	return 0;
}
else{
	cout << "Yes";
	return 0;
}









}
auto stop = high_resolution_clock::now(); // stop clock
auto duration = duration_cast<microseconds>(stop - start);  // printing duration
cerr << "Time taken by function: " << duration.count() << " milliseconds" << endl; 
return 0;
}

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

namespace ConsoleApp1
{
    static class CDaydream
    {        
        static void Main(string[] args)
        {
            const string DREAM = "dream";
            const string DREAMER = "dreamer";
            const string ERASE = "erase";
            const string ERASER = "eraser";
            
            var s = Console.ReadLine();
            string reverseS = s.ReverseString();

            while (reverseS.Length > 0)
            {
                if (reverseS.SafeSubstring(0, DREAM.Length) == DREAM.ReverseString())
                {
                    reverseS = reverseS.Substring(DREAM.Length);
                    continue;
                }
                if (reverseS.SafeSubstring(0, DREAMER.Length) == DREAMER.ReverseString())
                {
                    reverseS = reverseS.Substring(DREAMER.Length);
                    continue;
                }
                if (reverseS.SafeSubstring(0, ERASE.Length) == ERASE.ReverseString())
                {
                    reverseS = reverseS.Substring(ERASE.Length);
                    continue;
                }
                if (reverseS.SafeSubstring(0, ERASER.Length) == ERASER.ReverseString())
                {
                    reverseS = reverseS.Substring(ERASER.Length);
                    continue;
                }
                Console.WriteLine("NO");
                Console.ReadLine();
                return;
            }

            Console.WriteLine("YES");
            Console.ReadLine();
        }

        static string ReverseString(this string s)
        {
            return string.Join("", s.Reverse());
        }

        static string SafeSubstring(this string s, int start, int len)
        {
            if (s.Length < len)
            {
                return s;
            }
            return s.Substring(0, len);
        }

    }
}

Measured memory_bytes: 32848
#include <iostream>

using namespace std;

int main(void){
  bool flag = true;
  int cnt = 0;
  while(flag){
    int x;
    cnt++;
    cin >> x;
    if(x == 0) flag = false;
    else{
      cout << "Case " << cnt << ": " << x << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3068
N,K = map(int,input().split())
s = list(map(int,input()))
s.append(2)
start = s[0]
number = 1
choku = []
saka = [0]
for i in range(N):
    if s[i] == s[i+1]:
        number += 1
    else:
        if s[i] == 0:
            choku.append(number)
            number = 1
        else:
            saka.append(number)
            number = 1
choku.append(0)
saka.append(0)
while(1):
    max_align = 0
    m = len(choku)
    n = len(saka)
    if m <= K:
        print(N)
        break
    if start == 0: #最初が直立の場合
        aligns = [sum(choku[0:K]) + sum(saka[0:K+1])]
        for i in range(m-K-1):
            aligns.append(aligns[i] -choku[i]-saka[i] + choku[i+K] + saka[i+K+1])
        print(max(aligns))
    else:
        aligns = [sum(choku[0:K]) + sum(saka[1:K+2])]
        for i in range(m-K-1):
            aligns.append(aligns[i] -choku[i]-saka[i+1] + choku[i+K] + saka[i+K+2])
        print(max(aligns))
    break


Measured memory_bytes: 6296
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

S = input()

cnt1, cnt2 = 0, 0
for i, c in enumerate(S):
    if i % 2 == 0:
        if c == '1':
            cnt1 += 1
        else:
            cnt2 += 1
    else:
        if c == '1':
            cnt2 += 1
        else:
            cnt1 += 1
print(min(cnt1, cnt2))


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

typedef long long ll;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    int N;
    cin >> N;
    ll A, B;
    map<pair<ll, ll>, int> m;
    rep(i, N) {
        cin >> A >> B;
        if (A == 0 && B == 0) {
            m[make_pair(0, 0)]++;
        } else if (A == 0) {
            m[make_pair(0, 1)]++;
            m[make_pair(1, 0)]++;
            m[make_pair(1, 0)]--;
        } else if (B == 0) {
            m[make_pair(1, 0)]++;
            m[make_pair(0, 1)]++;
            m[make_pair(0, 1)]--;
        } else {
            ll G = gcd(abs(A), abs(B));
            A /= G;
            B /= G;
            if (A < 0) {
                A = -A;
                B = -B;
            }
            m[make_pair(A, B)]++;
            if (B < 0) {
                A = -A;
                B = -B;
            }
            m[make_pair(B, -A)]++;
            m[make_pair(B, -A)]--;
        }
    }
    ll ans = 1, MOD = 1e9 + 7;
    for (auto i : m) {
        ll a = i.first.first, b = i.first.second, c = i.second;
        if (b <= 0) continue;
        //out << "a=" << a << " b=" << b << "\n";
        ll d = m[make_pair(b, -a)];
        ll x = 1, y = 1;
        //cout << c << " " << d << "\n";
        rep(i, c) x = (x * 2) % MOD;
        rep(i, d) y = (y * 2) % MOD;
        ans = (ans * (x + y - 1)) % MOD;
    }
    cout << (ans - 1 + MOD + m[make_pair(0, 0)]) % MOD << "\n";
}

Measured memory_bytes: 28500
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
A = LI()
money,stock = 1000,0
temp = A[0]
for i in range(1,N):
    if temp<A[i]:
        add_stock = money//A[i-1]
        money -= A[i-1]*add_stock
        stock += add_stock
    if temp>A[i]:
        if stock:
            money += A[i-1]*stock
            stock = 0
    if i==N-1:
        if stock:
            money += A[i]*stock
    temp = A[i]
print(money)


Measured memory_bytes: 9016
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    if (fopen("Test.INP", "r"))
        freopen("Test.INP", "r", stdin);

    int n, k;
    cin >> n >> k;

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

    int dp[n];
    dp[0] = 0;

    for (int i = 1; i < n; ++i)
    {
        dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
        for (int j = 2; j <= k; ++j)
            if (i >= j)
                dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
    }

    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        long A = long.Parse(Console.ReadLine());
        long B = long.Parse(Console.ReadLine());
        if(A == B){
            sb.Append("1\n");
            return;
        }
        int b;
        for(b=63;b>=0;b--){
            if(((((long)1 << b) & A) == 0) && ((((long)1 << b) & B) != 0)){
                long temp = A;
                A = B;
                B = temp;
                break;
            }
            else if(((((long)1 << b) & A) != 0) && ((((long)1 << b) & B) == 0)){
                break;
            }
            else if(((((long)1 << b) & A) != 0) && ((((long)1 << b) & B) != 0)){
                A -= (long)1 << b;
                B -= (long)1 << b;
            }
        }
        long count = ((long)1 << b) - B;
        int c;
        for(c = b-1;c >= 0;c--){
            if(((((long)1 << c) & A) != 0)){
                break;
            }
        }
        long C = ((long)1 << (c+1));
        count += Math.Min((long)1 << b,count + C);
        sb.Append(count+"\n");
    }
}

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

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

  int a, left=0;
  for (int i=0; i<m; i++) {
    cin >> a;
    if(a<x)
      left++;
    else
      break;
  }

  cout << min(left,m-left) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
int main()
{
    ft
    int t,i,j,n,m,l,r;
    cin>>n>>m>>l;
    l--;
    r=min(n+l,m);
    for(i=n;i<=r;i++)
    {
        cout<<i<<"\n";
    }
    r=max(r+1,m-l);
    for(i=r;i<=m;i++)
    {
        cout<<i<<"\n";
    }
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  int a[n+2];
  a[0] = 0;
  for (int i=0; i<n; i++) cin>>a[i+1];
  a[n+1] = 0;
  long d = 0;
  for (int i=1; i<n+2; i++) {
    d += abs(a[i] - a[i-1]);
  }
  for (int i=1; i<n+1; i++) {
    cout<<d - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1])<<endl;
  }
}

Measured memory_bytes: 1664
#define DEBUG 0
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 6/11/2019, 7:10:24 PM
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
typedef long long ll;
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}
const int MAX_SIZE = 1000010;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return mint(0) - *this; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a) { return (*this *= power(MOD - 2)); }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
mint inv[MAX_SIZE];
mint fact[MAX_SIZE];
mint factinv[MAX_SIZE];
void init()
{
  inv[1] = 1;
  for (int i = 2; i < MAX_SIZE; i++)
  {
    inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
  }
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MAX_SIZE; i++)
  {
    fact[i] = mint(i) * fact[i - 1];
    factinv[i] = inv[i] * factinv[i - 1];
  }
}
mint choose(int n, int k)
{
  if (n >= 0 && k >= 0 && n - k >= 0)
  {
    return fact[n] * factinv[k] * factinv[n - k];
  }
  return 0;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// const double epsilon = 1e-10;
// const ll infty = 1000000000000000LL;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

int N;
int W[110];
int sum = 0;

int main()
{
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    cin >> W[i];
    sum += W[i];
  }
  int t = 0;
  int ans = abs(sum - t - t);
  for (auto i = 0; i < N; i++)
  {
    t += W[i];
    mins(ans, abs(sum - t - t));
  }
  cout << ans << endl;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,cnt=0;
    cin>>n;
    int a[n];
    for(long long int i;i<n;i++)
    {
        cin>>a[i];
        if(i>0)
        {
            if(a[i-1]>a[i])
                {cnt+=(a[i-1]-a[i]); a[i]=a[i-1];}
        }
    }
    cout<<cnt;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T> inline T sqr(T t) {return t*t;}
#define pb push_back
#define mp make_pair
#define endl "\n"

inline void files()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef _WIN32
        return;
    #endif // _WIN32
    //freopen("C.in", "r", stdin);freopen("C.out", "w", stdout);
}

ll d[300][300];

int n, m, r, a[100];

ll mn = 1e15;

int used[100];

bool taken[100];

void rec(int sz){
    if (sz == r){
        ll ans = 0;
        for (int i = 2; i <= r; i++){
            ans += d[used[i-1]][used[i]];
        }
        mn = min(ans, mn);
        return;
    }
    for (int j = 1; j <= r; j++)
        if (!taken[j]){
            used[sz+1] = a[j];
            taken[j] = 1;
            rec(sz+1);
            taken[j] = 0;
        }
}

int main(){
    files();
    //freopen("input.txt", "r", stdin);
    cin >> n >> m >> r;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++){
            d[i][j] = 1e12;
            if (i==j)
                d[i][j] = 0;
        }
    for (int i = 1; i <= r; i++)
        cin >> a[i];
    for (int i = 1; i <= m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = d[b][a] = c;
    }
    for (int k = 1; k <= n; k++){
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++){
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
    }
    rec(0);
    cout << mn;
}



Measured memory_bytes: 768
/** Author: Dwai
 *  Omae wa mou shindeiru!
**/

#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define fr(i,a,b) for (i = a; i <= b; i++)
#define frr(i,a,b) for (i = a; i >= b; i--)
#define rep(i,n) for (i = 0 ; i < n; i++)
#define repr(i,n) for (i = n - 1; i >= 0; i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define flushinput   cin.ignore(numeric_limits<streamsize>::max(),'\n');

void debug_out() { cerr << endl; }

void clock_out(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}

void fileio(){
  freopen("/home/dwai/Desktop/cp/input.txt","r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}

void ofileio(){
  freopen("input.txt","r", stdin);
  freopen("output.txt", "w", stdout); 
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define fio() fileio()
#define ofio() fileio()
#define clock() clock_out()
#else
#define debug(...) 42
#define fio() 42
#define ofio() ofileio()
#define clock() 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef map<ll,ll> mll;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

void solve(){
	string s;cin>>s;
	string arr[3]={"Sunny","Cloudy","Rainy"};

	int in=find(arr,arr+3,s)-arr;
	in=(in+1)%3;
	cout<<arr[in];
}

int main(){
	//fio();
	fast

	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n,d;
int main(){
    scanf("%d %d",&n,&d);
    int cnt=0;
    for(int i=1;i<=n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        ll dis=(ll)d*(ll)d;
        ll now=(ll)a*(ll)a+(ll)b*(ll)b;
        if(now<=dis) cnt++;
    }
    printf("%d\n",cnt);
        
    return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    ll b[n+1];
    for(int i = 1; i <= n-1; i++){
        cin >> b[i];
    }
    b[0] = 1000000;
    b[n] = 1000000;
    for(int i = 1; i <= n; i++){
        ans += min(b[i-1], b[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
using namespace std;
typedef long long ll;
int main() {
  string s;
  cin >> s;

  string divide[4] = {"dream", "dreamer", "erase", "eraser"};
  reverse(s.begin(), s.end());
  REP(i, 4) reverse(divide[i].begin(), divide[i].end());

  ll i = 0;
  while (i < s.size()) {
    bool ok = false;
    REP(j, 4) {
      string c = divide[j];
      if (s.substr(i, c.size()) == c) {
        i += c.size();
        ok = true;
        break;
      }
    }
    if (!ok) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

int32_t main(){_
   
   string s;      
   cin >> s;

   int n = (int)(s.size());
   if (n % 2){
      cout<<"No";
      return 0;
   }
   

   for (int i = 0; i < n; i+=2)
   {
      if(!(s[i] == 'h' and s[i+1] == 'i')){
         cout<<"No\n";
         return 0;
      }
   }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 1000000000;
const ll MOD = 1000000007;

using namespace std;

int dp[1001][1 << 12] = {};
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> mask(m + 1, 0);
  vector<int> a(m + 1);
  a[0] = 0;
  mask[0] = 0;
  FOR(i, 1, m + 1) {
    int b;
    cin >> a[i] >> b;
    REP(j, b) {
      int c;
      cin >> c;
      mask[i] = (mask[i] | (1 << (c - 1)));
    }
  }

  REP(s, (1 << n)) {
    REP(i, m + 1) { dp[i][s] = INF; }
  }
  dp[0][0] = 0;

  REP(s, (1 << n)) {
    FOR(i, 1, m + 1) {
      int ds = (s & (~mask[i]));
      dp[i][s] = min(dp[i - 1][s], dp[i - 1][ds] + a[i]);
    }
  }

  if (dp[m][(1 << n) - 1] == INF) {
    cout << -1 << endl;
  } else {
    cout << dp[m][(1 << n) - 1] << endl;
  }
}


Measured memory_bytes: 16256
def main():

    N = int(input())
    H = list(map(int, input().split()))
    dp = [float('inf') for _ in range(N)]
    dp[0] = 0
    for i in range(1, N):
        if i == 1:
            dp[i] = abs(H[i]-H[i-1])
        else:
            dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))
    return dp[N-1]

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 13976
a,b=map(int,input().split())
t=b-a+1
if a==b:
  print(a)
elif t%2:
  if a%2:
    print(((t-1)//2)%2^a)
  else:
    print(((t-1)//2)%2^b)
else:
  if a%2:
    print((t//2-1)%2^a^b)
  else:
    print((t//2)%2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main(){
    int N, K;
    cin >> N >> K;
    int X = ceil(log2(K));
    double ans = 0;

    for(int i=1; i<=N; i++) {
        if(i >= K) {
            ans += (1.0/N);
            continue;
        }
        int n = ceil(log2(K)-log2(i));
        ans += (double)pow(0.5, n)/N;
    }
    cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 4192
n, k = map(int, input().split())
D = 10**9 + 7

up = [1] * (n + 1)
down = [0] * (n + 1)
for i in range(1, n + 1):
  up[i] = (up[i - 1] * i) % D
down[n] = pow(up[n], D - 2, D)
for i in range(n, 0, -1):
  down[i - 1] = (down[i] * i) % D
  
def cmd(n, r, D):
  if r < 0 or r > n:
    return 0
  else:
    return (up[n] * down[r] * down[n - r]) % D

A = 0
k = min(k, n-1)
t = 0
while t <=k:
  A = (A + cmd(n-1, t, D) * cmd(n, t, D)) % D
  t = t+1
print (A)

Measured memory_bytes: 18804
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void *x, const void *y) {
	return *(int *)x - *(int *)y;
}
int main() {
	int n, m, d[200000], t[200000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &d[i]);
	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		scanf("%d", &t[i]);
	}
	qsort(d, n, sizeof(int), cmpint);
	qsort(t, m, sizeof(int), cmpint);
	int j = 0;
	for (int i = 0; i < n; i++) {
		if (d[i] == t[j]) {
			j++;
		}
		if (j == m) {
			break;
		}
	}
	if (j == m) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 2556
#include <stdio.h>

int n;
int a[1<<17];
int cost;
int dc[1<<17];

void read();
void calc();
void print();
int abs(int x);

int main()
{
    read();
    calc();
    print();
}

void read()
{
    int i;
    scanf("%d\n", &n);
    for (i = 1; i <= n; i++)
        scanf("%d", a+i);
}

void calc()
{
    int i;

    cost = 0;
    a[0] = 0;
    a[n+1] = 0;
    for (i = 1; i <= n+1; i++)
        cost += abs(a[i]-a[i-1]);
    for (i = 1; i <= n; i++) 
        dc[i] = abs(a[i+1]-a[i-1])
            - (abs(a[i+1]-a[i]) + abs(a[i]-a[i-1]));
}

void print()
{
    int i;

    for (i = 1; i <= n; i++)
        printf("%d\n", cost+dc[i]);
}

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


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

int main(){
	int Min = 1000000, Max = -1000000, n , i = 0, x;
	long long sum = 0;

	cin >> n;

	while(i < n){

		cin >> x;
		if(Min > x) Min = x;
		if(Max < x) Max = x;
		sum += x;
		i++;
	}

	cout << Min << " " << Max << " " << sum << endl;

	return 0;

}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,d,a;
	cin >> n >> d >> a;
	vector<pii> v(n);
	rep(i,0,n){
		cin >> v[i].first >> v[i].second;
	}
	sort(all(v));
	int dam = 0;
	queue<pii> q;
	ll ans = 0;
	rep(i,0,n){
		while(q.size() && q.front().first <= v[i].first){
			pii p = q.front();
			dam -= p.second;
			q.pop();
		}
		if(dam < v[i].second){
			int del = (v[i].second-dam+a-1)/a;
			ans += del;
			dam += del*a;
			q.push({v[i].first + 2 * d + 1,del*a});
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <string>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<unsigned long long int>;

int main(void) {
    Int n, a;
    cin >> n >> a;
    n -= 500 * (n / 500);
    if (n <= a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, ll> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

bool comp(P x, P y){
	return ((x.first == y.first)?(x.second < y.second):(x.first < y.first));
}

vector<P> v,u;

int find(ll x){
	int l = 0,r = u.l_ength(),m;
	while(r - l > 1){
		m = (l+r)/2;
		if(u[m].first < x){
			l = m;
		}else{
			r = m;
		}
	}
	return ((u[l].first < x)?r:l);
}

int main(void){
	int n,i,j,m,p;
	ll ma,mb,a[44],b[44],c[44],ans=INFLL,md,cs;
	cin >> n >> ma >> mb; m = n/2;
	for(i=0; i<n; ++i){
		cin >> a[i] >> b[i] >> c[i];
		a[i] *= mb;
		b[i] *= ma;
		a[i] -= b[i];
	}
	for(i=((1<<m)-1); i>0; --i){
		md = 0ll; cs = 0ll;
		for(j=0; j<m; ++j){
			if(i&(1<<j)){
				md += a[j];
				cs += c[j];
			}
		}
		if(md){
			v.push_back(P(md,cs));
		}else if(cs){
			ans = min(ans,cs);
		}
	}
	for(i=((1<<(n-m))-1); i>0; --i){
		md = 0ll; cs = 0ll;
		for(j=m; j<n; ++j){
			if(i&(1<<(j-m))){
				md += a[j];
				cs += c[j];
			}
		}
		if(md){
			u.push_back(P(md,cs));
		}else if(cs){
			ans = min(ans,cs);
		}
	}
	sort(u.begin(),u.end(),comp);
	if(!(u.l_ength() && v.l_ength())){
		cout << ((ans==INFLL)?-1:ans) << endl;
		return 0;
	}
	for(i=(v.l_ength()-1); i>=0; --i){
		p = find(0ll-v[i].first);
		if(!(v[i].first + u[p].first)){
			ans = min(ans,v[i].second + u[p].second);
		}
	}
	cout << ((ans==INFLL)?-1:ans) << endl;
	return 0;
}


Measured memory_bytes: 42212