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

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

    int n, k, q;
    cin >> n >> k >> q;
    int corr[100000] = {0};
    for (int i = 1; i <= q; ++i) {
        int a; cin >> a;
        corr[a] += 1;
    }

    for (int i = 1; i <= n; ++i) {
        if (k - (q - corr[i]) > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" <<endl;
        }
    }

    return 0;
}

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


//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = 1e18;
const ll SIZE = 1e5+5;
const ll mod = 1e9+7;

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

ll a[SIZE];
ll gp[SIZE]; ///PREFIX GCD
ll gs[SIZE]; ///SUFFIX GCD

int main() {
    ll t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
    scl1(n);

    for1(i, n) scl1(a[i]);

    if(n == 2) {
        cout << max(a[1], a[2]) << "\n";
        return 0;
    }

    g = a[1];
    for1(i, n) gp[i] = gcd(a[i], gp[i-1]);

    g = a[n];
    for(i = n; i >= 1; i--) gs[i] = gcd(a[i], gs[i+1]);

    for1(i, n) ans = max(ans, gcd(gp[i-1], gs[i+1]));

    printl(ans);


    return 0;
}



Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod=1e9+7;
ll dp[3000]={0};
int main()
{
	ll v;
	scanf("%lld",&v);
	if(v<3){
		printf("0\n");return 0;
	}
	dp[0]=1;
	for(ll i=0;i<=v;i++){
		for(ll j=3;j+i<=v;j++){
			dp[j+i]=dp[j+i]+dp[i];
			dp[j+i]=dp[j+i]%mod;
		}
	} 
	printf("%lld\n",dp[v]);
}

Measured memory_bytes: 3832
from math import hypot
from math import factorial

n = int(input())
a = [tuple(map(int, input().split())) for _ in range(n)]
m = factorial(n - 1)
ret = 0
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        ret += hypot(a[i][0] - a[j][0], a[i][1] - a[j][1]) * m
print(ret / factorial(n))

Measured memory_bytes: 3064
package main

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

var (
	N, Q int
	to   [][]int
)

func dfs(v, p int, ans []int) {
	for _, u := range to[v] {
		if u == p {
			continue
		}
		ans[u] += ans[v]
		dfs(u, v, ans)
	}
}

func main() {
	io := NewIo()
	defer io.Flush()

	N, Q = io.readInt(), io.readInt()
	to = make([][]int, N+5)
	for i := 0; i < N-1; i++ {
		a, b := io.readInt(), io.readInt()
		a--
		b--
		to[a] = append(to[a], b)
		to[b] = append(to[b], a)
	}

	ans := make([]int, N)
	for i := 0; i < Q; i++ {
		p, x := io.readInt(), io.readInt()
		ans[p-1] += x
	}
	dfs(0, -1, ans)
	io.printIntSlice(ans)
}

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) readStringLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) readString() string {
	for io.nextToken >= len(io.tokens) {
		line := io.readStringLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) readInt() int {
	i, err := strconv.Atoi(io.readString())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) printStringSlice(a []string) {
	var b []interface{}
	for _, v := range a {
		b = append(b, v)
	}
	io.println(b...)
}

func (io *Io) printIntSlice(a []int) {
	var b []interface{}
	for _, v := range a {
		b = append(b, v)
	}
	io.println(b...)
}

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

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

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}


Measured memory_bytes: 62512
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

x,k,d = map(int,input().split())
x = abs(x)
k0 = x//d
if k0 >= k:
  x-=k*d
  print(x)
else:
  x-=k0*d
  k -= k0
  if k %2 == 0:
    print(x)
  else:
    print(abs(x-d))


Measured memory_bytes: 65344
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<string>s(10);
  s[0]="pon";
  s[1]="pon";
  s[2]="hon";
  s[3]="bon";
  s[4]="hon";
  s[5]="hon";
  s[6]="pon";
  s[7]="hon";
  s[8]="pon";
  s[9]="hon";
  cout<<s[n%10]<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

#define repd(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue();
void inputArray(int*,int);
void inputVector(vector<int>*,int);
template <typename T>
void output(T,int);
int gcd(int a,int b);

int main(){
	//source
	int n,k;
	cin >> n >> k;
	int x[n];
	rep(i,n){
		cin >> x[i];
	}
	ll ans=x[n-1]-x[0];
	ans*=2;
	int r,l;
	rep(i,n-k+1){
		l=x[i];
		r=x[i+k-1];
		ll temp=min(abs(l)+abs(r-l),abs(r)+abs(r-l));
		ans=min(ans,temp);
	}
	cout << ans << endl;
	return 0;
}

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template<typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

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


