akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll x[4] = {0, 1, 0, -1};
ll y[4] = {1, 0, -1, 0};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W, K;
    cin >> H >> W >> K;
    pll s, g;
    cin >> s.first >> s.second >> g.first >> g.second;
    s.first--;
    s.second--;
    g.first--;
    g.second--;

    vector<string> S(H);
    vector<vector<vector<ll>>> C(H);
    REP(i, H) {
        cin >> S[i];
    }

    REP(i, H) {
        vector<vector<ll>> v(W);
        REP(j, W) {
            v[j] = vector<ll>();
            REP(k, 4) {
                v[j].push_back(INF);
            }
        }
        C[i] = v;
    }

    queue<tuple<pll, ll>> q;
    q.push(make_tuple(s, 0));
    REP(i, 4) {
        C[s.first][s.second][i] = 0;
    }
    while (!q.empty()) {
        auto t = q.front();
        q.pop();
        pll p = get<0>(t);
        ll cost = get<1>(t) + 1;
        REP(i, 4) {
            REP(d, K) {
                ll nx = x[i] * (d + 1) + p.first, ny = y[i] * (d + 1) + p.second;
                if (nx < 0 || nx >= H || ny < 0 || ny >= W)
                    break;
                if (S[nx][ny] == '@')
                    break;
                if (C[nx][ny][i] <= cost)
                    break;
                bool e = false;
                REP(k, 4) {
                    if (C[nx][ny][k] < cost)
                        e = true;
                }
                if (e)
                    break;
                C[nx][ny][i] = cost;
                q.push(make_tuple(pll(nx, ny), cost));
            }
        }
    }

    ll ans = INF;
    REP(i, 4) {
        ans = std::min(C[g.first][g.second][i], ans);
    }
    if (ans == INF)
        ans = -1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 144976
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
const int inf = 1e9;
const double EPS = 1e-10;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void fill(int y, int x, int c, int &l, int &r, int &sx, int &nb, vector<pair<int,int> > &top, vector<vector<char> > &field){
    field[y][x] = 'o';
    sx += x;
    nb ++;
    if(field[y-1][x] != c && '1' <= field[y-1][x] && field[y-1][x] <= '9'){
        top.push_back(make_pair(y-1, x));
    }
    if(field[y+1][x] == 'x'){
        l = min(l, x);
        r = max(r, x);
    }
    for(int i=0; i<4; i++){
        if(field[y+dy[i]][x+dx[i]] == c){
            fill(y+dy[i], x+dx[i], c, l, r, sx, nb, top, field);
        }
    }
}
void cleanup(int y, int x, vector<vector<char> > &field){
    field[y][x]='x';
    for(int i=0; i<4; i++){
        if(field[y+dy[i]][x+dx[i]] == 'o'){
            cleanup(y+dy[i], x+dx[i], field);
        }
    }
}
 
pair<int, int> solve(int y, int x, vector<vector<char> > &field){
    if(field[y][x] == 'x') return make_pair(0, 0);
    int color = field[y][x];
    int left=inf, right=-inf;
    int sumx=0, numblock=0;
    vector<pair<int,int> > top;
    fill(y, x, color, left, right, sumx, numblock, top, field);
    cleanup(y, x, field);

    for(int i=0; i<(int)top.size(); i++){
        pair<int,int> ret = solve(top[i].first, top[i].second, field);
        sumx += ret.first;
        numblock += ret.second;
        if(ret.first == -1) return make_pair(-1,-1);
    }
    
    double centroid = (double)sumx/numblock;
    if(centroid-EPS < left-0.5 || right+0.5 < centroid+EPS){
        return make_pair(-1, -1);
    }else{
        return make_pair(sumx, numblock);
    }
}
 
