akhauriyash/Code-Regression huggingface dataset:
#define ll long long int
#include <bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M = 1000001;
  int i,j,ct;
  int w=0,x;

  vector<int> c(M,0);
  vector<int> f(M,0);
  cin >> N;
  for(i=0;i<N;i++){
    cin >> x;
    c[x]++;
    w = gcd(w,x);
  }

  if (w>1){
    cout << "not coprime" << endl;
    return 0;
  }
  
  for(i=2;i<M;i++){
    if (f[i]) continue;
    ct = 0;
    for(j=i;j<M;j+=i){
      ct += c[j];
      f[j]++;
    }
    if (ct>1){
      cout << "setwise coprime" << endl;
      return 0;
    }
  }

  cout << "pairwise coprime" << endl;
  return 0;
}

Measured memory_bytes: 11060
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  int n;
  cin>>n;
  long long T;
  cin>>T;
  long long t[n];
  REP(i,n){
    cin>>t[i];
  }
  vector<int> indexes;
  indexes.push_back(0);
  REP(i,n){
    if(t[i]<=t[i-1]+T){
      continue;
    }else{
      indexes.push_back(i);
    }
  }
  indexes.push_back(n);
  
  long long ans=0;
  REP(i,indexes.size()){
    if(i==0){
      continue;
    }
    ans += t[indexes[i]-1]+T-t[indexes[i-1]];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
using ll = long long;

const int N_MAX = 100010;

int n;
ll a[N_MAX];

ll solve(bool sign) {
  ll res = 0; 
  ll acc = 0;

  for(int i=0;i<n;i++){
    acc += a[i];
    if (sign && acc <= 0) {
      res += -acc + 1;
      acc = 1;
    }
    if (!sign && acc >= 0) {
      res += acc + 1;
      acc = -1;
    }
    sign = !sign;
  }

  return res;
}

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

  ll res = min(solve(true), solve(false));
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
c = []
for _ in range(3):
    ci = list(map(int, input().split()))
    c.append(ci)
row_list = [[0, 1], [1, 2], [0, 2], [0, 1]]
for i in range(len(row_list)-1):
    if c[row_list[i][0]][0] - c[row_list[i][1]][0] == c[row_list[i][0]][1] - c[row_list[i][1]][1] == c[row_list[i][0]][2] - c[row_list[i][1]][2] \
    and c[row_list[i+1][0]][0] - c[row_list[i+1][1]][0] == c[row_list[i+1][0]][1] - c[row_list[i+1][1]][1] == c[row_list[i+1][0]][2] - c[row_list[i+1][1]][2]:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 3064
import java.io.UnsupportedEncodingException;
import java.util.*;

public class Main {

	public static void main(String[] args) throws UnsupportedEncodingException {

		Scanner sc = new Scanner(System.in);

		int ans = 0;

		int[] list = new int[3];
		list[0] = sc.nextInt();
		list[1] = sc.nextInt();
		list[2] = sc.nextInt();

		int K = sc.nextInt();

		Arrays.sort(list);

		for (int i = 0; i < K; i++) {
			list[2] = list[2] * 2;

		}

		for (int i : list) {
			ans += i;
		}

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


Measured memory_bytes: 22484
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        var n = long.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        long h = 0;
        long w = 0;
        var dic = new Dictionary<long, long>() { };
        for (int i = 0; i < n; i++)
        {
            if (!dic.ContainsKey(a[i]))
            {
                dic.Add(a[i], 1);
            }
            else
            {
                dic[a[i]]++;
            }

            if (dic[a[i]] == 2)
            {
                if (h == 0)
                {
                    h = a[i];
                    dic[a[i]] = 0;
                }
                else if (w == 0)
                {
                    w = a[i];
                    dic[a[i]] = 0;
                }
                else if (a[i] > h)
                {
                    if (h > w)
                    {
                        w = h;
                    }
                    h = a[i];
                    dic[a[i]] = 0;
                }
                else if (a[i] > w)
                {
                    w = a[i];
                    dic[a[i]] = 0;
                }
            }
        }
        long ans = h * w;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 29280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    int N;
    cin >> N;
    if (N==1) cout << "Hello World";
    else
    {
        int A, B;
        cin >> A >> B;
        cout << A+B;
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> > 
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
  map <string, int> ms;
  int n; cin >> n;
  while(n--) {
    string s; cin >> s;
    ms[s]++;
  }
  cout << "AC x " << ms["AC"] << '\n';
  cout << "WA x " << ms["WA"] << '\n';
  cout << "TLE x " << ms["TLE"] << '\n';
  cout << "RE x " << ms["RE"] << '\n';
}

signed main() {   
  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 = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
     solve();
  }
}    
  

Measured memory_bytes: 3688
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)

ans = 0
if len(a) % 2 == 0:
  b = a[:len(a)//2]
  ans = (2 * sum(b)) - b[0]
else:
  b = a[:len(a)//2 +1]
  ans = 2 * sum(b) - b[0] - b[-1]

print(ans)

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

class F
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ps = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
		var xs = ps.Select(p => p[0]).ToArray();
		var xy = ps.Select(p => p[1]).ToArray();
		Array.Sort(xs, xy);
		for (int i = 0; i < n; i++)
			xs[i] = i;
		Array.Sort(xy, xs);
		var yx = new int[n];
		Array.Copy(xs, yx, n);
		for (int i = 0; i < n; i++)
			xy[i] = i;
		Array.Sort(xs, xy);

		int ss = 128, sc = n / ss + 1;
		var s = new int[sc, sc];
		for (int i = 0; i < n; i++)
			s[i / ss, xy[i] / ss]++;
		for (int i = 0; i < sc; i++)
			for (int j = 1; j < sc; j++)
				s[i, j] += s[i, j - 1];
		for (int j = 0; j < sc; j++)
			for (int i = 1; i < sc; i++)
				s[i, j] += s[i - 1, j];

		var c = MInt(n * MPow(2, n) - n);
		for (int i = 0; i < n; i++)
		{
			var v = xy[i];

			var li = i >= ss && v >= ss ? s[i / ss - 1, v / ss - 1] : 0;
			var ix = i - i % ss;
			for (int i2 = ix; i2 < i; i2++)
				if (xy[i2] < v) li++;
			for (int j2 = v - v % ss; j2 < v; j2++)
				if (yx[j2] < ix) li++;

			c -= MPow(2, i) + MPow(2, n - 1 - i) + MPow(2, v) + MPow(2, n - 1 - v);
			c += MPow(2, li) + MPow(2, i - li) + MPow(2, v - li) + MPow(2, n - 1 + li - i - v);
			c = MInt(c);
		}
		Console.WriteLine(c);
	}

	const int M = 998244353;
	static long MPow(long b, long i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}
	static long MInt(long x) => (x %= M) < 0 ? x + M : x;
}


Measured memory_bytes: 41240
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};