Measured memory_bytes: 640
//#include"cpp_kyopro.h"
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include<stdio.h>

using namespace std;

int main() {
	int n, m; cin >> n;
	vector<string> vn(n);
	for (int i = 0; i < n; i++) {
		cin >> vn[i];
	}
	cin >> m;
	vector<string> vm(m);
	for (int i = 0; i < m; ++i) {
		cin >> vm[i];
	}
	int maxx=0,ans;

	string s;
	for (int i = 0; i < n; ++i) {
		ans = count(vn.begin(), vn.end(), vn[i]) - count(vm.begin(), vm.end(), vn[i]);
		if (ans > maxx) {
			maxx = ans;
			s = vn[i];
		}
	}
	cout << maxx << endl;
	return 0;
}




Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        var ev = " Eve";
        var D = Console.ReadLine();
        
        var dInt = int.Parse(D);
        var result = "Christmas";
        
        for(int i=0; i<25-dInt; i++) {
            result += ev;
        }
        
        Console.WriteLine(result);
    }
}

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

int main(){
  unsigned long long int n;
  unsigned long long int p;
  cin >> n >> p;
  if (n == 1) {cout << p; return 0;}
  //cout << p << endl;
  unsigned long long int ans = 1;
  unsigned long long int max = pow(p, 1.0/n)+0.5;
  //cout << max <<endl;
  //cout << 'x';
  bool* sosu;
  //sosu = new bool[max+1];
  //cout << 'a';
  //for (unsigned long long int i = 0; i < max+1; i++) sosu[i] = true;
  //cout << 'b';
  for (unsigned long long int i = 2; i < max+1; i++){
     // cout << sosu[i] << " ";
    //if (!sosu[i]) continue;
    //cout << i <<" " << sosu[i] << endl;
    //unsigned long long int mod = pow(i, n)+0.5;
    unsigned long long int check = p;
    bool hantei = true;
    //cout << 'c';
    for (unsigned long long int j = 0; j < n; j++){
      //cout << 'd';
      if(check%i == 0) check = check/i;
      else {hantei = false; break;}
    }
    if(hantei){
       ans = i;
    }
    //else {for(unsigned int k = 1; k<=(max/i); k++) sosu[k*i] = false;}
  }
  //delete[] sosu;
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto S = readln.chomp;
    auto T = S.to!(dchar[]);
    T.reverse();
    S = T.to!string;
    auto N = S.length.to!int;

    auto A = new long[](2020);
    A[0] = 1;
    int tmp = 0;
    auto tmps = new int[](N+1);

    auto ten = 1;

    foreach (i, s; S) {
        tmp += ten * (s - '0');
        tmp %= 2019;
        ten = ten * 10 % 2019;
        A[tmp] += 1;
        tmps[i+1] = tmp;
    }


    long ans = 0;

    foreach_reverse (i, s; S) {
        A[tmp] -= 1;
        ans += A[tmp];
        tmp = tmps[i];
    }

    ans.writeln;
}



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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	cout << max({a+b, a-b, a*b}) << endl;
	return 0;
}


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

int main() {

  int A, B;
  cin >> A >> B;
  
  int c = 0;
  
  int p = 1, q = 0, r = 0;
  
  while (10001 * p + 1010 * q + 100 * r < A) {
    if (r < 9)
      r ++;
    
    else if (q < 9) {
      r = 0;
      q ++;
    }
    
    else {
      r = 0;
      q = 0;
      p ++;
    }
  }
  
//  cout << 10001 * p + 1010 * q + 100 * r << endl;
  
  while  (10001 * p + 1010 * q + 100 * r <= B) {
    c ++;
    
    if (r < 9)
      r ++;
    
    else if (q < 9) {       
      r = 0;
      q ++;
    }
    
    else {
      r = 0;
      q = 0;
      p ++;
    }
  }
  
//  cout << 10001 * p + 1010 * q + 100 * r << endl;
  cout << c << endl;   
    
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int x, y, h;
	int w;
	int i;
	int t;
	int mt = 0;
	
	while (1) {
		scanf("%d", &n);
		
		if (n == 0) {
			break;
		}
		else {	
			for (i = 0; i < n; i++) {
				scanf("%d %d %d %d", &x, &y, &h, &w);
				
				t = x + y + h;
				
				if ((t <= 60) && (w <= 2)) {
					mt += 600;
				}
				else if ((t <= 80) && (w <= 5)) {
					mt += 800;
				}
				else if ((t <= 100) && (w <= 10)) {
					mt += 1000;
				}
				else if ((t <= 120) && (w <= 15)) {
					mt += 1200;
				}
				else if ((t <= 140) && (w <= 20)){
					mt += 1400;
				}
				else if ((t <= 160) && (w <= 25)) {
					mt += 1600;
				}
			}
			printf("%d\n", mt);	
			mt = 0;
		}
	}
	
	return (0);
}

