akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <utility>

int H, W, val;
std::queue<std::pair<int, int>> q, next_q;

void dfs(std::vector<std::string> const& mat, char c, std::vector<std::vector<int>>& times,int x, int y) {
	if(times[x][y] == -1) times[x][y] = val;

	if (x < H - 1 && times[x + 1][y] == -1 && mat[x + 1][y] == c) {
		dfs(mat, c, times, x + 1, y);
	}
	if (y < W - 1 && times[x][y + 1] == -1 && mat[x][y + 1] == c) {
		dfs(mat, c, times, x, y + 1);
	}

	if (x < H - 1 && y < W - 1) {
		if (times[x + 1][y] == -1 || times[x][y + 1] == -1) next_q.push({ x,y });
	}
	else if (x < H - 1) {
		if (times[x + 1][y]) next_q.push({ x,y });
	}
	else if(y < W-1){
		if (times[x][y + 1] == -1) next_q.push({ x,y });
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin >> H >> W;
	std::cin.ignore();
	std::vector<std::string> mat(H);
	std::vector<std::vector<int>> times(H, std::vector<int>(W, -1));
	for (int i = 0; i < H; ++i) getline(std::cin, mat[i]);

	val = 0;
	if (mat[0][0] == '#') dfs(mat, '#', times, 0, 0);
	else dfs(mat, '.', times,0,0);
	while (times[H - 1][W - 1] == -1) {
		while (!next_q.empty()) {
			q.push(next_q.front());
			next_q.pop();
		}
		++val;
		while (!q.empty()) {
			int i = q.front().first;
			int j = q.front().second;
			q.pop();
			if (mat[i][j] == '#') dfs(mat, '.', times, i, j);
			else dfs(mat, '#', times, i, j);
		}
	}
	
	if (mat[0][0] == '.' && mat[H - 1][W - 1] == '.') std::cout << times[H - 1][W - 1] / 2 << '\n';
	else std::cout << times[H - 1][W - 1] / 2 + 1 << '\n';

return 0;
}

Measured memory_bytes: 384
using System;

namespace TaxIncrease
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');
            int eight = int.Parse(str[0]);
            double ten = int.Parse(str[1]);
            int kotae = -1;
            for (int i = 0; i <= 1000; i++)
            {
                if((Math.Floor(i * 0.08) == eight) && (Math.Floor(i * 0.1) == ten))
                {
                    kotae = i;
                    break;
                }
            }

            Console.WriteLine(kotae.ToString());
        }
    }
}


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

using namespace std;



string S;