// const int C ;
// const int M = 1000000007;

ll N;
ll x;
ll a[2010];
ll b[2010];
ll t[2010];

int main () {
  cin >> N;
  cin >> x;
  for (auto i = 0; i < N; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  ll ans = 0;
  for (auto i = 0; i < N; i++) {
    ans += a[i];
  }
  for (auto i = 1; i < N; i++) {
    //cerr << "i = " << i << endl;
    for (auto j = 0; j < N; j++) {
      t[j] = min(b[j], a[(j-i+N)%N]);
    }
    for (auto j = 0; j < N; j++) {
      b[j] = t[j];
    }
    ll tans = x * i;
    for (auto j = 0; j < N; j++) {
      tans += b[j];
    }
    ans = min(ans, tans);
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#ifndef _WIN32
#include<iostream>
#endif // !_WIN32

#include<queue>
#include<algorithm>
#include<vector>
#include<tuple>
#include<iomanip>

using namespace std;

typedef long long LL;
const LL INF = 1e17;


#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

int N, M, K;

int st[123];
int mon[2123];
double arrive_time[112][2123];
double open_time[112][2123];
double op[2123];
double cl[2123];
double v[123];





int main() {
	cout << fixed;
	cout << setprecision(10);
	while (cin >> N >> M >> K, N + M + K) {
		REP(i, 2123)mon[i] = 0;
		K += 500;
		REP(i, N) {
			int X, Y; cin >> X; X += 500;
			mon[X] = 1;
			double l, f, d;
			cin >> l >> f >> d;
			cin >> Y;

			if (Y) {
				//------_____
				op[X] = l / f;
				cl[X] = l / d;
				open_time[0][X] = op[X];
			}
			else {
				//______------
				op[X] = l / d;
				cl[X] = l / f;
				open_time[0][X] = 0;
			}
		}
		REP(i, M) {
			cin >> v[i];
			st[i] = 500-i;
			arrive_time[i][st[i]] = 0;
		}
		{
			FOR(j, st[0], K + 300) {
				if (mon[j]) {
					double out = max(arrive_time[0][j], open_time[0][j]) + cl[j];
					arrive_time[0][j + 1] = out + 1 / v[0];
					open_time[1][j] = out + op[j];
				}
				else {
					arrive_time[0][j + 1] = arrive_time[0][j] + 1 / v[0];
				}
			}
		}
		FOR(i,1, M) {
			FOR(j, st[i], K+300) {
				if (mon[j]) {
					double out = max(arrive_time[i][j], open_time[i][j]) + cl[j];
					arrive_time[i][j + 1] = max(out + 1 / v[i],arrive_time[i-1][j+2]);
					open_time[i+1][j] = out + op[j];
				}
				else {
					arrive_time[i][j + 1] = max(
						arrive_time[i][j] + 1 / v[i]
						,arrive_time[i-1][j+2]);
				}
			}
		}
		cout << arrive_time[M - 1][K] << endl;
	}
}

Measured memory_bytes: 5856
// #include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#define pb emplace_back
#define LOCAL
  
using namespace std;
  
const int inf = 0x3f3f3f3f;
const int maxn = 1e5+5;
typedef long long ll;
typedef pair<int,int> Pii;
 
template <typename T>inline void read(T& t){
    char c=getchar();t=0;
    int f=1;
    while(!isdigit(c)){
       if(c=='-')f=-1;
        c=getchar();
    }
    while(isdigit(c))t=t*10+c-48,c=getchar();
    t=f*t;
}
  
template <typename T,typename... Args> inline void read(T& t,Args&... args){
    read(t);read(args...);
}

int n,m;
int a[maxn<<1];
int f[maxn<<1];

int find(int x){
    return f[x]==x?x:f[x]=find(f[x]);
}

void merge(int x, int y){
	int tx=find(x);
	int ty=find(y);
	if(tx!=ty){
        f[ty] = tx;
    }
}
  
int main(){
    read(n,m);
    for(int i=1;i<=n;i++){
        f[i]=i;
    }
    for(int i=1;i<=m;i++){
        int u,v;
        read(u,v);
        if(find(u)!=find(v)){
            merge(u,v);
        }
    }
    int ans=-1;
    for(int i=1;i<=n;i++){
        int tmp=find(i);
        a[tmp]++;
        ans=max(a[tmp],ans);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4812
# ABC 060 D
N, W = map(int,input().split())
L = [list(map(int,input().split())) for k in range(N)]

wmin = L[0][0]
M = [[],[],[],[]]
for load in L:
    M[load[0]-wmin].append(load[1])

M0 = sorted(M[0])[::-1]
M1 = sorted(M[1])[::-1]
M2 = sorted(M[2])[::-1]
M3 = sorted(M[3])[::-1]

ans = 0
for p in range(len(M0)+1):
    for q in range(len(M1)+1):
        for r in range(len(M2)+1):
            for s in range(len(M3)+1):
                weight = p*wmin + q*(wmin+1) + r*(wmin+2) + s*(wmin+3)
                if weight <= W:
                    ans = max(ans,sum(M0[:p])+sum(M1[:q])+sum(M2[:r])+sum(M3[:s]))
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
  int sum=0,ans=100;
  vector<int> V[30];
  string s;
  cin>>s;
  for(int i=0;i<30;i++){
    V[i].push_back(-1);
  }
  for(int i=0;i<s.size();i++){
    V[s[i]-'a'].push_back(i);
  }
  for(int i=0;i<30;i++){
    V[i].push_back(s.size());
  }
  for(int i=0;i<26;i++,sum=0){
    for(int j=1;j<V[i].size();j++){
      sum=max(sum,V[i][j]-V[i][j-1]-1);
    }
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#! /usr/bin/env perl

use strict;
use warnings;

my $one = <>;
my $two = <>;

chomp $one;
chomp $two;

my @atwo =  split / /, $two;

if($atwo[1] == 1){
    print("1\n");
}
else{
    print("0\n");
}

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


int main() {
    int k,n;
    cin>>k>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int maxd=0;
    rep(i,n-1){
        maxd=max(a[i+1]-a[i],maxd);
    }
    maxd=max(a[0]+k-a[n-1],maxd);
    cout<<k-maxd<<endl;
}

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

int main() {
    int16_t a, b, c;
    cin >> a >> b >> c;
    
    int16_t m;
    m = a >= b ? a : b;
    m = c >= m ? c : m;
    int16_t n = m * 3 - a - b - c;

    cout << (n % 2 ? (n + 3) / 2 : n / 2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long
const int YYQ=1e9+7;
int d,dp[10005][105][2];
string s;
signed main(){
	cin>>s>>d;
    dp[0][0][0]=1;
	for(int i=0;i<s.size();i++){
		for(int j=0;j<d;j++){
			for(int k=0;k<2;k++){
				int r=9;
				if(k==0)	r=s[i]-'0';
				for(int S=0;S<=r;S++){
					int gk=k;
					if(S<s[i]-'0')	gk=1;
					dp[i+1][(j+S)%d][gk]=(dp[i+1][(j+S)%d][gk]+dp[i][j][k])%YYQ;
				}
			}
		}
	}
	int ans=(dp[s.size()][0][0]+dp[s.size()][0][1]+YYQ-1)%YYQ;
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 16640
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        m: usize,
        p: i64,
        e: [(usize1, usize1, i64); m],
    }
    let mut g = vec![vec![]; n];
    for (a, b, c) in e {
        let c = p - c;
        g[a].push((b, c));
    }
    let inf = 100000000000000000;
    let mut dp = vec![inf; n];
    dp[0] = 0;
    for _ in 0..n {
        for v in 0..n {
            if dp[v] == inf {
                continue;
            }
            for &(u, c) in g[v].iter() {
                let d = dp[v] + c;
                if d < dp[u] {
                    dp[u] = d;
                }
            }
        }
    }
    let mut q = std::collections::VecDeque::new();
    let mut neg = vec![false; n];
    for v in 0..n {
        if dp[v] == inf {
            continue;
        }
        for &(u, c) in g[v].iter() {
            let d = dp[v] + c;
            if d < dp[u] {
                neg[v] = true;
                q.push_back(v);
                break;
            }
        }
    }
    while let Some(v) = q.pop_front() {
        for &(u, _) in g[v].iter() {
            if neg[u] {
                continue;
            }
            neg[u] = true;
            q.push_back(u);
        }
    }
    if neg[n - 1] {
        println!("-1");
    } else {
        println!("{}", std::cmp::max(0, -dp[n - 1]));
    }
}

fn main() {
    run();
}


Measured memory_bytes: 4476
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

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

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    while(true){
        rep(i,n){
            if(a[i]%2!=0){
                cout << ans << endl;
                return 0;
            }
            a[i] /=2;
        }
        ans++;
    }
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

vector<int> vec;

void pre(){
	set<int> st({3, 5, 7});
	for(auto x : st){
		int y = x;
		int dig = 0;
		while(y){
			dig++; y /= 10;
		}
		if(dig == 9)break;
		st.insert(x*10 + 3);
		st.insert(x*10 + 5);
		st.insert(x*10 + 7);
	}
	for(auto x : st){
		int y = x;
		vector<int> f(10, 0);
		while(y){
			f[y%10]++; y /= 10;
		}
		if(f[3] && f[5] && f[7])vec.push_back(x);
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	pre();
	int n;
	cin>>n;
	cout<<(upper_bound(vec.begin(), vec.end(), n) - vec.begin())<<endl;

	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  string t="";
  re(i, s.size()){
    if((s[i]=='K'||s[i]=='B'||s[i]=='R')&&(t.size()==0||t[t.size()-1]!='A')) t+='A';
    t+=s[i];
  }
  if(t=="AKIHABARA"||t=="AKIHABAR") std::cout << "YES" << '\n';
  else std::cout << "NO" << '\n';
}


Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
typedef long long ll;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
// isPrime
// modpow modinv
// getDigit
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<bool> d(1000006, false);
  vector<ll> a(n);
  map<int, int> mp;
  rep(i, n) {
    cin >> a[i];
    mp[a[i]]++;
  }
  sort(ALL(a));
  ll ans = 0;
  rep(i, n) {
    if (!d[a[i]] && mp[a[i]] == 1) {
      ans++;
    }
    if (d[a[i]]) {
      continue;
    }
    ll c = 1;
    while (a[i] * c < 1000006) {
      d[a[i] * c] = true;
      c++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 14244
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
using namespace std;
typedef long long ll;

int n, nRow, nCol;

pair<int,int> ps[200000+10];
vector<pair<int,int> > rs[200000+10];

int main(void) {
  scanf("%d%d%d", &nCol, &nRow, &n);
  REP(i, n) {
    int c, r;
    scanf("%d%d", &c, &r);
    ps[i] = make_pair(r-1, c-1);
  }
  sort(ps, ps + n);

  // 各行をrangeに分割
  int lastR = 0;
  int lastC = 0;
  REP(idx, n) {
    int r = ps[idx].first;
    int c = ps[idx].second;
    for(; lastR < r; ++lastR) {
      int ced = nCol;
      if(lastC < ced) {
        rs[lastR].push_back(make_pair(lastC, ced));
      }
      lastC = 0;
    }
    int ced = c;
    if(lastC < ced) {
      rs[r].push_back(make_pair(lastC, ced));
    }
    lastC = c+1;
  }
  for(; lastR < nRow; ++lastR) {
    int ced = nCol;
    if(lastC < ced) {
      rs[lastR].push_back(make_pair(lastC, ced));
    }
    lastC = 0;
  }
  // REP(i, nRow) {
  //   REP(j, rs[i].size()) {
  //     cerr << "[" << rs[i][j].first << "," << rs[i][j].second << ")";
  //   }
  //   cerr << endl;
  // }
  // 上から、到達可能なrangeを保持しながら進む
  // 答えはminC
  int res = nCol;
  vector<pair<int,int> > curRs;
  curRs.push_back(make_pair(-1, 1));
  REP(i, nRow) {
    vector<pair<int,int> > nextRs;
    const vector<pair<int,int> > &row = rs[i];
    int i2 = 0;
    REP(i1, curRs.size()) {
      int bg1 = curRs[i1].first + 1;
      int ed1 = curRs[i1].second;
      for(;;) {
        if(i2 >= (int)row.size()) break;
        int bg2 = row[i2].first;
        int ed2 = row[i2].second;
        if(ed2 <= bg1) {
          i2++;
          continue;
        } else if(ed1 <= bg2) {
          break;
        } else {
          // cerr << i << ": [" << bg2 << ", " << ed2 << ")" << endl;
          res = min(res, ed2);
          nextRs.push_back(make_pair(max(bg1, bg2), ed2));
          i2++;
        }
      }
    }
    curRs.swap(nextRs);
  }
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 13568
n,m=map(int,input().split())

a=[int(input()) for _ in range(m)]

dp=[0]*(n+1)

broken=[0]*(n+1)

for aa in a:
    broken[aa]=1

dp[0]=1
if broken[1]==0:
    dp[1]=1

mod=10**9+7

for i in range(2,n+1):
    if broken[i]==0:
        dp[i]=(dp[i-1]+dp[i-2])%mod

print(dp[-1])



Measured memory_bytes: 77436
#include<stdio.h>

int main(){
    int n, m, i, j, f;
    scanf("%d %d", &n, &m);
    int s[m], c[m];
    for(i=0;i<m;i++){
        s[i]=0; c[i]=0;
        scanf("%d %d",&s[i], &c[i]);
    }
    for(i=0;i<m-1;i++){
        for(j=i+1;j<m;j++){
            if(s[i]==s[j]&&c[i]!=c[j]){ printf("-1"); return 0; }
        }
    }
    for(i=1;i<=n;i++){
        f=0;
        for(j=0;j<m;j++){
            if(s[j]==1&&c[j]==0&&n>1){ printf("-1"); return 0; }
            else if(i==s[j]){ printf("%d",c[j]); f=1; break; }
        }
        if(f==0&&i==1&&n>1){ printf("1"); }
        else if(f==0){ printf("0"); }
    }
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
	int n, num[100];
	while (cin >> n, n) {
		int k = -1;
		do {
			num[++k] = n % 8;
			if (num[k] >= 5) num[k] += 2;
			else if (num[k] >= 4) ++num[k];
		} while (n /= 8);
		for (int i = k; i >= 0; --i) cout << num[i];
		cout << endl;
	}
return 0;
}

Measured memory_bytes: 864
import java.util.*;

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

    Map<Integer, Long> map = new HashMap<>();
    map.put(0, 1L);
    for(int i = 0, sum = 0; i < N; i++){
      sum = (sum + sc.nextInt()) % M;
      map.put(sum, map.getOrDefault(sum, 0L) + 1);
    }
    long ans = 0L;
    for(long i : map.values()){
      ans += i * (i - 1) / 2;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 61592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    ll ans=0;
    rep(0,i,n){
        ll a;
        cin>>a;
        if(i%2==0&&a%2==1)++ans;
    }
    cout<<ans;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define eb emplace_back


typedef long long ll;
typedef long double ld;


const ll inf = 2e9;
const ll base = 998244353;
ll mod = 1e9 + 7;


int main() {
//    srand(time(NULL));
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
//    std::random_device rd;
//    std::mt19937 g(rd());

    auto start = clock();
    string s; cin >> s;
    int n = s.length() + 1;
    vector<int> a(n), b(n);
    a[0] = 0;
    b[n - 1] = 0;
    for (int i = 1; i < n; ++i) {
        if (s[i - 1] == '>') {
            a[i] = 0;
        } else {
            a[i] = a[i - 1] + 1;
        }
    }
    for (int i = n - 2; i >= 0; --i) {
        if (s[i] == '>') {
            b[i] = b[i + 1] + 1;
        } else {
            b[i] = 0;
        }
    }


    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += max(a[i], b[i]);
    }
    cout << ans << endl;




    std::cerr << double(clock() - start) / CLOCKS_PER_SEC << std::endl;
    return 0;
}

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

using namespace std;

int n, a[210000];
set <pair<int, int> > Set;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) {
		Set.insert(make_pair(a[i], i));
	}
	int ans = 0;
	for (int i = n; i; i--) {
		if (Set.count(make_pair(a[i], i))) {
			Set.erase(make_pair(a[i], i));
			for (int j = 30; j >= 0; j--)
				if ((1 << j) > a[i]) {
					int c = (1 << j) - a[i];
					auto it = Set.lower_bound(make_pair(c, 0));
					if (it != Set.end() && it -> first == c) {
						Set.erase(it);
						ans++;
						break;
					}
				}
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 10368
#include<stdio.h>
int main()
{
    char s[4];
    int i,c=0;
     for(i=0;i<4;i++){
        scanf("%c",&s[i]);
     }
     for(i=0;i<4;i++){
        if(s[i]=='+'){
        c++;}

     else
        c--;

     }
     printf("%d",c);

 return 0;
}



Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void){
    long x;
    cin >> x;
    if(x < 7){
        cout << 1 << endl;
    }else if(x < 12){
        cout << 2 << endl;
    }else{
        cout << (x / 11) * 2 + (x%11!=0) + (x%11>6) << endl;
    }
}

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

int main(void)
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    

    int cnt = 0;
    for(int i = 0; i < n; i++)
    {   
        cin >> h.at(i);
        if(h.at(i) >= k) cnt++;
    }

    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>){
    var a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    var c = readLine()!!.toInt()
    val d = readLine()!!.toInt()
    if(a>b){
        a=b
    }
    if(c>d){
        c=d
    }
    print(a+c)
}

Measured memory_bytes: 31996
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    d, t, s = map(int, input().split())

    aa = t * s

    if aa >= d:
        print("Yes")
    else:
        print("No")


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """1000 15 80"""
        output = """Yes"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """2000 20 100"""
        output = """Yes"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """10000 1 1"""
        output = """No"""
        self.assertIO(test_input, output)

    # 自作テストパターン
    def test_original(self):
        pass


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


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

int main() {
  char l;
  cin >> l;
  if (l=='a'||l=='e'||l=='i'||l=='o'||l=='u') {
  cout << "vowel" << endl;
  }
  else
    cout << "consonant" << endl;
}

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

const int COMMAX = 2000;
const int MOD = 1000000007;
vector<long long> fac, finv, inv;

void InitializeCombination(void){
    fac.push_back(1LL);
    fac.push_back(1LL);
    finv.push_back(1LL);
    finv.push_back(1LL);
    inv.push_back(0LL); //Though 0^(-1) cannot be defined, there should be some number in inv[0]
    inv.push_back(1LL);
    for (int i = 2; i < COMMAX; i++){
        fac.push_back(fac[i-1] * (long long)i % (long long)MOD);
        inv.push_back((long long)MOD - inv[MOD%i] * (long long)(MOD/i) % (long long)MOD);
        finv.push_back(finv[i-1] * inv[i] % (long long)MOD);
    }
}

long long Combination(int n, int r){
    if (n < r) return 0LL;
    if (n < 0 || r < 0) return 0LL;
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
}

int main(void){

    int K, N;
    cin >> N >> K;

    long long res;

    InitializeCombination();

    for(int i=1; i<=K; i++){
        cout << Combination(K-1, i-1)*Combination(N-K+1, i) % MOD << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <vector>
#define ll long long
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;

    cout << (n-1)*(m-1) << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string res[4] = {
		"AC","WA","TLE","RE"
	};
	int N;
	cin >> N;
	int count[4] = { 0,0,0,0 };
	for (int n = 0; n < N; n++) {
		string s;
		cin >> s;
		for (int v = 0; v < 4; v++) {
			if (res[v] == s)count[v]++;
		}
	}
	cout << "AC x " << count[0] << "\n";
	cout << "WA x " << count[1] << "\n";
	cout << "TLE x " << count[2] << "\n";
	cout << "RE x " << count[3] << "\n";
	return 0;
}

Measured memory_bytes: 3192
//他者回答参考
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

ll now;
string s, t;
ll nxt[26][200005];

int main(void) {
    cin >> s >> t;
    ll S = (ll)s.size();
    ll T = (ll)t.size();

    s += s;
    for (ll i=0; i<26; i++) nxt[i][S*2] = S*2;
    for (ll i=S*2-1; i>=0; i--) {
        for (int ch=0; ch<26; ch++) {
            nxt[ch][i] = nxt[ch][i+1];
            nxt[s[i]-'a'][i] = i;
        }
    }

    for (ll i=0; i<T; i++) {
        char ch = t[i]-'a';
        ll x = now%S;
        if (nxt[ch][x] == S*2) {
            puts("-1");
            return 0;
        }
        now += nxt[ch][x]-x+1;
    }
  
    printf("%lld\n", now);

	return 0;
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= c && c <= b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}

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

int main() {
	long long a, b, c, d, e;
	long long N;
	cin >> N >> a >> b >> c >> d >> e;
	long long minMove;
	//a~eの最小値をとる
	minMove = min({ a, b, c, d, e });

	//最後の人がaからbに移動し終わるのは、Nが偶数の時は(N / minMove)で求まり、Nが奇数の時は((N + 1) / minMove)で求まる
	//最後の人がbからeに到達するには4分かかるので+4
	long long ans;
	ans = (N + minMove - 1) / minMove + 4;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
  int n, k;
  cin >> n >> k;
  LL a, b;
  a = n/k;
  if (k % 2 != 0) b = 0;
  else {
    b = 0;
    for (int i=1; i<=n; i++) {
      if (i % k == k / 2) b++;
    }
  }

  cout << a*a*a + b*b*b << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		String S = sc.nextLine();
		String T = sc.nextLine();
		char[] s = new char[S.length()];
		char[] t = new char[T.length()];
		int a = 0;

		for(int i = 0;i<S.length();i++) {
			s[i] = S.charAt(i);
			t[i] = T.charAt(i);
			if(s[i]!=t[i]) {
				a++;
			}
		}
		System.out.println(a);
	}

}


Measured memory_bytes: 42712
def dist(x,y):
    return abs(x[0]-y[0])+abs(x[1]-y[1])
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
flag = 0
t1 = 0
x1,y1 = 0,0
for i in range(N):
    t2,x2,y2 = X[i]
    dt = t2-t1
    d = dist((x1,y1),(x2,y2))
    if dt>=d and (dt-d)%2==0:
        t1,x1,y1 = t2,x2,y2
        continue
    flag = 1
    break
if flag==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 90324
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int first,second;
    while(cin >> first >> second){
        float avg = (first +second)/2.0;
        float rounder = (int)avg+0.5;
        if(avg<rounder) cout << (int)avg << endl;
        else cout <<(int)avg+1 << endl;
    }
}



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

int main(){
    char c[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++) cin >> c[j][i];
    }
    for(int i = 0; i < 3; i++) cout << c[i][i];
    cout << endl;
	
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using Pl = pair<ll, int>;

const int INF = 1001001001;

void Main() {
	string s;
	cin >> s;
	int n = s.size();
	vi dist(26, 0);
	vi end(26, -1);
	
	rep(i, n){
	    int j = s[i] - 'a';
	    dist[j] = max(dist[j], i-end[j]-1);
	    end[j] = i;
	}
    
    rep(j, 26){
        if(end[j] != -1) dist[j] = max(dist[j], n-1-end[j]);
    }
    
    /*
    rep(j, 26) {
        cout << char('a'+j) << ":" << dist[j] << ", ";
        if(j == 12) cout << endl;
    }
    cout << endl;
    */
    
    int ans = n/2;
    rep(j, 26){
        if(end[j] != -1) ans = min(ans, dist[j]);
    }
    
    cout << ans << endl;
    return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

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

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	IOS;
	string s;
	cin >> s;
	int use[26] = {};
	REP(i, s.size()) {
		use[s[i] - 'a']++;
	}
	bool ans = true;
	REP(i, 26) {
		if (use[i] % 2)ans = false;
	}
	cout << (ans ? "Yes" : "No") << endl;
}



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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int H[55];
int PH[55];
int ans;

void func(int L, int t, int X)
{
	if (L == 1)
	{
		ans += min(3LL, X - t - 1);
	}
	else
	{
		t++;
		if (t == X)
		{
			return;
		}
		if (t + H[L - 1] < X)
		{
			t += H[L - 1];
			ans += PH[L - 1];
			t++;
			ans++;
			if (t == X)
			{
				return;
			}
			if (t + H[L - 1] < X)
			{
				ans += PH[L - 1];
			}
			else
			{
				func(L - 1, t, X);
			}
		}
		else
		{
			func(L - 1, t, X);
		}
	}
}

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

	H[1] = 5;
	PH[1] = 3;

	int N, X;
	cin >> N >> X;

	rep(i, 2, N + 1)
	{
		H[i] = 2 * H[i - 1] + 3;
		PH[i] = 2 * PH[i - 1] + 1;
	}

	func(N, 0, X);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
while 1:
	N = map(int,raw_input().split())
	if sum(N) == 0: break
	a,b,c = N[0]+N[3],N[1]+N[4],N[2]+N[5]
	m = min(a,b,c)
	ans = 0
	for i in range(max(0,m-2),m+1):
		ans = max(ans,i+(a-i)/3+(b-i)/3+(c-i)/3)
	print ans

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

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

    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

namespace ConsoleApp87
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);

            int question;
            question = a * b;
            int con = question % 2;
            if (con == 0)
            {
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");
            }

        }
    }
}


Measured memory_bytes: 11092
fun main(args: Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val monsters = readLine()!!.split(" ").map { it.toLong() }.sorted()
    println(if (n <= k) 0 else monsters.subList(0, n-k).reduce { acc, i -> acc + i })
}


Measured memory_bytes: 84036
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
typedef pair<int,int> pii;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

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

void solve(){

    int n;
    cin >> n;

    int ord[n+2];
    int p[n+1];
    int ex[n+1];

    for(int i = 1;i<=n;i++)cin >> ord[i];
    for(int i = 1;i<=n;i++)cin >> p[i];
    for(int i = 1;i<n;i++)cin >> ex[i];

    ord[n+1] = 0;
    int ans =0;

    for(int i = 1;i<=n;i++){
        if(ord[i]+1==ord[i+1]){
            ans+=p[ord[i]]+ex[ord[i]];
        }
        else ans+=p[ord[i]];
    }

    cout << ans << endl;
} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 256