Measured memory_bytes: 600
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("Three")
    else:print("Four")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())




n = ip()                              #入力整数1つ
#a,b= (int(i) for i in input().split())      #入力整数横2つ
#k,a,b = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
a = input().split()                          #入力文字配列

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
b = len(set(a))
if b==3: j(1)
j(0)

Measured memory_bytes: 5144
N = int(input())

W = [int(i) for i in input().split()]
s1 =0
s2 = sum(W)
res = s2 -s1
for t in range(len(W)):
    s1 = s1+W[t]
    s2 = s2 - W[t]
    if s2 -s1 <0:
        ans = min(abs(s2-s1),abs(res))
        break
    res = s2-s1
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define INF 10000

int N,M;


double wide(int *px ,int *py, int n,double x) {
	double lb=INF,ub=-INF;
	for(int i=0;i<n;i++){
		double x1=px[i],x2=px[(i+1)%n];
		double y1=py[i],y2=py[(i+1)%n];
		if((x1-x)*(x2-x)<=0 && x1!=x2){
			double y=y1+(y2-y1)*(x-x1)/(x2-x1);
			lb=min(lb,y);
			ub=max(ub,y);
		}
	}
	return max(0.0,ub-lb);
}

int main(void){
	while(cin >> M >> N,M|N){
		int pointMx[100],pointMy[100];
		int pointNx[100],pointNy[100];
		for(int i=0;i<M;i++)
			cin >> pointMx[i] >> pointMy[i];
		for(int i=0;i<N;i++)
			cin >> pointNx[i] >> pointNy[i];

		int minM=*min_element(pointMx,pointMx+M),maxM=*max_element(pointMx,pointMx+M);
		int minN=*min_element(pointNx,pointNx+N),maxN=*max_element(pointNx,pointNx+N);

		vector<int> list;
		for(int i=0;i<M;i++) list.push_back(pointMx[i]);
		for(int i=0;i<N;i++) list.push_back(pointNx[i]);
		sort(list.begin(),list.end());

		double ans=0.0;
		for(int i=0;i+1<list.size();i++){
			double a=list[i];
			double b=list[i+1];
			double c=(a+b)/2;
			if(minN <=c && c<= maxN && minM <=c && c<= maxM){
				double fa=wide(pointNx,pointNy,N,a)*wide(pointMx,pointMy,M,a);
				double fb=wide(pointNx,pointNy,N,b)*wide(pointMx,pointMy,M,b);
				double fc=wide(pointNx,pointNy,N,c)*wide(pointMx,pointMy,M,c);
				ans+=(b-a)/6*(fa+ 4.0*fc +fb);
			}
		}
		cout.precision(10);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1292
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

s = input()
n = len(s)
last = []
ans = 0
i = 0
last = []
while i<n:
    if last and s[i]!=last[-1]:
        ans += 2
        last.pop()
        i += 1
    else:
        last.append(s[i])
        i += 1
print(ans)

Measured memory_bytes: 74624
#include <iostream>
#include <vector>

using namespace std;

int main(){


    int n;
    cin >> n;

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

    int ans = 0;

    while (true){

        bool done = true;

        for (int i = 0; i < n; i++){
            if (nums[i] % 2 != 0) done = false; 
        }

        if (!done){
            cout << ans << endl;
            return 0;
        }

        for (int i = 0; i < n; i++){
            nums[i] /= 2;
        }

        ans++;
    }



    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long a[100005],dp[100005][2];
int main()
{
	int n,i;
	cin>>n;
	for(i=1;i<=n;i++) cin>>a[i];
	
	dp[1][0]=a[1];dp[1][1]=a[1]*-1;
	for(i=2;i<=n;i++){
		dp[i][0]=max(dp[i-1][0]+a[i],dp[i-1][1]-a[i]);
		dp[i][1]=max(dp[i-1][0]-a[i],dp[i-1][1]+a[i]);
	}
	
	cout<<dp[n][0];
	return 0;
 } 

Measured memory_bytes: 2560
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{

    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var inputs = Console.ReadLine().Split(' ');
        var A = new long[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = long.Parse(inputs[i]);
        }

        var gcd = A[0];
        for (int i = 1; i < N; i++)
        {
            gcd = Gcd(gcd, A[i]);
        }

        Console.WriteLine(gcd);
    }

    /**
     * ユークリッド互除法(最大公約数)
     * <see cref="https://qiita.com/gushwell/items/e9614b4ac2bea3fc6486"/>
     */
    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
}



Measured memory_bytes: 20832
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}

int main(){
    lint N;
    cin >> N;
    if(N%2==1)cout << 0;
    else{
        lint ans=0,n=10;
        for(int i=1; n<=N;i++){
            ans += N/n;
            n*=5;
        }
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AMultiplication1 solver = new AMultiplication1();
        solver.solve(1, in, out);
        out.close();
    }

    static class AMultiplication1 {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            w.println(s.nextInt() * s.nextInt());
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 25548
N= int(input())
A = [int(i) for i in input().split()] 

ANS = "APPROVED"
for i in range(N):
	if 0 == A[i]%2:
		if 0 != A[i]%3:
			if 0 != A[i]%5:
				ANS = "DENIED"
print(ANS)


Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
	int n, r, i, a[13][4] = { {0} }, x, y;
	char  e;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf(" %c", &e); scanf("%d", &r);
		if (e == 'S')
		{
			a[r-1][0] = 1;
		}
		if (e == 'H')
		{
			a[r-1][1] = 1;
		}
		if (e == 'C')
		{
			a[r-1][2] = 1;
		}
		if (e == 'D')
		{
			a[r-1][3] = 1;
		}
	}
	for (x = 0; x < 4; x++)
	{
		for (y = 0; y < 13; y++)
		{
			if (a[y][x] == 0)
			{
				if (x == 0)
				{
					printf("S %d\n", y + 1);
				}
				if (x == 1)
				{
					printf("H %d\n", y + 1);
				}
				if (x == 2)
				{
					printf("C %d\n", y + 1);
				}
				if (x == 3)
				{
					printf("D %d\n", y + 1);
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 596
#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 P[100005];

int main()
{
    ll N;
    cin >> N;
    REP(i, N)
    {
        ll p;
        cin >> p;
        P[p - 1] = i;
    }

    set<ll> left, right;
    right.insert(-1);
    right.insert(N);
    left.insert(1);
    left.insert(-N);

    ll ans = 0;
    for (int i = N - 1; i >= 0; --i)
    {
        left.insert(-P[i]);
        right.insert(P[i]);
        ll l = -(*left.lower_bound(-P[i] + 1));
        ll r = *right.lower_bound(P[i] + 1);
        ll num = 0;
        if (l >= 0)
        {
            //! 左との組み合わせ
            ll nl = -(*left.lower_bound(-l + 1));
            num += (l - nl) * (r - P[i]);
        }
        if (r < N)
        {
            //! 右との組み合わせ
            ll nr = *right.lower_bound(r + 1);
            num += (P[i] - l) * (nr - r);
        }
        ans += num * (i + 1);
    }
    cout << ans << endl;
    return 0;
}

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

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

    int number=0;
    for (int i = 0; i < s.size(); i++)
    {
        s[i] == '+'?number++:number--;
    }
    
    cout << number;
    return 0;
}

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

int a[10];

int permutations(int arr[], int n) {
  sort(arr, arr + n);
  int mn = INT_MAX;
  do {
    int sum = 0;
    for (int i = 0; i < n; ++i) {
      sum = 10 * ((int) ceil(sum / 10.0));
      sum += a[i];
    }
    mn = min(mn, sum);
  } while (next_permutation(arr, arr + n));
  return mn;
}

// claudio van
int main() {
  for (int i = 0; i < 5; ++i) {
    scanf("%d", &a[i]);
  }
  int ans = permutations(a, 5);
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;
int main(void){
    int N;
    vector<int> C,V,profit;
    cin >> N;
    
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        V.push_back(tmp);
    }
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        C.push_back(tmp);
    }
    for(int i=0;i<N;i++){
        profit.push_back(V.at(i)-C.at(i));
        //cout << profit.at(i) << endl;
    }
    
    int sum=0;
    for_each(profit.begin(), profit.end(), [&](int x) { if(x>0) sum+=x; });
    cout << sum;
}


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

int lcs(const string& X,
    const string& Y) 
{
    int lenX = X.length();
    int lenY = Y.length();
    vector<vector<int>> dp(lenX + 1, vector<int>(lenY + 1));
    for (int i = 1; i <= lenX; ++i) {
        for (int j = 1; j <= lenY; ++j) {
            if (X[i-1] == Y[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else {
                dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
            }
        }
    }
    return dp[lenX][lenY];
}

int main() {
    int q;
    cin >> q;
    vector<string> Xs(q);
    vector<string> Ys(q);
    for (int i = 0; i < q; ++i) {
        cin >> Xs[i];
        cin >> Ys[i];
    }
    for (int i = 0; i < q; ++i) {
        cout << lcs(Xs[i], Ys[i]) << endl;
    }



}


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

using namespace std;

const int INF = 1e9 + 9;

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

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

    vector<int> h(n);
    vector<int> dp(n, INF);

    for (int &x : h)
        cin >> x;

    dp[0] = 0;

    for (int i = 0; i < n; i++)
        for (int j = i + 1; j <= i + k; j++)
            if (j < n)
                dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));

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

Measured memory_bytes: 1024
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll a,b,n;
            cin>>a>>b>>n;
            ll z=min(b-1,n);
            ll ans=(a*z)/b;
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 3640
#include<stdio.h>
#include<algorithm>
using namespace std;
#define range 100000+10
int N=0;
struct stu{
	int id;
	int rank;
};
bool com(const stu&a,const stu&b){
	return a.rank<b.rank;
}
stu a[range];
int main(){
	scanf("%d",&N);
	int tmp;
	for(int i=0;i<N;i++){
		scanf("%d",&tmp); 
		a[i].id=i;
		a[i].rank=tmp;
	}
	sort(a,a+N,com);
	for(int i=0;i<N-1;i++){
		printf("%d ",a[i].id+1);
	}
	printf("%d",a[N-1].id+1);
	return 0;
}

Measured memory_bytes: 1536
#include <algorithm>
#include <sstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

bool comp(int &a, int &b) {
	return a > b;
}

int main()
{
	int a, b, c, d, e;
	vector<int> A;
	cin >> a >> b >> c >> d >> e;
	A.push_back(a);
	A.push_back(b);
	A.push_back(c);
	A.push_back(d);
	A.push_back(e);
	sort(A.begin(), A.end(), comp);

	for (int i = 0; i < 5; i++) {
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}



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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N,K;
	cin >> N>>K;
    vector<ll> H(N);
    rep(i,N){
        cin>>H[i];
    }
    ll ans=0;
    if(N<=K){
        cout<<0<<"\n";
        return 0;
    }

    sort(H.begin(),H.end(),greater<ll>());
    // ans += K;

    for(int i=K;i<N;i++){
        ans += H[i];
    }
    cout<<ans<<"\n";


	return 0;
}


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

int main(){
    int n, m;
    cin>>m>>n;
    int adap=m;
    int cont=0;
    if(n>1){
        cont=1;
        while(adap<n){
            adap+=(m-1);
            cont++;
        }
    }
    cout<<cont<<endl;
    
    return 0;
}
/*
1 1 1 
1 1 1 1
*/

Measured memory_bytes: 3632
#include <stdio.h>

int main(int argc, char const *argv[]) {
	char str[101];
	int n, m;
	int ans;

	fgets(str, 100, stdin);
	sscanf(str, "%d %d\n", &n, &m);

	if (n*m%2 != 0) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<class V, int ME> class BIT {
public:
    V bit[1<<ME];
    V total(int e) {
        if(e < 0) return 0;
        V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;
    }
    void add(int e, V val) {e++; while(e<=1<<ME) bit[e-1]+=val,e+=e&-e;}
};

const ll MA = 18;
const ll len = (1<<MA);
map<ll,ll> zip;
ll unzip[len];

typedef pair<ll, pll> plll;

ll compress(vector<ll> &x) {
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(),x.end()),x.end());
    for(ll i = 0; i < x.size(); i++){
        zip[x[i]] = i;
        unzip[i] = x[i];
    }
    return x.size();
}

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

    ll Q;
    cin >> Q;
    vector<plll> query;
    vector<ll> A;
    REP(i, Q){
        ll type;
        cin >> type;
        if(type == 1){
            ll a, b;
            cin >> a >> b;
            query.push_back({1, {a, b}});
            A.push_back(a);
        }else{
            query.push_back({2, {0, 0}});
        }
    }
    BIT<ll, MA> bit1, bit2;
    REP(i, len) bit1.bit[i] = 0;
    REP(i, len) bit2.bit[i] = 0;

    compress(A);
    ll B = 0, cnt = 0;
    REP(i, Q){
        //dump(i)
        ll type = query[i].first;
        if(type == 1){
            ll val = query[i].second.first;
            B += query[i].second.second; 
            cnt++;
            bit1.add(zip[val], val);
            bit2.add(zip[val], 1);
        }else{
            ll lb = -1, ub = len;
            while(ub - lb > 1){
                ll m = (ub+lb)/2;
                if(bit2.total(m) >= (cnt+1)/2) ub = m;
                else lb = m;
            }
            ll med = ub;
            ll med_val = unzip[med];
            ll P = (bit1.total(len-1) - bit1.total(med));
            ll Q = med_val * (bit2.total(len-1) - bit2.total(med));
            ll R = (bit1.total(med-1));
            ll S = med_val * (bit2.total(med-1));
            /*
            dump(B)
            dump(P)
            dump(Q)
            dump(R)
            dump(S)
            */
            ll res = B + P + S  - Q - R;
            cout << med_val << " " << res << endl;
        }
    }

    return 0;
}

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

int main() {
 int n,m,maxi,mini;cin>>n>>m;int l[m],r[m];for(int i=0;i<m;i++)cin>>l[i]>>r[i];
  maxi=n;mini=1;
  
  for(int i=0;i<m;i++){
    if(l[i]>mini) mini=l[i];
    if(r[i]<maxi) maxi=r[i];
  }
  
  if(maxi>=mini)cout<<maxi-mini+1<<endl;
  else cout<<0<<endl;
  
  
  
  
}


Measured memory_bytes: 1024
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define bug2(v1,v2)               cerr<<#v1<<" = "<<(v1)<< ' ' << #v2<<" = "<<(v2)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
//const ll mod = 998244353;
const ll mod = 1000000007;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

//////////////////// start /////////////////////////////////
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];

ll dp[MAX];
int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

	cin >> n >> k;
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    for(int i = 1; i <= k; ++i)
    {
        for(int j = 1; j <= n; ++j)
            if(i - a[j] >= 0 && !dp[i - a[j]])
                dp[i] = 1;
    }
    if(dp[k])
        cout << "First";
    else
        cout << "Second";
  
 eNd();
  return 0;
 
}

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

    //long long
    using ll = long long;

    // pair<int, int>
    using PII = pair<int, int>;

    //最大値、mod
    const int MOD = 1000000007;
    const int INF = 1000000000;
    const long long LINF = 1e18;

    //出力系
    #define print(x) cout << x << endl
    #define prints(x) cout << fixed << setprecision(10) << x << endl
    #define printc(x) cout << setw(2) << setfill('0') << x << endl;
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数 
    unsigned gcd(unsigned a, unsigned b) {
      if(a < b) return gcd(b, a);
      unsigned r;
      while ((r=a%b)) {
        a = b;
        b = r;
      }
      return b;
    }

    // 最小公倍数
    unsigned lcm(unsigned a, unsigned b){
        return a / gcd(a, b) * b; 
    }

    // a = max(a, b), a = min(a, b)
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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