int main()
{
	cin >> S;

	int ans = 0;
	int current = -1;
	for (unsigned int i = 0; i < S.size(); i++) {
		int n = S.at(i) - 'a';

		if (current < 0) {
			ans++;
			current = n;
		}
		else if(current != n){
			ans++;
			current = n;
		}
		else {
			if (i >= S.size() - 1) {
				break;
			}
			else {
				ans++;
				i++;
				current = -1;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
M = 0
for i in range(N):
  M += B[A[i] - 1]
  if i < N - 1 and A[i] + 1 == A[i + 1]:
    M += C[A[i] - 1]
print(M)

Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}


//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let ch:char = read::<String>().chars().collect::<Vec<char>>()[0];

    println!("{}",
        match ch {
            'A' => 'T',
            'T' => 'A',
            'C' => 'G',
            'G' => 'C',
            _ => '_',
        }
    );
    
}


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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

void solve_A(){
    int n;
    cin >> n;
    int a[n];
    REP(i,n) cin >> a[i];

    int ctr[1000005] = {0};
    for(int i = 0; i < n; i++){
        if(ctr[a[i]] != 0){
            ctr[a[i]] = 2;
            continue;
        }
        for(int j = a[i]; j <= 1000000; j += a[i]){
            ctr[j]++;
        }
    }

    int ans = 0;
    for(int x: a){
        if(ctr[x] == 1) ans++;
    }
    cout << ans << endl;
    
}

int main(void){
    solve_A();
    
    return 0;
}

Measured memory_bytes: 8304
#include <iostream>
#include <cmath>
using namespace std;
int N,A[110];
int main(){
  cin >> N;
  for(int i=0;i<N;i++) cin >> A[i];
  int ans = 0;
  for(int i=0;i<N-1;i++){
	for(int j=i+1;j<N;j++){
      ans = max(ans,abs(A[i]-A[j]));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import product

S = list(input())
a = list(product(['+','-'],repeat=3))

for i in a:
  shiki = S[0]+i[0]+S[1]+i[1]+S[2]+i[2]+S[3]
  if eval(shiki) == 7:
    print(shiki + "=7")
    exit()

Measured memory_bytes: 3060
def prime_list(n):
    '''
    n以下の素数のリストを返す
    '''
    A = list(range(2, n + 1, 1))
    prime = []
    p_max = A.pop(0)    
    while A[-1] >= p_max ** 2:
        for n in A:
            if n % p_max == 0:
                A.remove(n)
        prime.append(p_max)
        p_max = A.pop(0)
    prime.append(p_max)
    prime += A
    return prime

N = int(input())
ans = ['2']
for prime in prime_list(1362):
    if len(ans) < N:
        if prime % 5 == 1:
            ans.append(str(prime))

print(' '.join(ans))


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P)
{
    int i = 0;
    for(int j = 0; j < k; j++)
    {
        llong s = 0;
        while(s + T[i] <= P)
        {
            s += T[i];
            i++;
            if( i == n ) return n;
        }
    }
    return i;
}

int solve()
{
    llong left = 0;
    llong right = 100000 * 10000;
    llong mid;
    while(right - left > 1)
    {
        mid = (left +  right) / 2;
        int v = check(mid);
        if(v >= n) right = mid;
        else left = mid;
    }
    return right;
}

int main()
{
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> T[i];
    llong ans = solve();
    cout << ans << endl;
}



Measured memory_bytes: 3884
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	int H, W;
	cin >> H >> W;
	string s;
	REP(y, H) REP(x, W) {
		cin >> s;
		if (s == "snuke") {
			cout << (char)('A' + x) << (y + 1) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int, P> PP;

int n;
int d1[105000];
int dn[105000];
int memo[105000];
vector<int>G[105000];

void bfs(int s,int *d)
{
	fill(memo, memo + n, 0);
	queue<P> q;
	q.push(P(s,0));
	memo[s] = 1;
	while (!q.empty()) {
		//cout << s << endl;
		P a = q.front(); q.pop();
		int from = a.first;
		int k = a.second;
		d[from] = k;
		for (int i = 0; i < G[from].size(); i++) {
			if (memo[G[from][i]] == 0) {
				memo[G[from][i]] = 1;
				q.push(P(G[from][i], k + 1));
			}
		}
	}
}

int main()
{
	cin >> n;
	int a, b;
	for (int i = 0; i < n-1; i++) {
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	bfs(0, d1);
	bfs(n - 1, dn);

	int cnt1 = 0, cntn = 0;
	for (int i = 0; i < n; i++) {
		if (d1[i] <= dn[i])cnt1++;
		else cntn++;
	}
	if (cnt1 > cntn)cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	
	return 0;
}

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

int main() {
  ll n,tmp;
  string s;
  cin >> n >> s;
  rep(i,sz(s)){
  	tmp=s.at(i)+n;
  	if(tmp>90) s.at(i)=64+tmp-90;
  	else s.at(i)+=n;
  }
  cout << s <<endl;
}


Measured memory_bytes: 256
import Control.Applicative ((<$>))
import Control.Monad
import Data.Complex
import Data.List ((\\), nub, sort)
import Data.Maybe

type Point = Complex Double
type Vector = Complex Double

eps :: Double
eps = 1e-7

dot :: Vector -> Vector -> Double
dot a b = realPart $ conjugate a * b

cross :: Vector -> Vector -> Double
cross a b = imagPart $ conjugate a * b

normalize :: Vector -> Vector
normalize = signum

readWords :: Read a => IO [a]
readWords = map read . words <$> getLine

data Line = Line {
  a :: Double,
  b :: Double,
  c :: Double
}

data LineSeg = LineSeg {
  p :: Point,
  q :: Point,
  l :: Line
}

mkLine :: Point -> Point -> Line
mkLine p1@(x:+y) p2 = Line a b c where
  (nx:+ny) = (p2-p1)*(0:+1)
  a = nx
  b = ny
  c = -(a*x+b*y)

mkLineSeg :: Point -> Point -> LineSeg
mkLineSeg p1 p2 = LineSeg p1 p2 $ mkLine p1 p2

intersect :: Line -> Line -> Maybe Point
intersect (Line a1 b1 c1) (Line a2 b2 c2)
  | abs ((a1:+b1)`cross`(a2:+b2)) < eps = Nothing
  | otherwise = Just (x/det:+y/det)
  where
    det = a1*b2-b1*a2
    x = c2*b1-c1*b2
    y = a2*c1-a1*c2

intersectLS :: LineSeg -> LineSeg -> Maybe Point
intersectLS (LineSeg p1 q1 l1) (LineSeg p2 q2 l2)
  | cpM == Nothing && online && t1 <= t4 && t3 <= t2 = Just p1
  | cpM == Nothing = Nothing
  | onSeg p1 q1 cp && onSeg p2 q2 cp = Just cp
  | otherwise = Nothing
  where
    cpM = intersect l1 l2
    cp = fromJust cpM
    onSeg p q cp = (cp-p)`dot`(cp-q) < eps
    [t1',t2',t3',t4'] = map (`dot` (normalize (q1-p1))) [p1,q1,p2,q2]
    [t1,t2] = sort [t1',t2']
    [t3,t4] = sort [t3',t4']
    proj p q r = p+((r-p)`dot`d:+0)*d where
      d = normalize (q-p)
    online = magnitude (p2-proj p1 q1 p2) < eps
    
main :: IO ()
main = do
  q <- readLn
  qs <- replicateM q $ do
    [x0,y0,x1,y1,x2,y2,x3,y3] <- readWords :: IO [Double]
    let
      p0 = x0:+y0
      p1 = x1:+y1
      p2 = x2:+y2
      p3 = x3:+y3
    return (p0,p1,p2,p3)

  forM_ qs $ \(p0,p1,p2,p3) -> do
    let cp = intersectLS (mkLineSeg p0 p1) (mkLineSeg p2 p3)

    print $ if cp == Nothing
      then 0
      else 1

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

int main(){
  int n;
  double t, a;
  cin >> n >> t >> a;
  double min_value = 100000;
  int min_index = -1;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h[i];
  for(int i = 0; i < n; i++){
    double diff = abs((t - h[i] * 0.006) - a);
    if(diff < min_value){
      min_value = diff;
      min_index = i + 1;
    }
  }
  cout << min_index << endl;
  return 0;
}

Measured memory_bytes: 3772
function Main(input){
var all = input.split(" ");
var N = parseInt(all[0],10);
var A = parseInt(all[1],10);
var B = parseInt(all[2],10);

var na = A*N;
if(na>B){
    console.log(B);
}else{
    console.log(na);
}

}





Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#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 = 2019;
const ll INF = (ll) 1e15;

ll modpow(ll n, ll p, ll mod) {
    ll ret = 1;
    ll r = n;
    while (p > 0) {
        if ((p & 1) == 1) {
            ret = ret * r % mod;
        }
        r = r * r % mod;
        p >>= 1;
    }
    return ret;
}

ll A[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, P;
    cin >> N >> P;
    string S;
    cin >> S;
    A[0] = 1;
    REP(i, N + 1) {
        A[i + 1] = (A[i] * 10) % P;
    }

    ll sum = 0;
    ll ans = 0;
    map<ll, ll> m;
    m[0]++;
    REP(i, N) {
        ll p = modpow(A[i], P - 2, P);
        sum = (sum * 10LL + S[i] - '0') % P;
        ll t = sum * p % P;
        if (P == 2) {
            if ((S[i] - '0') % 2 == 0)
                ans += i + 1;
        }
        else if (P == 5) {
            if ((S[i] - '0') % 5 == 0)
                ans += i + 1;
        }
        else {
            ans += m[t];
        }

        m[t]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5816
N,K = map(int,input().split())
A = list(map(int,input().split()))

def check(x):
  count = 0
  for Ai in A:
    count += (Ai - 1)//x
  
  return count <= K

#めぐる式そのまま
ok = 10**9
ng = 0
while ok-ng > 1:
  mid = (ok + ng)//2
  if check(mid):
    ok = mid
  else:
    ng = mid

print(ok)

Measured memory_bytes: 30892
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
    int l, r, d, k = 0;
    cin >> l >> r >> d;
    for (int i = l; i <= r;++i)
        if (i % d == 0) ++k;
    cout << k;
    return 0;
}


Measured memory_bytes: 3588
import sys
sys.setrecursionlimit(20000000)

s = input()
K = int(input())


def calculate(str, k):
    s = sorted(list(set(str)))
    criteron = s[:k]
    objs = {}
    for index, s in enumerate(str):
        if s in criteron:
            if len(str)+1 > index + 1 + k:
                made = index + 1 + k
            else:
                made = len(str)+1
            for i in range(index+1,made):
                objs.__setitem__(str[index:i],True)

    arr = sorted(objs.keys())

    print(arr[k-1])

calculate(s, K)


Measured memory_bytes: 3516
import math


def calc_koch_curve(left, right, i):
    if i == n:
        return
    mid1 = (2*left[0] + right[0]) / 3, (2*left[1] + right[1]) / 3
    mid2 = (left[0] + 2*right[0]) / 3, (left[1] + 2*right[1]) / 3
    mid3_x = (
        (mid2[0] - mid1[0]) * math.cos(math.pi/3)
        - (mid2[1] - mid1[1]) * math.sin(math.pi/3) + mid1[0])
    mid3_y = (
        (mid2[0] - mid1[0]) * math.sin(math.pi/3)
        + (mid2[1] - mid1[1]) * math.cos(math.pi/3) + mid1[1])
    mid3 = (mid3_x, mid3_y)

    calc_koch_curve(left, mid1, i+1)
    print(*mid1)
    calc_koch_curve(mid1, mid3, i+1)
    print(*mid3)
    calc_koch_curve(mid3, mid2, i+1)
    print(*mid2)
    calc_koch_curve(mid2, right, i+1)


def main():
    global C
    global n
    C = [(0, 0)]
    n = int(input())
    print(0., 0.)
    calc_koch_curve((0, 0), (100, 0), 0)
    print(100., 0.)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5780
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007
 
int main() {
	ll n;
	cin>>n;
	if(n==1){
		cout << 0 << endl;
		return 0;
	}
	ll ans = n*(n-1)/2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long int n,k,l[50],pl=2000000000000,total=0,s[50],totalm=0,count=0,j=-1;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>l[i];
        s[i]=0;
        total+=l[i];
    }
    while(count<n-k){
        j++;
        pl=2000000000000;
        for(int i=0;i<n;i++){
            if(l[i]<pl){
                pl=l[i];
                s[j]=i;
            }
            if(i==n-1){
                totalm+=l[s[j]];
                l[s[j]]=2000000000000;
            }
        }
        count++;
    }
    cout<<total-totalm<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  int n;
  cin >> n;
  vector<int> b(n);
  rep(i, n) cin >> b[i];

  vector<int> ans, res = b;
  while (n--) {
    vector<int> nxt;
    int idx = -1;
    repr(i, n) {
      if (i + 1 == res[i]) {
        idx = i;
        break;
      }
    }
    if (idx == -1) {
      cout << -1 << '\n';
      return 0;
    }
    ans.push_back(idx);
    rep(i, n + 1) {
      if (i != idx) nxt.push_back(res[i]);
    }
    res = nxt;
  }
  reverse(ans.begin(), ans.end());
  for (int i: ans) cout << i + 1 << '\n';
  




  
  return 0;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll n;
    string s,t,ans;
    cin>>n>>s>>t;
    ans = s+t;
    rep(i,n){
        if(s.substr(i,n-i) == t.substr(0,n-i)) ans = s.substr(0,i) + t;
    }
    if(s==t) ans=s;
    cout<<ans.size()<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;

int main(){

  int n;
  cin>>n;
  int st[2]={0};
  int sum=0;
  int a[100000][3];
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin>>a[i][j];
    }
  }

  for(int i=0;i<n;i++){
    sum=0;
    sum+=a[i][1]-st[0]+a[i][2]-st[1];
    if(sum > a[i][0]){
      cout<<"No"<<endl;
      return 0;
    }else if(a[i][0]%2 != sum%2){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;

}

Measured memory_bytes: 1408
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint=====================================
N, K = map(int, input().split())

A, B = map(int, input().split())

H, W = map(int, input().split())

L, R = map(int, input().split())

1行のstring=================================
S, T = input().split()

1行の整数配列================================
P = list(map(int,input().split()))

A = list(map(int,input().split()))
B = list(map(int,input().split()))

D = list(map(int,input().split()))

L = list(map(int,input().split()))
R = list(map(int,input().split()))

T = list(map(int,input().split()))

改行あり整数==================================
X = []
Y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    X.append(x1)
    Y.append(y1)

A = []
B = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    A.append(x1)
    B.append(y1)

Pair = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    Pair.append((x1, y1))


N行M列の初期化====================================
dp = [[VAL] * RETU for i in range(GYO)]

'''

N = int(input())


A = list(map(int,input().split()))

for a in A:
    if a % 2== 0 and (a%3 !=0 and a%5!=0):
        print("DENIED")
        sys.exit()
   
print("APPROVED")


Measured memory_bytes: 5728
a, b, c, k = map(int, input().split())
ans = 0
if k >= a:
    k -= a
    ans += a
    if k >= b:
        k -= b
        if k >= c:
            k -= c
            ans -= c
            print(ans)
        else:
            print(ans - k)
    else:
        print(ans)
else:
    print(k)

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

int main(void)
{
    int n;
    cin >> n;
    vector<int> a(n);
    ll stSum = 0;
    map<int, int> mp;
  	rep(i, n) {
        int nm;
        cin >> nm;
        a[i] = nm;
        mp[nm]++;
      	stSum += nm;
    }
    
    
    
    
    int q;
    cin >> q;
  	rep(i, q) {
          int b, c;
          cin >> b >> c;
          if (mp[b] != 0) {
              stSum += mp[b] * (c - b);
              mp[c] += mp[b];
              mp[b] = 0;
          }
          cout << stSum << endl;
      }
      
}


Measured memory_bytes: 7756
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }


int main(){
    int N, M;
    cin >> N >> M;
    vector<int> v(N);
    int acs = 0;
    int was = 0;
    REP(i, M){
        int p;
        string S;
        cin >> p >> S;
        p--;
        if(v[p] == -1) continue;
        if(S == "AC"){
            acs++;
            was += v[p];
            v[p] = -1;
        }
        if(S == "WA") v[p]++;
    }
    cout << acs << " " << was << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#define N 500001
void max(int);
void build();
int left(int);
int right(int);
int A[N];
int H;
int main()
{
  int i,j;

  scanf("%d",&H);
  for(i=1; i<=H; i++){
    scanf("%d",&A[i]);
  }

  build();

  for(i=1; i<=H; i++){
    printf(" %d",A[i]);
  }

  printf("\n");

  return 0;
}

int left(int i){
  return 2*i;
}

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

void max(int i){
  int l,r,large,temp;
  
  l = left(i);
  r = right(i);

  if(l<=H && A[l]>A[i]) large = l;
  else large = i;

  if(r<=H && A[r]>A[large]) large = r;

  if(large!=i){
    temp = A[i];
    A[i] = A[large];
    A[large] = temp;
    max(large);
  }
}

void build(){
  int i;
  for(i=H/2; i>=1; i--){
    max(i);
  }
}

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

using namespace std;

int main(void){
  int n;

  while(cin >> n && n){
    vector<int> time;
    int tmp;
    long long now=0;
    long long ret=0;
    for(int i=0;i<n;i++){
      cin >> tmp;
      time.push_back(tmp);
    }
    sort(time.begin(), time.end());
    for(int i=0;i<n;i++){
      ret += now;
      now += time[i];
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define F  first
#define S  second
#define ff(i,n) for(i=0;i<n;i++)
ll bg = 1000000000000000000;
ll power(ll x,ll y)
{
	if(y==0)
		return 1;
	ll h=power(x,y/2)%bg;	
	h=(h*h)%bg;
	if(y%2==1)
	  return (x*h)%bg;
	else
	  return h%bg;  
}
ll modinv(ll m)
{
	return power(m,bg-2)%bg;
}
ll sum(ll i)
{
	ll s = (i*(i+1))/2;
	return s;
}
ll g(char d)
{
	return (d-'0');
}
ll ans = 0;
void p(ll n) 
{ 
    ll nn=0,s = 0,count=0;
	// Print the number of 2s that divide n 
    while (n%2 == 0) 
    { 
		n = n/2;
		count++; 
    } 
    ll i,j;
    while(1)
    {
    	nn++;
    	s+=nn;
    	if(s==count)
    	  break;
    	if(s>count)
		{
			nn--;
			break;
		}  
	}
	ans+=nn;
    // n must be odd at this point.  So we can skip  
    // one element (Note i = i +2) 
    for (i = 3; i <= sqrt(n); i = i+2) 
    { 
        // While i divides n, print i and divide n 
        nn=0,s = 0,count=0;
		while (n%i == 0) 
        { 
            count++;
			n = n/i; 
        }
			while(1)
	    {
	    	nn++;
	    	s+=nn;
	    	if(s==count)
	    	  break;
	    	if(s>count)
			{
				nn--;
				break;
			}  
		}
		ans+=nn;
    } 
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2 
    if (n > 2) 
        ans++; 
} 
int main()
{ 
	ll t;
	t=1;
	while(t--)
	{
		ll i,n,m;
		cin>>n;
		p(n);
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

vector<vector<int>> v(222222);
int par[222222];
int chi[222222];
int num[222222];
int tmp[222222];
int visited[222222];

vector<int> getLoeTwo(int a){
	vector<int> ret;
	REP(j, v[a].size()){
		int nu = num[v[a][j]];
		if(nu == -1)continue;
		tmp[nu] = a;
	}
	REP(j, 222222){
		if(tmp[j] != a){
			ret.PB(j);
			if(ret.size() == 2)return ret;
		}
	}
}

bool seica(int s, int a){
	//cout << "seica " << s << " " << a << endl;
	num[s] = a;
	int now = par[s];
	while(now != s){
		num[now] = getLoeTwo(now)[0];
		now = par[now];
	}
	
	return getLoeTwo(s)[0] == num[s];
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	REP(i, 222222)num[i] = tmp[i] = -1;
	ll n;cin >> n;
	REP(i, n){
		cin >> par[i];
		par[i]--;
		v[par[i]].PB(i);
	}
	queue<int> q;
	REP(i, n)if(v[i].size() ==0)q.push(i);
	
	while(!q.empty()){
		int now = q.front();q.pop();
		num[now] = getLoeTwo(now)[0];
		chi[par[now]]++;
		if(chi[par[now]] == v[par[now]].size()){
			q.push(par[now]);
		}
	}
	REP(i, n){
		if(num[i] != -1)continue;
		int now = i;
		//cout << "now " << i << endl;
		auto candi = getLoeTwo(now);
		if(seica(now, candi[0]) || seica(now, candi[1])){
			cout << "POSSIBLE" << endl;
		}
		else {
			cout << "IMPOSSIBLE" << endl;
		}
		
		return 0;
	}
	
	return 0;
}


Measured memory_bytes: 14208
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int x = stdIn.nextInt();
        int a = stdIn.nextInt();

        if (x < a ) {
            System.out.println(0);
        } else {
            System.out.println(10);
        }

    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>

int main(void)
{
	int m, f, r;
	int ii;
	char c;
	char rank[1000];

	int idx = 0;
	for (;;) {
		scanf("%d %d %d", &m, &f, &r);
		scanf("%c", &c);
		if (m == -1 && f == -1 && r == -1) {
			break;
		}
		if (m == -1 || f == -1) {
			rank[idx] = 'F';
		} else if (m + f >= 80) {
			rank[idx] = 'A';
		} else if ((m + f) >= 65 && (m + f) < 80) {
			rank[idx] = 'B';
		} else if ((m + f) >= 50 && (m + f) < 65) {
			rank[idx] = 'C';
		} else if ((m + f) >= 30 && (m + f) < 50) {
			if (r >= 50) {
				rank[idx] = 'C';
			} else {
				rank[idx] = 'D';
			}
		} else {
			rank[idx] = 'F';
		}
		idx++;
	}

	for (ii = 0; ii < idx; ii++) {
		printf("%c\n", rank[ii]);
	}


	return 0;
}

Measured memory_bytes: 600
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let h: usize = read();
    let w: usize = read();

    let ans = (n + 1 - h) * (n + 1 - w);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll k,x;
	rl2(k,x);
	fr(i,x-k+1,x+1)
	{
		if(x>=-1000000)
		{
			cout<<i<<" ";
		}
	}
	fr(i,x+1,x+k)
	{
		if(x<=1000000)
		{
			cout<<i<<" ";
		}
	}
	NL;
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

// ???????????°????????????
int getChar(char ch) {
	switch (ch) {
	case 'A' : return 1;
	case 'C' : return 2;
	case 'G' : return 3;
	case 'T' : return 4;
	default  : return 0;
	}
}

// ?????????????????°??????????????????key?????????
// ???????????\??¢??°
long long getkey(char str[]) {
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++) {
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
	long long key, i, h;
	key = getkey(str);
	for (i = 0;; i++) {
		// ???????????\?????????????????´??????i?????????
		h = (h1(key) + i*h2(key)) % M;
		// ???????????\?????????????????¨?????°????????????????????´????????´???
		if (strcmp(H[h], str) == 0) return 1;
		// ?????´????????? && ??????????????¨???????????????????????\?????????????????´???
		else if (strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]) {
	long long key, i, h;
	key = getkey(str);
	for (i = 0;; i++) {
		h = ((h1(key) + i*h2(key))) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}


int main() {
	int n;
	char com[6], str[L];

	for (int i = 0; i < M; i++) H[i][0] = '\0';

	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%s %s", com, str);
		if (com[0] == 'i') insert(str);
		else if (com[0] == 'f') {
			if (find(str)) printf("yes\n");
			else printf("no\n");
		}
	}
}

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end(), greater<int>());
  int th = a[0] / 2;
  ll mn = a[0];
  ll ans = 0;
  for(int i = 1; i < n; ++i){
    if(mn > abs(a[i] - th)){
      mn = abs(a[i] - th);
      ans = a[i];
    }
  }

  cout << a[0] << " " << ans << endl;

  return 0;
}


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

int main(){
    long long N,A,B;
    cin>>N>>A>>B;
    
    long long ans;

    ans=(B*(N-1)+A)-(A*(N-1)+B)+1;
    
    if(A>B||(A!=B&&N<2))ans=0;
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function arrayIn(){
		$buf = explode(" ", fgets(STDIN));
		return $this->killNewLine($buf);
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->arrayIn();
		
		$n = $s[0];
		$m = $s[1];

		$buf = array();
		$b = array_fill(1, 30, 0);
		$ans = 0;
		
		for($i = 0; $i < $n; $i++){
			$buf = $this->arrayIn();	
			for($j = 0; $j < $buf[0]; $j++){
				switch ($buf[$j + 1]){
					case(1):
					$b[1]++;
					break;
					case(2):
					$b[2]++;
					break;
					case(3):
					$b[3]++;
					break;
					case(4):
					$b[4]++;
					break;
					case(5):
					$b[5]++;
					break;
					case(6):
					$b[6]++;
					break;
					case(7):
					$b[7]++;
					break;
					case(8):
					$b[8]++;
					break;
					case(9):
					$b[9]++;
					break;
					case(10):
					$b[10]++;
					break;
					case(11):
					$b[11]++;
					break;
					case(12):
					$b[12]++;
					break;
					case(13):
					$b[13]++;
					break;
					case(14):
					$b[14]++;
					break;
					case(15):
					$b[15]++;
					break;
					case(16):
					$b[16]++;
					break;
					case(17):
					$b[17]++;
					break;
					case(18):
					$b[18]++;
					break;
					case(19):
					$b[19]++;
					break;
					case(20):
					$b[20]++;
					break;
					case(21):
					$b[21]++;
					break;
					case(22):
					$b[22]++;
					break;
					case(23):
					$b[23]++;
					break;
					case(24):
					$b[24]++;
					break;
					case(25):
					$b[25]++;
					break;
					case(26):
					$b[26]++;
					break;
					case(27):
					$b[27]++;
					break;
					case(28):
					$b[28]++;
					break;
					case(29):
					$b[29]++;
					break;
					case(30):
					$b[30]++;
					break;
					default:
					break;
				}
			}
		}

		for($i = 0; $i < $m; $i++){
			if($n == $b[$i + 1]){
				$ans++;
			}
		}

		echo $ans . "\n";

	}
}
?>


Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] > c[i]) {
      ans += v[i] - c[i];
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

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

    int zero_start_cnt = 0;
    int one_start_cnt = 0;
    for(int i = 0; i < S.size(); i++) {
        if(i % 2 == 0) { // 偶数indexの場合
            if(S[i] != '0'){ // 0ではないとき
                zero_start_cnt++;
            } else {
                one_start_cnt++;
            }
        } else { // 奇数indexの場合
            if(S[i] != '1'){ // 1ではないとき
                zero_start_cnt++;
            } else {
                one_start_cnt++;
            }
        }
    }
    cout << min(zero_start_cnt, one_start_cnt) << endl;
}


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

double INF = 1e100;
double EPS = 1e-12;
typedef long long int ll;

typedef pair < int,int > PII;
typedef pair < ll,ll > PLL;
#define F first
#define S second
ostream& operator<<(ostream & os, PLL h)
{
	return os << "( " << h.F << ", " << h.S << " )" << endl;

}
PLL operator+ (PLL a, ll x)     {return {a.F + x, a.S + x} ;}
PLL operator- (PLL a, ll x)     {return {a.F - x, a.S - x} ;}
PLL operator* (PLL a, ll x)     {return {a.F * x, a.S * x} ;}
PLL operator+(PLL x, PLL y) { return {x.F + y.F,x.S + y.S} ;}
PLL operator-(PLL x,PLL y) { return {x.F - y.F, x.S - y.S} ;}
PLL operator*(PLL x,PLL y) { return {x.F * y.F , x.S * y.S} ;}
PLL operator%(PLL x,PLL y) { return {x.F % y.F, x.S % y.S} ;}

PLL base = {37,41};
PLL M = {1e9+21, 1e9+9};

int const N = 1e6 + 5;
int const LOG = 11;


int main(){

	ios::sync_with_stdio(false); cin.tie(0);

    string ara[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

    string ans;
    cin >> ans;

    int now = 0;
    for( ; now < 7; now++)
    {
        if(ara[now] == ans) break;
    }
    cout << (7 - now) << endl;
    return 0;
}


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

submit = []
for i in range(m):
    temp = [x for x in input().split()]
    submit.append(temp)

ac = [0] * (n + 1)
wa = [0] * (n + 1)

for i in range(m):
    result = submit[i][1]
    question = int(submit[i][0])

    if result == 'AC' and ac[question] == 0:
        ac[question] = 1
    elif result == 'WA' and ac[question] == 0:
        wa[question] += 1

for i in range(n + 1):
    if ac[i] != 1:
        wa[i] = 0

print(sum(ac), sum(wa))


Measured memory_bytes: 33476
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (d == 1 ? 1 : 0) << endl;
}


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

int main()
{
    int A, B;
    cin >> A >> B;

    for(int i=0;i<10000;++i)
    {
        int a = i*8/100;
        int b = i*10/100;
        if(a==A && b==B)
        {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#include <queue>
#include <deque>
#define int long long
using namespace std;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, ai;
    cin >> n;
    int x[100001];
    for (int i=0; i <=100000; i++){
        x[i] = 0;
    }
    for (int i=0; i < n; i++){
        cin >> ai;
        x[ai]++;
        if (ai-1 >= 0) x[ai-1]++;
        if (ai+1 <= 100000) x[ai+1]++;
    }
    int mm = 0;
    for (int i=0; i <= 100000; i++){
        mm = max(mm, x[i]);
    }
    cout << mm << endl;
    return 0;
}


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

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

    vector<int> a(n);
    rep(i,n) {
        if (s[i] == 'R') a[i] = 0;
        if (s[i] == 'G') a[i] = 1;
        if (s[i] == 'B') a[i] = 2;
    }

    vector<ll> cnt(3);
    rep(i,n) cnt[a[i]]++;
    ll ans = 1;
    rep(i,3) ans *= cnt[i];
    rep(j,n)rep(i,j) {
        int k = j + (j-i);
        if (k < n) {
            if (a[i] == a[j]) continue;
            if (a[i] == a[k]) continue;
            if (a[k] == a[j]) continue;
            ans--;
        }
    }

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

Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define mod 10007
using  namespace std;
int maxn (int a,int b,int c){return max(max(a,b),max(b,c));}
int main()
{
    char a[100],b[100],c[100];
    scanf("%s%s%s",a,b,c);
    printf("%c%c%c\n",a[0],b[0],c[0]);
    return 0;
}


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

int main(){
  int x, y;
  bool judge=false;
  cin >> x >> y;
  if(y == 4 * x) judge = true;
  for(int i=0; i<x; i++){
    if((y - 4 * i) == (2 * (x - i))){
      judge=true;
      break;
    }
  }
  if(judge)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
    int n; cin >> n;
    vector<int> a(n+1), b(n);
    rep(i,n+1) cin >> a[i]; rep(i,n) cin >> b[i];
    ll ans = 0;
    for(int i = n-1; i >= 0; i--) {
        if(b[i] >= a[i+1]){
            ans += a[i+1];
            b[i] -= a[i+1];
        }
        else{
            ans += b[i]; 
            b[i] = 0;
        }
        if(a[i] >= b[i]){
            ans += b[i];
            a[i] -= b[i];
        }
        else { 
            ans += a[i];
            a[i] = 0;
        } 
        a.pop_back();
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, m;
  cin >> n >> m;
  int l[m], r[m];
  REP(i, m) cin >> l[i] >> r[i];
  int lo = 0, hi = 1e9;
  REP(i, m) {
    lo = max(lo, l[i]);
    hi = min(hi, r[i]);
  }
  cout << max(0, hi - lo + 1) << endl;
  return 0;
}

Measured memory_bytes: 1024
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}



int main(){
	FIO
	
	queue<int> s[1100];
	int n, q;
	cin >> n >> q;
	while(q--){
		int op, t;
		cin >> op >> t;
		if(op == 0){
			int x;
			cin >> x;
			s[t].push(x);
		}else if(op == 1){
			if(s[t].empty());
			else cout << s[t].front() << '\n';
		}else{
			if(!s[t].empty())
				s[t].pop();
		}
	}
	return 0;
}



Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int count,i,n,j,sum,k;
    count=1;
    sum=1;
    string s,p,q;
    cin >> s;
    n=s.size();
    p=s.substr(0,1);
    k=0;
    for(i=0;i<n;i=i+k){
        k=0;
        for(j=1;j<n;j++){
            k++;
            if(sum+j>n){
                break;
            }
          q=s.substr(i+1,j);
          if(p!=q){
          p=q;
          count++;
          sum+=j;
          break;
          }          
        }
      if(n<=sum){
          break;
      }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
using namespace std;
typedef long long ll;
int inf = 1000000000;
template<typename T>
T GCD(T a, T b) {
	while (max(a, b) % min(a, b)) {
		if (a > b)a = a % b;
		else b = b % a;
	}
	return min(a, b);
}
template<typename T>
T LCM(T a, T b) {
	return a / GCD(a, b)*b;
}
ll a, r[200010];
map<ll, ll>mp;
int main() {
	int n;
	ll ans = 0;
	cin >> n >> r[0];
	for (int i = 1; i < n; i++) {
		cin >> a;
		r[i] = r[i - 1] + a;
	}
	mp[0] = 1;
	for (int i = 0; i < n; i++) {
		ans += mp[r[i]];
		mp[r[i]]++;
	}
	cout << ans << endl;
	return 0;
}

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

const int C = 26;
const int D = 365;

int d;
int c[C];
int s[D][C];

vector<int> t;

void read() {
  scanf("%d", &d);
  for (int i = 0; i < C; ++i) scanf("%d", &c[i]);
  for (int i = 0; i < d; ++i) {
    for (int j = 0; j < C; ++j) {
      scanf("%d", &s[i][j]);
    }
  }
}

int score[D];
int lst[D];
int eval(vector<int> t) {
  int cur = 0;
  for (int i = 0; i < D; ++i) lst[i] = -1;
  for (int i = 0; i < t.size(); ++i) {
    cur += s[i][t[i]];
    lst[t[i]] = i;
    for (int j = 0; j < C; ++j) {
      cur -= (i - lst[j]) * c[j];
    }

    score[i] = cur;
  }

  return cur;
}

vector<int> greedy() {
  vector<int> t;
  for (int i = 0; i < d; ++i) {
    t.push_back(0);
    for (int j = 1; j < C; ++j) {
      vector<int> nt = t;
      t.back() = j;
 
      if (eval(nt) > eval(t)) {
        t = nt;
      }
    }
  }
  return t;
}

vector<int> greedy2() {
  vector<int> t = {0};
  for (int i = 1; i < C; ++i) {
    vector<int> nt = t;
    t.back() = i;
    if (eval(nt) > eval(t)) t = nt;
  }

  for (int i = 1; i < d; i += 2) {
    t.push_back(0); t.push_back(0);
    for (int j = 0; j < C; ++j) {
        for (int jj = 0; jj < C; ++jj) {
        vector<int> nt = t;
        t.back() = jj;
        t[t.size() - 2] = j;
   
        if (eval(nt) > eval(t)) {
          t = nt;
        }
      }
    }
  }
  return t;
}

void solve() {
  t = greedy2();

  for (int k = 0; k < 10; ++k) {
    for (int i = 0; i < d; ++i) {
      for (int j = 0; j < C; ++j) {
        vector<int> nt = t;
        nt[i] = j;
        if (eval(nt) > eval(t)) t = nt;
      }
    }
  }
}

void print() {
  for (int i = 0; i < d; ++i) printf("%d\n", t[i] + 1);
}

void printScore() {
  eval(t);
  for (int i = 0; i < d; ++i) printf("%d\n", score[i]);
}

int main() {
  read();
  solve();
  print();
  // cerr << eval(t) << endl;
  // printScore();
  return 0;
}


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

#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

ll frog(vector<ll> &v,vector<ll> &dp,ll i,ll k)
{
    if(i==0)
        return 0;
    if(dp[i]!=-1)
        return dp[i];

    set<ll> s;
    for(ll j=1;j<=k;j++)
    {
        if(i-j>=0)
        {
            s.insert(abs(v[i]-v[i-j])+frog(v,dp,i-j,k));
        }
        else
        {
            break;
        }
    }

    return dp[i] = *s.begin();
}

int main(){

    IOS;

    ll t,n,k,m;
    t=1;
    while(t--)
    {
        cin >> n >> k;
        vector<ll> v(n);
        vector<ll> dp(n,-1);
        for(ll i=0;i<n;i++)
            cin >> v[i];

        ll ans = frog(v,dp,n-1,k);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 17408