int main(){
    while(1){
        int w,h;
        cin >> w >> h;
        if(w==0) break;
         
        vector<vector<char> > field(h+3, vector<char>(w+2, '.'));
        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                cin >> field[i][j];
            }
        }

        int sx;
        for(int j=1; j<=w; j++){
            field[h+1][j] = 'x';
            if(field[h][j] != '.') sx = j;
        }
        if(solve(h, sx, field).second == -1){
            cout << "UNSTABLE" << endl;
        }else{
            cout << "STABLE" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <algorithm>
#include <cmath>
 
using namespace std;
 
typedef struct _POS {
  int x, y;
} POS;
 
#define MX 10000
 
POS field[MX];
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
 
int main(void) {
  int mN, mE, mS, mW;
  POS init;
  int n;
  int p, d;
   
  init.x = -1; init.y = -1;
 
  while(1) {
    cin >> n;
    if(n == 0) break;
 
    //fill(field[], field + MX, init);
    for(int i = 0; i < MX; i++) {
      field[i] = init;
    }
     
    mN = 0; mE = 0; mS = 0; mW = 0;
    field[0].x = 0; field[0].y = 0;
    int cnt = 0;
    for(int i = 1; i < n; i++) {
      cin >> p >> d;
      cnt++;
      field[cnt].x = field[p].x + dx[d];
      field[cnt].y = field[p].y + dy[d];
 
      mN = min(mN, field[cnt].y);
      mE = max(mE, field[cnt].x);
      mS = max(mS, field[cnt].y);
      mW = min(mW, field[cnt].x);
    }
 
    cout << mE - mW +1<< " " << mS - mN +1<< endl;
  }
   
  return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;




int main() {

	string str;
	cin >> str;
	
	string first = str.substr(0, 1);
	string last = str.substr(str.size() - 1, 1);
	string num_s = to_string(str.size() - 2);

	string ans = first + num_s + last;
	cout << ans << endl;
	return 0;
	
}



Measured memory_bytes: 256
#最小全域木　プリム法
from heapq import *

n=int(input())
xy=[]
for i in range(n):
    x,y=map(int,input().split())
    xy.append([x,y,i])

#今回の問題では,高々xが隣のやつとyが隣のやつを全部考えればよし
#（詳しくは解説pdfより）
x_sort = sorted(xy, key=lambda x: x[0])
y_sort = sorted(xy, key=lambda x: x[1])

cost = [[]for _ in range(n+3)] #cost[i]にはi番目から(j,k)でj番目にコストkかかる
for i in range(n-1):
    cost[x_sort[i][2]].append((x_sort[i+1][2],x_sort[i+1][0]-x_sort[i][0]))
    cost[x_sort[i+1][2]].append((x_sort[i][2],x_sort[i+1][0]-x_sort[i][0]))

    cost[y_sort[i][2]].append((y_sort[i+1][2],y_sort[i+1][1]-y_sort[i][1]))
    cost[y_sort[i+1][2]].append((y_sort[i][2],y_sort[i+1][1]-y_sort[i][1]))


used=[False]*(n+3)#頂点が最小全域木にもうすでに含まれているかどうか
q=[]
#すでに最小全域木が決まっている部分からまだ決まっていない部分への辺をヒープで管理
#(a,b)でaには向かう先の頂点,bにはかかるコスト
#ヒープで小さいコストからとりだせる

#初期条件
#はじめはどこでもよいので０番目スタートとする(0番目だけではコストは0)
used[0] = True
ans = 0

#0番目からの辺をすべてヒープに挿入
for to,cst in cost[0]:
    heappush(q,(cst,to))

#すでに決まっている最小全域木部分からまだ決まっていない部分を貪欲的にひたすら追加する
#はじめは初期条件の通り
while(len(q)!=0):
    c,ver=heappop(q)
#すでに決まっている部分から一番小さいコストの辺を取り出す
    if used[ver] == True:
        continue
#もしすでに最小全域木部分であればやり直し
#そうでなければコストの分を加算し、新しい頂点を最小全域木部分に追加する
    ans += c
    used[ver] = True
#新しく追加した頂点からの辺をヒープに追加する
    for to,cst in cost[ver]:
        heappush(q,(cst,to))
#これを貪欲的に繰り返すことでうまくいくらしい
print(ans)


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

int main() {
    ll h,enemy=1,count=0;
    cin>>h;
    while(h>1) {
        count+=enemy;
        enemy*=2;
        h/=2;
    }
    count+=enemy;
    cout<<count<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# initialize
N,K = map(int, input().split())
list = [0] * (10**5+1)

# In:list, Out:ans
def solve(k,l):
    for i in range(len(l)):
        k -= l[i]
        if (k <= 0):
            return i
    return 0

# Input a and b to the list
for i in range(N):
    a,b = map(int, input().split())
    list[a] += b

print(str(solve(K,list)))


Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define fo(i,a,b) for(long long i=a;i<b;i++)
#define all(c) (c).begin(),(c).end()
#define ll long long
const int M=1e9+7;
#define endl "\n"





int main() 
{ 
    
   ll n;
   sfl(n);

   ll ans=0;
   fo(i,1,n+1)
   {
	   	if(i%5==0 && i%3==0)
	   {
	   	continue;
	   }
	   else if(i%3==0)
	   	continue;
	   else if(i%5==0)
	   {
	   	continue;
	   }
	   else
	   {
	      ans+=i;
	   }
   }

   pfln(ans);
   
    return(0);
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n,T;
  cin >> n >> T;
  int cost = 1001;
  rep(i,n){
    int c,t;
    cin >> c >> t;
    if(t <= T)cost = min(c,cost);
  }
  if(cost == 1001) cout << "TLE" << endl;
  else cout << cost << endl;
}



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

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 1;
  rep(i, n) {
    if (ans < k)
      ans *= 2;
    else
      ans += k;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	string s, t;
	cin >> s >> t;
	int n = s.size();
	bool flag = false;
	for(int i = 0; i < n; i++){
		if(s.substr(i, 1) == t.substr(n - i - 1, 1)){
			continue;
		}else{
			flag = true;
			break;
		}
	}
	if(flag) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

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

n = int(input())

def rec(s, kind):
    if len(s) == n:
        print(s)
        return
    for i in range(kind+1):
        end = chr(ord('a')+i)
        if i < kind:
            rec(s+end, kind)
        else:
            rec(s+end, kind+1) 

rec('a', 1)

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

int main(){
    int X;
    cin >> X;
    int hun,one;
    hun=X/500;
    hun=hun*1000;
    one=X%500;
    if(one%5==0){
        hun=hun+one;
    }else if(one%5<5){
        hun=hun+one-one%5;
    }else{
        hun=hun+one-one%5+5;
    }
    cout << hun << endl;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

bool check(int n, vector<bool> &ok) {
    while (n > 0) {
        int d = n % 10;
        if (!ok[d])
            return false;
        n /= 10;
    }
    return true;

}
int main() {
    int n, k;
    cin >> n >> k;
    vector<bool> ok(10, true);
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        ok[d] = false;
    }
    int i = n;
    for (i = n;; i++) {
        if (check(i, ok))
            break;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX   20
#define M     200

int solve(int,int);

int n;
int A[MAX];

int main()
{
  int q,i,res;
  int B[M];
  
  scanf("%d",&n);
  
  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }
  
  scanf("%d",&q);
 
  for(i = 0;i < q;i++){
    scanf("%d",&B[i]);
  }
  
  for(i = 0;i < q;i++){
      res = solve(0,B[i]);
      if(res == 1){
	printf("yes\n");
      }
      else if(res == 0){
	  printf("no\n");
      }
  }
  
  return 0;
}

  int solve(int i,int m)
  {
    int res; 
    if(m == 0) return 1;
    if(i >= n) return 0;

    if(solve(i+1,m) == 1 || solve(i+1,m - A[i]) == 1)
    return 1;
  }

Measured memory_bytes: 580
#include<iostream>
#include<math.h>
using namespace std;
int main(){
	long long h,c;
	cin>>h;
	long long sum=0;
	long long a;
	c=0;
	while(h!=1){
		a=1*pow(2,c);
		sum+=a;
		c++;
		h=h/2;
	}
	sum+=1*pow(2,c);
	cout<<sum;
}

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

// 各桁の和を計算する関数
int decimal_ch(int n){
  int sum=0;
  while(n>0){
    sum += n%10;
    n/=10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  int total = 1000000;
  for (int i = 1; i < N; ++i) {
    int sum_A = decimal_ch(i); // i の各桁の和
    int sum_B = decimal_ch(N-i);
    if (sum_A+sum_B<total) {
      total=sum_A+sum_B;
    }
  }
  cout << total << endl;
}

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

typedef long long INT;

int main(){
    INT K;
    std::string S;
    std::cin >> K;
    std::cin >> S;

    INT le  = (INT)S.length();

    if(le>K){
        std::cout << S.substr(0,K);
        std::cout << "..." << std::endl;
    }else{
        std::cout << S << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010

int main(){
	lint n=3;
	liv a(n);rep(i,n)cin>>a[i];
	bool g=0;rep(i,n)if(a[i]%2==0)g=1;
	if(g==1){ cout<<0<<endl;return 0; }
	sort(all(a));
	cout<<a[0]*a[1]<<endl;
}

//sub-EOF


Measured memory_bytes: 256
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	N := readInt64()

	m := N - 1
	println(m * (m + 1) / 2)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}
 
int main(void){
    string a,b; cin >> a >> b;
    string n_str = a + b;
    int n = stoi(n_str);
    bool OK = false;
    if( (int)(sqrt(1.0*n)*100) % 100 == 0) OK = true;
    if(OK) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cmath>
#include <queue>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(B / A, C) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define P 3.1415926
int main(){
	double a,b,C,d;
	double S,L,h;
	scanf("%lf %lf %lf",&a,&b,&C);
	C=C/180*P;
	S=a*b*sin(C)/2;
	d=pow(a,2)+pow(b,2)-2*a*b*cos(C);
	L=a+b+sqrt(d);
	h=b*sin(C);
	printf("%f\n%f\n%f\n",S,L,h);
	return 0;
}


Measured memory_bytes: 2028
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int h, w,k;
	cin >> h >> w>>k;
	vector<string>a(h);
	rep(i, h) {
		cin >> a[i];
	}
	int ans(0);
	rep(is, 1 << h) {//2^hのループ。1<<hが2^h
		rep(js, 1 << w) {//1<<wが2^h
			int cnt = 0;
			rep(i, h) {

				rep(j, w) {
					if (is >> i & 1)continue;//isのi番目が1のとき、=かくしてあるとき
					if (js >> j & 1)continue;
					if (a[i][j] == '#')cnt++;
				}
			}
			if (cnt == k) {
				ans++;
			}

		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3628
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

def main():
    n,m = map(int, input().split()) # n represents switch, m represents lights
    lights=[]
    for i in range(m):
        ll=list(map(int, input().split()))
        lights.append(ll[1:])
    p = list(map(int, input().split()))
    # eprint(lights)
    # eprint(s)
    ans=0
    for case in range((1<<n)):
        # eprint(bin(case))
        # cnt_switch_on = 0
        ii=0
        f_flag=0
        for light in lights:
            cnt_on=0
            for i in light:
                if (case>>(i-1))&1:
                    cnt_on+=1
            # eprint(cnt_on,p[ii])
            if  cnt_on%2!=p[ii]:
                f_flag=1
            ii+=1
        if f_flag==0:
            ans+=1
    print(ans)
if __name__ == '__main__':
    main()


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

using namespace std;

using int64 = long long;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

// Verified: AOJ-GRL4B
vector<int> TopologicalSort(const vector<vector<Edge>>& graph) {
  int n = graph.size();
  vector<int> in(n);
  for (int v = 0; v < n; v++) {
    for (const auto& edge : graph[v]) {
      in[edge.to]++;
    }
  }

  deque<int> queue;
  for (int v = 0; v < n; v++) {
    if (in[v] == 0) queue.push_back(v);
  }

  vector<int> vs;
  while (!queue.empty()) {
    int v = queue.front();
    queue.pop_front();
    vs.push_back(v);
    for (const auto& edge : graph[v]) {
      in[edge.to]--;
      if (in[edge.to] == 0) queue.push_back(edge.to);
    }
  }

  if (vs.size() < n) return vector<int>();
  return vs;
}

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

  int n;
  cin >> n;
  auto id_table = Make2DVector(n, n, -1);
  int id = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      id_table[i][j] = id;
      id++;
    }
  }

  auto table = Make2DVector(n, n - 1, -1);
  vector<vector<Edge>> graph(id);
  for (int i = 0; i < n; i++) {
    vector<int> ids;
    for (int j = 0; j < n - 1; j++) {
      int k;
      cin >> k;
      k--;
      table[i][j] = k;
      int p1 = min(i, k);
      int p2 = max(i, k);
      int id = id_table[p1][p2];
      ids.push_back(id);
    }
    for (int i = 0; i + 1 < n - 1; i++) {
      graph[ids[i]].emplace_back(ids[i], ids[i + 1]);
    }
  }

  vector<int> t_sort = TopologicalSort(graph);
  if (t_sort.empty()) {
    cout << -1 << endl;
    return 0;
  }

  int turn = 0;
  int count = 0;
  vector<int> counter(n);
  vector<int> changed(n);
  for (int i = 0; i < n; i++) changed.push_back(i);
  while (count < n * (n - 1) / 2) {
    turn++;

    vector<int> used(n);
    vector<int> new_changed;
    for (int i : changed) {
      if (counter[i] >= n - 1) continue;
      if(used[i]) continue;
      int j = table[i][counter[i]];
      if (used[j]) continue;
      if (table[j][counter[j]] != i) continue;
      counter[i]++;
      counter[j]++;
      used[i] = 1;
      used[j] = 1;
      count++;
      new_changed.push_back(i);
      new_changed.push_back(j);
    }
    changed = new_changed;
  }
  cout << turn << endl;
}

Measured memory_bytes: 39548
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    bad = set()
    for _ in range(m):
        a, b = map(lambda x: int(x) - 1, input().split())
        if h[a] <= h[b]:
            bad.add(a)
        if h[a] >= h[b]:
            bad.add(b)
    print(n - len(bad))

main()

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  ll a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);

  // 累積和
  ll b[N];
  for (int i = 0; i < N; i++) b[i] = a[i];
  for (int i = 1; i < N; i++) b[i] += b[i-1];

  int ans = N;
  for (int i = N - 1; i > 0; i--) {
    if (b[i-1] * 2 < a[i]) {
      ans = N - i;
      break;
    }
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Here your code !
    string s,t;
    cin >> s >> t;
    
    for(int i = 0; i < t.size(); i++){
        cout << s[i] <<t[i];
    }
    
    if(s.size() > t.size())
        cout << s[t.size()];
    
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int n;
pair<int,int> a[N];
long long ans;

bool cmp(pair<int,int> x, pair<int,int> y){
	return x.first+x.second > y.first+y.second;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> a[i].first >> a[i].second;
	}
	sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;i++){
		if (i&1){
			ans += a[i].first;
		}else{
			ans -= a[i].second;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 1024
import math

def is_prime(num):
    i = 2
    while i <= math.sqrt(num):
        if num % i == 0:
            return False
        i = i + 1
    return True

N = int(input())
cnt = 0
for i in range(0, N):
    n = int(input())
    if (is_prime(n)):
        cnt = cnt + 1
        
print(cnt)

Measured memory_bytes: 7720
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int N;
vector<pair<long double, long double>> points;
int main(void) {
  cin >> N;
  points.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> points[i].first >> points[i].second;
  }

  long double total = 0;
  long double sum = 0;
  Sort(points);

  do {
    for (int i = 0; i < points.size() - 1; i++) {
      sum += sqrtl((points[i].first - points[i + 1].first) *
                       (points[i].first - points[i + 1].first) +
                   (points[i].second - points[i + 1].second) *
                       (points[i].second - points[i + 1].second));
    }
    total++;
  } while (next_permutation(points.begin(), points.end()));

  printf("%.100Lf\n", sum / total);

  return 0;
}

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

int parent(int i){return i/2;}
int left(int i){return i*2;}
int right(int i){return i*2 + 1;}

int main(){
  int h;
  cin >> h;
  int key;
  int T[h + 1];
  for ( int i = 1; i <= h; i++){
    cin >> key;
    T[i] = key;
  }

  for ( int i = 1; i <= h; i++){
    cout << "node " << i << ": " << "key = " << T[i] << ", ";
    if ( parent(i) >= 1  ){
      cout << "parent key = " << T[parent(i)] << ", ";
    }
    if ( left(i) <= h){
      cout << "left key = " << T[left(i)] << ", ";
    }
    if ( right(i) <= h){
      cout << "right key = " << T[right(i)] << ", ";
    }
    cout << endl;
  }

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector <vector< int> > vvi;
typedef vector<ll> vl;
typedef vector <vector< ll> > vvl;

#define endl "\n"
#define sp " "
#define M 1000000007
#define PI acos(-1.0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define ini(a,i) memset(a, i, sizeof(a))
#define forf(n,x) for(int x = 0; x < n; ++x)
#define forb(n,x) for(int x = n-1; x >= 0; --x)
#define fori(n,x,i) for(int x=i; x<n; ++x)
#define vin(arr,n) forf(n,_) cin>>arr[_]
#define vout(arr,n) {forf(n,_) cout<<arr[_]<<sp; cout<<endl;}

#define all(c) c.begin(), c.end()
#define itr(c,it) for( auto it = c.begin(); it != c.end(); ++it)

typedef priority_queue <int> pq;

ll modInv(ll a)
{
    ll y = M-2;
    ll ans = 1;
    
    a %= M;
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % M; 
  
        y = y>>1;
        a = (a*a) % M; 
    } 
    return ans;
    
}

int main()
{
	fastio;
	/*
	int quer;
	cin>>quer;
	forf(quer,qe)
	{

	}
	*/
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll ans = 0;
	ans+=min(a,k);
	if(k>a)
	{
		k-=a;
		k-=b;
		if(k>0)
		{
			ans -= k;
		}
	}
	cout<<ans;	
	return 0;
}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args){

		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> listAnswer = new ArrayList<Integer>();

		try{

			String strTurn = insBR.readLine();
			int intTurn = Integer.parseInt(strTurn);

			for(int i = 0; i < intTurn; i++){
				insBR.readLine();

				List <Integer> listMountain = new ArrayList<Integer>();

				String[] strMountain = insBR.readLine().split(" ");
				for(int j = 0; j < strMountain.length; j++){
					int intMountain = Integer.parseInt(strMountain[j]);
					listMountain.add(intMountain);
				}


				int intClimb = 0;
				int intDescend = 0;

				for(int j = 0; j + 1 < listMountain.size(); j++){
					int intDistance = listMountain.get(j + 1) - listMountain.get(j);
					if(intClimb < intDistance){
						intClimb = intDistance;
					}else if(intDistance < 0){
						intDistance = Math.abs(intDistance);
						if(intDescend < intDistance){
							intDescend = intDistance;
						}
					}
				}

				listAnswer.add(intClimb);
				listAnswer.add(intDescend);

			}

		}catch(IOException e){
		 	e.printStackTrace();
		}catch(NumberFormatException e){
			e.printStackTrace();
		}

		for(int i = 0; i < listAnswer.size(); i++){
			int intDiv = i % 2;
			if(intDiv == 0){
				System.out.print(listAnswer.get(i) + " ");
			}else{
				System.out.println(listAnswer.get(i));
			}
		}

	}
}



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

public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj= new FastReader();
        int x = obj.nextInt(),sum = 0;
        while(x>=5)
        {
            if(x>=500)
            {
                int u = x;
                x -= (u/500)*500;
                sum += (u/500)*1000;
            }
            else
            {
                int u = x;
                x -= (u/5)*5;
                sum += (u/5)*5;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 21332
#!/usr/bin/env python3
import sys


def solve(a: int, b: int):
    if a < b:
        print(str(a)*b)
    if b < a:
        print(str(b)*a)
    if a == b:
        print(str(a)*b)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#[test]
fn test_solve() {
    assert_eq!(solve("3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n"), "2\n");
    assert_eq!(solve("3 3 2\n1 3\n2 3 2\n1 3 6\n1 2 2\n"), "4\n");
    assert_eq!(
        solve("4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6\n"),
        "3\n"
    );
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let m: usize = sc.read();
    let rn: usize = sc.read();
    let r: Vec<usize> = (0..rn).map(|_| sc.read()).collect();
    let mut nbr = vec![Vec::new(); n];
    for _ in 0..m {
        let a: usize = sc.read();
        let b: usize = sc.read();
        let c: i64 = sc.read();
        nbr[a - 1].push((b - 1, c));
        nbr[b - 1].push((a - 1, c));
    }
    let nbr = nbr;

    let mut ans = i64::max_value();
    let sds = shortest_dists(&nbr);
    let mut prm = (0..rn).collect::<Vec<_>>();
    while {
        let s = (0..rn - 1)
            .map(|i| sds[r[prm[i]] - 1][r[prm[i + 1]] - 1])
            .sum();
        ans = std::cmp::min(ans, s);
        next_permutation(&mut prm)
    } {}

    format!("{}\n", ans)
}
fn shortest_dists(neighbor: &[Vec<(usize, i64)>]) -> Vec<Vec<i64>> {
    let n = neighbor.len();
    let mut d = vec![vec![i64::max_value() >> 1; n]; n];
    for v in 0..n {
        for &(w, c) in &neighbor[v] {
            d[v][w] = c;
        }
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                d[i][j] = std::cmp::min(d[i][j], d[i][k] + d[k][j])
            }
        }
    }
    d
}
fn next_permutation<T: Ord>(v: &mut [T]) -> bool {
    let len = v.len();
    if len <= 1 {
        return false;
    }
    let mut i = len - 1;
    loop {
        let i1 = i;
        i -= 1;
        if v[i] < v[i1] {
            let mut i2 = len - 1;
            while v[i] >= v[i2] {
                i2 -= 1;
            }
            v.swap(i, i2);
            for j in 0..(len - i1) >> 1 {
                v.swap(i1 + j, len - j - 1);
            }
            return true;
        }
        if i == 0 {
            v.reverse();
            return false;
        }
    }
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


Measured memory_bytes: 6396
mod=1000000007
n=int(input())
s=input()

d=[0]
for i in range(1,n):
    if s[i-1]==s[i]:
        d[-1]+=1
    else:
        d.append(0)
ans=[3,6][d[0]]
for i in range(1,len(d)):
    if d[i-1]==d[i]==1:
        t=3
    elif d[i-1]==1:
        t=1
    else:
        t=2
    ans=(ans*t)%mod
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;

int N, M;
vector<string> A, B;

void solve() {
  REP (i, N-M+1) {
    REP (j, N-M+1) {
      bool same = true;
      REP (k, M) {
        if (A[i+k].substr(j, M) != B[k]) {
          same = false;
        }
      }
      if (same) {
        cout << "Yes" << endl; return;
      }
    }
  }
  cout << "No" << endl;
}

signed main() {
  cin >> N >> M;
  REP (i, N) {
    string a; cin >> a; A.push_back(a);
  }
  REP (i, M) {
    string b; cin >> b; B.push_back(b);
  }
  solve();
}


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

long long gcd(long long a, long long b) {
  for (; b; swap(a, b)) a %= b;
  return a;
}
int main() {
  long long x, y; cin >> x >> y;
  cout << x / gcd(x, y) * y << '\n';
  return 0;
}

Measured memory_bytes: 256
//AOJ0227
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cstdio>
#include<iostream>
int vegetable[1001];

int main(){
	int n, m;
	while (scanf("%d %d", &n, &m), n, m){
		for (int i = 0; i < n; ++i){
			scanf("%d",vegetable+i);
		}
		std::sort(vegetable, vegetable + n);
		int cnt = 0;
		int ans = 0;
		//??????
		//for (int i = 0; i < n; ++i)printf("%d ", vegetable[i]);
		for (int i = n - 1; i >= 0; i--){
			ans += vegetable[i];
			cnt++;
			if (cnt%m == 0)ans -= vegetable[i];
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1208
#include <iostream>

using namespace std;
typedef long long int ll;


int main()
{	
	int n; cin>>n;
	ll ans=0;
	for(int i=0;i<n;i++){
		ll x; cin>>x;
		while(x % 2 == 0){
			ans++;
			x /= 2;
		}
		
	}

	cout<<ans;
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  string a,b;
  cin >> a >> b;
  int k=0;
  for(int i=0;i<3;i++){
    if(a[i]==b[i])
      k++;
  }
  cout << k << endl;
}

Measured memory_bytes: 256
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024
var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	a := map[int]int{}
	for i := 0; i < 9; i++ {
		a[nextInt()] = i
	}

	n := nextInt()
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = nextInt()
	}

	bingo := map[int]bool{}
	for i := 0; i < n; i++ {
		if index, ok := a[b[i]]; ok {
			bingo[index] = true
		}
	}

	if bingo[0] && bingo[1] && bingo[2] ||
		bingo[3] && bingo[4] && bingo[5] ||
		bingo[6] && bingo[7] && bingo[8] ||
		bingo[0] && bingo[3] && bingo[6] ||
		bingo[1] && bingo[4] && bingo[7] ||
		bingo[2] && bingo[5] && bingo[8] ||
		bingo[0] && bingo[4] && bingo[8] ||
		bingo[2] && bingo[4] && bingo[6] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

Measured memory_bytes: 640
MOD = 10**9+7
fact = [1, 1]
for i in range(2, 10**6+1):
    fact.append((fact[i-1] * i) % MOD)


def comb(n, k):
    return (fact[n] * pow(fact[k], MOD-2, MOD) * pow(fact[n-k], MOD-2, MOD)) % MOD


X, Y = [int(x) for x in input().split(" ")]

n = (2 * X - Y) / 3
m = (2 * Y - X) / 3

if n < 0 or n != int(n):
    print(0)
elif m < 0 or m != int(m):
    print(0)
else:
    n = int(n)
    m = int(m)
    ans = comb(n+m, n)
    print(ans)


Measured memory_bytes: 94316
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
  cin >>n;
  int l[2*n];
  for(int i=0; i<2*n; i++) cin >>l[i];
  sort(l,l+2*n);
  int sum=0;
  for(int i=0; i<n; i++){
  	sum+=l[i*2];
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }

string S;
int vis[26];
int main() {

	cin >> S;

	
	ll ans = inf, m = 0;
	rep(i, 26){
		ll index = -1;
		m = 0;
		for(int j = 0; j < S.size(); j++) {
			if (S[j] == i + 'a') {				
				m = max(j - index - 1, m);
				index = j;
			}
			else if (j == S.size() - 1) {

				m = max(j - index, m);
			}

		}
		ans = min(m, ans);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_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(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
vector<int> tree[222222];
int cnt[222222] = {};
void search(int now, int from) {
    cnt[now] += cnt[from];
    each(i, tree[now]) {
        if(i != from) search(i, now);
    }
}
signed main() {
    INCANT;
    int n, q, a, b;
    cin>>n>>q;
    rep(i, n - 1) {
        cin>>a>>b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    rep(i, q) {
        cin>>a>>b;
        cnt[a] += b;
    }
    search(1, 0);
    rep(i, 1, n) cout<<cnt[i]<<' ';
    cout<<cnt[n]<<endl;
}


Measured memory_bytes: 24832
#include<cstdio>
#include<algorithm>
const int MAXN=200000+5;
int cnt[MAXN],n,k,max,a;bool appr[MAXN];
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		cnt[a]++;
		if(!appr[a])
		{
			appr[a]=1;
			cnt[0]++;
			max=std::max(a,max);
		}
	}
	std::sort(cnt+1,cnt+max+1);
	int start=1;
	while(!cnt[start]) start++;
	int end=start+(cnt[0]-k)-1,ans=0;
	for(int i=start;i<=end;i++)
		ans+=cnt[i];
	printf("%d",ans);
	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define filename "lynext"
#define freop freopen(filename ".cik","w",stdout);freopen(filename ".gir","r",stdin)
const long long int N = ((long long int)4e2) + 5;
const long long int M = ((long long int)1e3) + 5;
const long long int llinf = (long long int)1e18;
const int inf = INT_MAX;
typedef long long int lli;

lli n;
lli arr[N];
lli dp[N][N];
lli pref[N];

lli f(lli l, lli r)
{
	if (l < 1 || r > n)
		return llinf;
	if (l == r)
			return 0;
	if (dp[l][r] != -1)
		return dp[l][r];
	lli ans = llinf;
	for (lli i = l; i < r; i++)
	{
		lli cost = pref[r] - pref[l - 1];
		lli xD = f(l,i) + f(i + 1,r) + cost;
		ans = min(ans,xD);
	}
	return dp[l][r] = ans;
}

int main ()
{
	fast;
	//freop;
	cin >> n;
	memset(dp, -1, sizeof dp);
	for (lli i = 1; i <= n; i++)
	{
		cin >> arr[i];
		pref[i] = pref[i - 1] + arr[i];
	}
	cout << f(1,n) << "\n";
}


Measured memory_bytes: 1536
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int x = scan.nextInt();
        int a = scan.nextInt();
        if(x < a){
            System.out.println("0");
        }else{
            System.out.println("10");
        }
    }
}

Measured memory_bytes: 22612
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#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 all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

// エラトステネスの篩
vector<char> eratos(int n) {
	vector<char> is_prime(n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i*i <= n; i++)
		if (is_prime[i]) {
			int j = i + i;
			while (j <= n) {
				is_prime[j] = false;
				j += i;
			}
		}
	return is_prime;
}
// n以下の素数
vector<int> getPrimes(int n) {
	vector<char> is_prime = eratos(n);
	vector<int> primes;
	for (int i = 0; i < n + 1; i++)
		if (is_prime[i])
			primes.emplace_back(i);
	return primes;
}
// 素因数分解 昇順
// √x以下の素数に対して割り切れるか調べる
vector<int> primeFactorization(int x) {
	vector<int> primes = getPrimes(sqrt(x));
	vector<int> factors;
	for (auto &p : primes) {
		while (x%p == 0) {
			x /= p;
			factors.emplace_back(p);
		}
	}
	if (x != 1)factors.emplace_back(x);
	return factors;
}
vector<int> getDivisors(int x) {
	vector<int> ret;
	int i;
	for (i = 1; i*i < x; i++) {
		if (x%i)continue;
		ret.emplace_back(i);
		ret.emplace_back(x / i);
	}
	if (i*i == x)
		ret.emplace_back(i);
	return ret;
}


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

	vector<int> factors = primeFactorization(N);
	vector<int> divisors = getDivisors(N);

	dump(factors);

	map<int, int> mp;
	for (auto f : factors)mp[f]++;

	int maxi = 0;
	int mini = 0;

	maxi = divisors.size() - 1;
	mini = mp.size();

	cout << mini << " " << maxi << endl;

	return 0;
}


Measured memory_bytes: 4900