int main(){
  string S;
  cin >> S;
  int len = S.length();
  ll ans = 0;
    for(int i = 0; i < (1 << len - 1); i++){
      string target;
      target += S.at(0);
        for(int j = 0; j < len - 1; j++) {
          if(i & (1 << j)) target += '+';
          target += S.at(j + 1);
        }

    ll sum = 0;
    int pos = 0;
    while(target.find('+', pos) != string::npos){
      int nextpos = target.find('+', pos);
      sum += stoll(target.substr(pos, nextpos - pos));
      pos = nextpos + 1;
    }
    sum += stoll(target.substr(pos));
    ans += sum;
}

print(ans);
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!long);
    auto A = s[0];
    auto B = s[1];
    auto C = s[2];
    auto X = s[3];
    auto Y = s[4];
    long ans = 1L << 59;

    for (long ab = 0; ab <= 2 * max(X, Y); ab += 2) {
        long a = max(0, X - ab/2);
        long b = max(0, Y - ab/2);
        ans = min(ans, a * A + b * B + ab * C);
    }

    ans.writeln;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<tuple>
#include<string>
#include<map>
#include<queue>
#include<random>
#include<stack>
#include<algorithm>
#include<list>
#include<deque>
#define _GLIBCXX_DEBUG
using namespace std;
int main(){
  int n,head=0;
  string command;
  deque<int> list;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>command;
    if(command=="insert"){
      int x;
      cin>>x;
      list.push_front(x);
    }
    else if(command=="delete"){
      int x;
      cin>>x;
      for(deque<int>::iterator it=list.begin(); it!=list.end(); it++){
      if(*it==x){
        list.erase(it);
         break;
      }
     }
    }
    else if(command=="deleteFirst"){
      list.pop_front();
    }
    else {
      list.pop_back();
    }
  }
  for(int i=head;i<list.size();i++){
    if(i==list.size()-1)
        cout<<list[i];
    else cout<<list[i]<<" ";
  }
  cout<<endl;
  return 0;
}



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

const Int MOD = 1000000007;
const Int MAX = 200010;


Int fac[MAX], finv[MAX], inv[MAX], fac2[MAX];

void COMinit(Int n) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    fac2[0] = n;
    fac2[1] = n * (n-1) % MOD;
    for (int i=2; i<MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        fac2[i] = fac2[i-1] * (n-i) % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

/*Int COM(Int n, Int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}*/

Int COM2(Int n, Int k) {
    if (n < k) return 0;
    if (k < 0) return 0;
    return fac2[k-1] * finv[k] % MOD;
}


Int modpow(Int a, Int m) {
    Int res = 1;
    while (m > 0) {
        if (m & 1) res = res * a % MOD;
        a = a * a % MOD;
        m >>= 1;
    }
    return res;
}

int main(){ 


    Int n, a, b, ans;
    cin >> n >> a >> b;

    COMinit(n);

    ans = modpow(2,n);

    ans = (ans + (MOD - COM2(n, a))) % MOD;
    ans = (ans + (MOD - COM2(n, b))) % MOD;
    ans = (ans + (MOD - 1)) % MOD;

    cout << ans << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main(){
  //freopen("input.txt", "r", stdin);
  string s;
  int a, b;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'A'){
      a = i;
      break;
    }
  }
  for(int i = s.size() - 1; i >= 0; i--){
    if(s[i] == 'Z'){
      b = i;
      break;
    }
  }
  cout << b - a + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include<math.h>
#include<queue>
#include<stack>
#include<list>
#include<vector>
#include<map>
#include<set>
#define FOR(i,a) for(int i=0;i<a;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define ll long long
int bmap[]={ 0,1,0,-1 };
int amap[]={ 1,0,-1,0 };
using namespace std;
int N;
int A[100][2];
int ans = 0;
void candybfs(int x,int y,int sum) {
	sum += A[x][y];
	if (x == N - 1 && y == 1)ans = max(ans, sum);
	else if (x == N - 1)candybfs(x, y + 1, sum);
	else if (y == 1)candybfs(x + 1, y, sum);
	else {
		candybfs(x, y + 1, sum);
		candybfs(x + 1, y, sum);
	}
}
int main() {
	cin >> N;
	FOR(i, 2)FOR(j, N)cin >> A[j][i];
	candybfs(0, 0, 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<map>
#include<vector>
#include<algorithm>
#include <stdio.h>
#include<set>
#include<string>
#include<math.h>
#include<cmath>
#include<iomanip>
#include<queue>
#include<stack>
#define ll long long
using namespace std;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);


int main() {
	int n;  cin >> n;
	int* arr = new int[n+1];
	for (int i = 1; i <= n; i++)
		cin >> arr[i];
	int* dp = new int[n+1];
	dp[1] = 0;
	dp[2] = abs(arr[2] - arr[1]);
	for (int i = 3; i <= n; i++) 
		dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	
	cout << dp[n];
	return 0;
}


Measured memory_bytes: 1024
import           Control.Monad
import           Data.Maybe
import qualified Data.ByteString.Char8 as BS
import qualified Data.Sequence as Seq

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
  k <- getInt

  let q = Seq.fromList [1..9]

      nextLL q = let x Seq.:< q1 = Seq.viewl q
                     d = x `mod` 10
                     x0 = x * 10  
                     q2 = if d == 0 then q1 else q1 Seq.|> x0 + (d-1)
                     q3 = q2 Seq.|> x0 + d
                     q4 = if d == 9 then q3 else q3 Seq.|> x0 + (d+1)
                 in (x, q4)

      solve n x q | n == 0 = x
                  | otherwise = solve (n-1) x' q'
        where (x', q') = nextLL q

  print $ solve k 0 q

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, c;
    cin >> n >> c;
    vector<vector<int>> D(c, vector<int> (c)), C(n, vector<int> (n));
    vector<vector<int>> r(3);
    vector<vector<int>> d(3, vector<int> (c));

    for (int i = 0; i < c; i++) {
        for (int j = 0; j < c; j++) {
            cin >> D[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> C[i][j];
            r[(i + j) % 3].push_back(C[i][j] - 1);
        }
    }
    for (int q = 0; q < c; q++) {
        for (int p = 0; p < 3; p++) {
            int cst = 0;
            for (auto x: r[p]) {
                cst += D[x][q];
            }
            d[p][q] = cst;
        }
    }
    int ans = INT_MAX;
    for (int i = 0; i < c; i++) {
        for (int j = 0; j < c; j++) {
            for (int k = 0; k < c; k++) {
                if (i == j || j == k || i == k) continue;
                int cst = d[0][i] + d[1][j] + d[2][k];
                ans = min(ans, cst);
            }
        }
    }
    cout << ans << endl;

}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  string S;
  int Q;
  cin >> S >> Q;
  deque<char> ans;
  for (int i = 0; i < S.size(); i++) {
    ans.push_back(S[i]);
  }
  int flag = false;
  for (int i = 0; i < Q; i++) {
    int T;
    cin >> T;
    if (T == 1) {
      flag = !flag;
    } else {
      int F;
      char C;
      cin >> F >> C;
      if (F == 1) {
        if (flag)
          ans.push_back(C);
        else
          ans.push_front(C);
      } else {
        if (flag)
          ans.push_front(C);
        else
          ans.push_back(C);
      }
    }
  }

  if (flag) {
    for (int i = ans.size() - 1; i >= 0; i--) {
      cout << ans[i];
    }
  } else {
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i];
    }
  }
  cout << endl;
}

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

  solve();

  return 0;
}


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

using namespace std;

using lli = long long int;
using ulli = unsigned long long int;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

lli N, B, A, in, Mid, ctc;
vector<lli> H;

lli enough(lli T);

int main(){

	cin >> N >> A >> B;
	for(int i = 0; i < N; i++){
		cin >> in;
		H.push_back(in);
	}
	sort(H.begin(), H.end());
	lli Max= H[N-1] / B;
	if( (H[N-1] % B) != 0) Max++;
	for(int Min = 0; ;){
		dbug(Max);
		dbug(Min);
		if((Max - Min) == 1){

			Mid = Min;
			ctc = enough( Mid );
			dbug(Mid);
			dbug(ctc);
			dbugln;
			if(Mid >= ctc){
				if(Mid-1 < enough(Mid-1)){
					break;
				}else{
					Max--;
					Min--;
				}
			}else{
				if(Mid+1 >= enough(Mid+1)){
					Mid++;
					break;
				}else{
					Max+=2;
					Min+=2;
				}
			}

		}
		if(Min == Max){
			ctc = enough( Min );
			dbug(Mid);
			dbug(ctc);
			dbugln;
			if(Mid >=ctc){
				break;
			}else{
				Max++;
				Min++;
			}
		}
		Mid = (Min+Max)/2;
		ctc = enough( Mid );
		if(Mid < ctc){
			Min = Mid;
		}else{
			Max = Mid;
		}
		dbug(Mid);
		dbug(ctc);
		dbugln;
	}

	cout << Mid << endl;
	return 0;

}

lli enough(lli T){	//T回爆破したとき、全滅に追加ダメージが何回必要かを返す

	lli ret = 0, fst;
	for(int i = 0; i < N; i++){
		fst = H[i] - B*T;
		if(fst <= 0) continue;
		ret += fst / (A-B);
		if( ((H[i] - B*T) % (A-B)) != 0){
			ret++;
		}
	}

	return ret;

}

/*
int main(){
	cin >> N >> A >> B;
	for(int i = 0; i < N; i++){
		cin >> in;
		H.push_back(in);
		sum += in;
	}

	sort(H.begin(), H.end());
	if( (sum % (A + B * (N-1))) != 0 ){
		for(int i = N-1; i > 0; i--){
			if(H[i] <= 0) continue;
			cnt= H[i] / A;
			if(H[i] % A != 0) cnt++;
			for(int j = i-1; j >= 0; j--){
				H[j] -= cnt * B;
			}
			ans += cnt;
		}
	}else{
		ans = sum / (A + B * (N-1));
	}

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


Measured memory_bytes: 1400
S = list(input())
n = len(S)

dict = {}
i = 0
for c in S:
    if c not in dict:
        dict[c] = [False for _ in range(n)]
    dict[c][i] = True
    i += 1

suniq = set(S)

k = 0
for _ in range(n):
    end = False
    for c in suniq:
        end_c = True
        for j in range(len(dict[c]) - k):
            if not dict[c][j]:
                end_c = False
        if end_c:
            end = True
    if end:
        break
    
    k += 1

    for c in suniq:
        for j in range(len(dict[c]) - 1):
            if dict[c][j + 1]:
                dict[c][j] = True
    
print(k)

Measured memory_bytes: 3064