akhauriyash/Code-Regression huggingface dataset:
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int32_t main()
{
   IOS

    int TESTS=1;
  //  cin >> TESTS;
    while (TESTS--)
    {
        ll n;
        cin >> n;
        vi v(n-1);
        int a[200010]={0};
        for(int i=1;i<n;i++)
        {
            cin>> v[i];
            a[v[i]]++;
        }
         for(int i=1;i<=n;i++)
        {
            cout<< a[i]<<endl;
        }




    }
    return 0;
}


Measured memory_bytes: 5556
#include<cstdio>

using namespace std;

int main(){
	int N, i = 0, j = 0;
	char S[1000];

	scanf("%d\n", &N);
	while (scanf("%c", &S[j])==1){
		if (S[j] == 'Y'){
			i = 1;
		}
		if (S[j] == '\n'){
			break;
		}
		j++;
	}

	if (i == 1){
		printf("Four\n");
	}
	else{
		printf("Three\n");
	}

	return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
possess = [0] * N
count = 0

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for k in range(d):
        sunuke_num = A[k]
        possess[sunuke_num - 1] = 1

for i in range(N):
    if possess[i] == 0:
        count += 1

print(count)


Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int maxn = 2e5 + 5;
int n;
int v[maxn];
bool solve(int x) {
    //cout << x << endl;
    int mid = (n / 2);
    for (int i = 1 ; i <= n / 2 ; i++) {
        if (((v[mid-i] >= x) ^ (v[mid-i+1] >= x)) == 0) {
            //cout << v[mid-i] <<' '<<v[mid-i+1] << endl;
            return v[mid-i] >= x;
        }
        if (((v[mid+i] >= x) ^ (v[mid+i-1] >= x)) == 0) {
            //cout << v[mid+i] <<' '<<v[mid+i-1] << endl;
            return v[mid+i] >= x;
        }
    }
    return v[0] >= x;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    n = n * 2 - 1;
    f(n) {
        cin >> v[i];
    }
    int l = 1, r = n;
    while(r - l > 1) {
        int mid = (l + r) >> 1;
        if (solve(mid)) {
            l = mid;
        }
        else {
            r = mid;
        }
    }
    cout << l << '\n';
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int a = 0;
    int b = 0;
    
    int plus = 0;
    int minus = 0;
    int kakeru = 0;
    int result = 0;
    
    scanf("%d %d",&a,&b);
    
    plus = a + b;
    minus = a - b;
    kakeru = a * b;
    
    if (plus >= minus) {
        result = plus;
    }else{
        result = minus;
    }
    if (result >= kakeru) {
        result = result;
    }else{
        result = kakeru;
    }
    
    printf("%d\n",result);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

int main() {
	int X, N; std::cin >> X >> N;
	std::vector<int> P(N);
	int ans = 0;
	for (auto& r : P) std::cin >> r;
	for (auto i{ 0 }; i < 101; ++i) {
		bool flag_m = false;
		bool flag_l = false;
		int less = X - i;
		int more = X + i;
		for (auto j{ 0 }; j < N; ++j) {
			if (less == P[j]) {
				flag_l = true;
			}
			if (more == P[j]) {
				flag_m = true;
			}
		}
		if (flag_l == false) {
			ans = less;
			break;
		}
		if (flag_m == false) {
			ans = more;
			break;
		}
	}
	std::cout << ans << std::endl;
	
	return 0;
}

Measured memory_bytes: 3584
n = int(input())
count = [[[0 for i in range(10)]for j in range(3)]for k in range(4)]
for i in range(n):
    b,f,r,v = map(int,input().split())
    count[b-1][f-1][r-1] += v
i = 0
for floor in count:
    i+=1
    for room in floor:
        for visitor in room:
            print("",visitor,end ="")
        print("")
    if(i!=4):
        print("####################")
    


Measured memory_bytes: 5636
#![allow(unused)]

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
//入力マクロここまで

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return if a > 0 { a } else { -a };
    }
    gcd(b, a % b)
}

fn main() {
    input! {
        a: i64,
        b: i64,
    }

    let n_gcd = gcd(a, b);
    let n_lcm = (a / n_gcd) * (b / n_gcd) * n_gcd;

    println!("{}", n_lcm);
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(){
	long long n,x,ans,a,b,tmpa;
	cin>>n>>x;
	ans=x;a=x;b=n-x;
	while(true){
		//cout<<ans<<" "<<a<<" "<<b<<endl;
		ans+=b;
		if(a==b){
			ans+=b;break;
		}else{
			long long aa=(a-1)/b;
			ans+=2*aa*b;
			a=a-aa*b;
			if(a==b){
				ans+=b;break;
			}
			tmpa=a;a=b;b=tmpa;
			ans+=b;a=a-b;
		}
	}
	cout<<ans<<endl;
}

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

namespace id_0033cs
{
    class Balls
    {
        int[] _balls;
        public Balls(int[] balls)
        {
            _balls = balls;
        }
        public bool search(int i, int lt ,int rt)
        {
            if(i==9 && (_balls[9] >lt || _balls[9] > rt))
            {
                return true;
            }
            if(_balls[i] > lt && _balls[i] > rt)
            {
                return search(i + 1, _balls[i], rt) || search(i + 1, lt, _balls[i]);
            }
            if (_balls[i] > lt)
            {
                return search(i + 1, _balls[i], rt);
            }
            if (_balls[i] > rt)
            {
                return search(i + 1, lt, _balls[i]);
            }
            return false;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            foreach(var i in Enumerable.Range(0, n))
            {
                var vs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                Balls balls = new Balls(vs);
                if (balls.search(0, 0, 0))
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}



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

ll calc(ll p,ll q,ll r,ll s){
	ll ma=max(max(max(p,q),r),s);
	ll mi=min(min(min(p,q),r),s);
	return ma-mi;
}

int main(){
  int N,i,j,k,l;
  cin>>N;
  ll a[N+1];
  ll b[N+1];
  b[0]=0;
  for(i=1;i<=N;i++){
	cin>>a[i];
	b[i]=b[i-1]+a[i];
  }
  
  j=2;k=1;l=3;
  ll ans=10000000000000000;

  while(j<=N-2){
	while(1){
	if(k==j-1) break;
	if(abs(b[j]-2*b[k])<=abs(b[j]-2*b[k+1])) break;
	k+=1;
	}
	while(1){
	if(l==N-1) break;
	if(abs(b[N]-b[j]-2*(b[N]-b[l]))<=abs(b[N]-b[j]-2*(b[N]-b[l+1]))) break;
	l+=1;
	}
	ans=min(ans,calc(b[k],b[j]-b[k],b[l]-b[j],b[N]-b[l]));
	j+=1;
  }
  cout<<ans<<endl;
  return 0;
}

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

typedef struct node_s {
    char c;
    struct node_s *prev_node;
    int len;
}              Node;

Node *create_node(char c, Node* prev_node, int len) {
    Node *node = (Node*) malloc(sizeof(Node));
    node->c = c;
    node->prev_node = prev_node;
    node->len = len;
    return node;
}

Node *create_null_node() {
    Node *node = (Node*) malloc(sizeof(Node));
    node->len = 0;
    node->c = 0;
    node->prev_node = NULL;
    return node;
}

int main() {
    char s[3001];
    char t[3001];
    scanf("%s", s);
    scanf("%s", t);
    int len_s = strlen(s);
    int len_t = strlen(t);

    //printf("%s len: %d\n", s, len_s);
    //printf("%s len: %d\n", t, len_t);

    //printf("0\n");
    Node ***DP;
    DP = malloc(len_s * sizeof(Node**));
    for (int i = 0; i < len_s; i++) {
        DP[i] = malloc(len_t * sizeof(Node*));
    }

    //Node* DP[len_s][len_t];
    //printf("0-1\n");

    // 初期化
    int has_same_char = 0;
    for (int i = 0; i < len_s; i++) {
        if (t[0] == s[i]) {
            DP[i][0] = create_node(t[0], NULL, 1);
            has_same_char = 1;
            continue;
        }

        if (has_same_char) {
            DP[i][0] = create_node(t[0], NULL, 1);
        } else {
            DP[i][0] = create_null_node();
        }
    //    printf("DP[%d][%d] char:%c, len:%d\n", i, 0, DP[i][0]->c, DP[i][0]->len);
    }
    //printf("1\n");

    has_same_char = 0;
    for (int j = 0; j < len_t; j++) {
        if (t[j] == s[0]) {
            DP[0][j] = create_node(s[0], NULL, 1);
            has_same_char = 1;
            continue;
        }
        if (has_same_char) {
            DP[0][j] = create_node(s[0], NULL, 1);
        } else {
            DP[0][j] = create_null_node();
        }
    }
    //printf("2\n");

    for (int i = 1; i < len_s; i++) {
        for (int j = 1; j < len_t; j++) {
            if (s[i] == t[j]) {
                DP[i][j] = create_node(s[i], DP[i-1][j-1], DP[i-1][j-1]->len + 1);
            }
            else {
                DP[i][j] = (DP[i-1][j]->len > DP[i][j-1]->len) ? DP[i-1][j] : DP[i][j-1];
            }
        }
    }

    //printf("3\n");

    char ans[3001];
    int i = 0;
    Node *current_node = DP[len_s - 1][len_t - 1];
    if (current_node->len == 0) {
        printf("\n");
        return 0;
    }

    do {
        if (current_node->c >= 'a' && current_node->c <= 'z')
            ans[i++] = current_node->c;
        current_node = current_node->prev_node;
    } while (current_node != NULL);
    i--;
    while(i >= 0)
        printf("%c", ans[i--]);
    printf("\n");
    return 0;
}


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

void insertionSort(int array[], int N){

	for(int i=1; i<N; ++i){
		int v = array[i];
		int j = i - 1;
		while(j>=0 && array[j]>v){
			array[j+1] = array[j];
			--j;
		}
		array[j+1] = v; //array[-1] does not affect...
		for(int k=0; k<N; ++k){
			(k!=N-1) ? cout << array[k] << ' ' : cout << array[k];
		}
		cout << endl;
	}

}

int main(){
	int n;
	cin >> n;
	int array[n];

	for(int i=0; i<n; ++i){
		cin >> array[i];
		(i!=n-1) ? cout << array[i] << ' ' : cout << array[i];
	}
	cout << endl;
	insertionSort(array, n);

	return 0;
}



Measured memory_bytes: 3088
N = int(input())
red = [list(map(int, input().split())) for _ in range(N)]
blue = [list(map(int, input().split())) for _ in range(N)]
red.sort(key=lambda x: x[1], reverse=True)
blue.sort()
cnt = 0
for i in range(N):
    for j in range(N):
        if red[i][0] < blue[j][0] and red[i][1] < blue[j][1]:
            red[i][0] = 0
            red[i][1] = 0
            blue[j][0] = 0
            blue[j][1] = 0
            cnt += 1
            break
print(cnt)


Measured memory_bytes: 3188
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;

int main() {
	cin >> n;
	LL T = 1, A = 1;
	REP(i, n) {
		int t, a;
		cin >> t >> a;
		LL num = max((T-1) / t+1, (A-1) / a+1);
		T = num*t;
		A = num*a;
	}
	cout << T + A << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()

using namespace std;

#define MAX 110
int n,D[MAX],A[MAX];
map<vector<int>,int> dp[MAX];
map<vector<int>,int> score[MAX];

void normalize(vector<int> &vec) {
  vector<int> tmp = vec;
  sort(ALL(tmp));
  rep(i,(int)vec.size()) vec[i] = lower_bound(ALL(tmp),vec[i]) - tmp.begin();
}

void init(int Dmax) {
  vector<int> init;
  rep(i,min(Dmax+1,n)) init.push_back(i);
  do {
    int c_score = 0;
    vector<int> nex;
    rep(i,(int)init.size()) {
      if( i && i <= D[0] && init[0] < init[i] ) c_score += A[0]; // 0 ????????????
      if( i && i <= D[i] && init[0] > init[i] ) c_score += A[i]; // 0 ????????????
      if( i ) nex.push_back(init[i]);
    }
    normalize(nex);
    dp[0][nex] = max(dp[0][nex],c_score);
  } while(next_permutation(ALL(init)));
}


struct Data {
  int key, ID;
  bool operator < ( const Data & data ) const {
    return key < data.key;
  }
};

void compute() {
  int Dmax = 0;
  rep(i,n) Dmax = max(Dmax,D[i]);

  init(Dmax);

  int maxi = 0;
  REP(i,1,n) {
    if( i + Dmax < n ) {
      for(auto v : dp[i-1]) {
	vector<int> cur = v.first;
	int c_score = v.second;
	rep(j,(int)cur.size()) {
	  cur[j] += 1;
	  cur[j] *= 10;
	}

	int n_score = c_score;
	vector<int> nex;
	cur.push_back(5);

	rep(j,(int)cur.size()) {
	  if( j && j <= D[i+0] && cur[0] < cur[j] ) n_score += A[i+0];
	  if( j && j <= D[i+j] && cur[0] > cur[j] ) n_score += A[i+j];
	  if( j ) nex.push_back(cur[j]);
	}
	normalize(nex);
	dp[i][nex] = max(dp[i][nex],n_score);

	rep(_,Dmax) {
	  nex.clear();
	  n_score = c_score;
	  cur.back() += 10;

	  rep(k,(int)cur.size()) {
	    if( k && k <= D[i+0] && cur[0] < cur[k] ) n_score += A[i+0];
	    if( k && k <= D[i+k] && cur[0] > cur[k] ) n_score += A[i+k];
	    if( k ) nex.push_back(cur[k]);
	  }
	  normalize(nex);
	  dp[i][nex] = max(dp[i][nex],n_score);
	}
      } 
    } else {
      for(auto v : dp[i-1]) {
	vector<int> cur = v.first;
	int c_score = v.second;
	rep(j,(int)cur.size()) {
	  REP(k,j+1,(int)cur.size()) {
	    if( k-j <= D[i+j] && cur[j] < cur[k] ) c_score += A[i+j];
	    if( k-j <= D[i+k] && cur[j] > cur[k] ) c_score += A[i+k];
	  }
	}
	maxi = max(maxi,c_score);
      }
      break;
    }
  }
  cout << maxi << endl;
}

int main() {
  cin >> n;
  rep(i,n) cin >> D[i];
  rep(i,n) cin >> A[i];
  compute();
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  vector<string> str(2);
  string ca = to_string(a); 
  string cb = to_string(b);

  for(int i = 0; i < b; i++) str[0] += ca;
  for(int i = 0; i < a; i++) str[1] += cb;

  sort(str.begin(), str.end());
  cout << str[0];


}



Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

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

            int[] dp = new int[N + 1];
            Arrays.fill(dp, (int) 1e9);
            dp[0] = 0;
            for (int i = 0; i < dp.length; i++) {
                for (int j = 1; i + j < dp.length; j += (int) 1e9) {
                    dp[i + j] = Math.min(dp[i + j], dp[i] + 1);
                }
                for (int j = 6; i + j < dp.length; j *= 6) {
                    dp[i + j] = Math.min(dp[i + j], dp[i] + 1);
                }
                for (int j = 9; i + j < dp.length; j *= 9) {
                    dp[i + j] = Math.min(dp[i + j], dp[i] + 1);
                }
            }

            System.out.println(dp[N]);
        }
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <map>
using namespace std;
map<string,int> mp;
int main(int argc, char** argv) {
	int n,ans=0;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin >> s
		;
		if(!mp[s]) ++ans;
		mp[s]=1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 18712
#include <bits/stdc++.h>
using namespace std;
int k,n;
int height[200000],dp[200000];
void read()
{
    cin>>n>>k;

    for(int i=k+1;i<=n+k;i++)
    {
        cin>>height[i];
    }
        for(int i=1;i<=k;i++)
    {
        height[i]=height[k+1];
    }
}
int max(int a,int b)
{
    if(a<b)
    return a;
    else
    return b;
}
int solve()
{
for(int i=1;i<=k;i++)
{
    dp[i]=0;
}
    for(int i=k+1;i<=k+n;i++)
    {
        int temp=INT_MAX;
        for(int j=1;j<=k;j++){
    temp=min(abs(height[i]-height[i-j])+dp[i-j],temp);  
        }
        dp[i]=temp;
    }
    return dp[n+k];
}
int main() {
	read();
	cout<<solve();
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define int long long
#define pii pair<int, int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define jai_shree_ram  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, a, b, d) for (int i = a; i <= b; i += d)
#define brep(i, a, b, d) for (int i = a; i >= b; i -= d)
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl '\n'
int MOD = 1e9 + 7;
////////////////////////////////



int32_t main(){
    jai_shree_ram
    int n, ans = 0;
    double d;
    cin >> n >> d;
    rep(i,1,n,1){
        double x, y, z;
        cin >> x >> y;
        z = sqrt(x*x + y*y);
        if(z <= d) ans++; 
    }
    cout << ans;
    return 0;   
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a != b && b != c && a != c) {
    cout << 3 << endl;
  }
  
  else if(a == b && b == c){
    cout << 1 << endl;
  }
  
  else{
    cout << 2 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double N;
int main(){
  cin >> N;
  for(double y=0;y<=N/7;y++){
    if(ceil((N-7*y)/4)==floor((N-7*y)/4)){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
from numpy import argmax
import numpy as np
from collections import defaultdict

n = int(input())
H = [np.array([int(j) for j in input().split()]) for i in range(n)]

if n == 1:
    print(1)
    exit()
# else n == 2:
#     print(0.5)
#     print(0.5)
#     exit()

convex = [min(H, key=lambda x:x[1])]

for i in range(n):
    a = H[0] if (H[0] != convex[-1]).any() else H[-1]
    for b in H:
        ac = a-convex[-1]
        bc = b-convex[-1]
        cross_ = np.cross(ac, bc)
        if cross_ < 0 or (cross_ == 0 and np.linalg.norm(ac) < np.linalg.norm(bc)):
            a = b
    if (a == convex[0]).all():
        break
    convex.append(a)

ans = defaultdict(float)

for c, a, b in zip([convex[-1]]+convex[:-1], convex, convex[1:] + [convex[0]]):
    ca = c-a
    ba = b-a
    i = np.inner(ca, ba)
    n = np.linalg.norm(ca) * np.linalg.norm(ba)
    ans[tuple(a)] = (np.pi - np.arccos(np.clip(i/n, -1, 1))) / (2*np.pi)

for i in H:
    print(ans[tuple(i)])


Measured memory_bytes: 14476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9 + 7;

int main(){
	int a, b, c; cin >> a >> b >> c;
	if(a+b+c>=22) cout << "bust" << endl;
	else cout << "win" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n;
  ll t, a;
  cin >> n >> t >> a;

  double value = 10000;
  ll ans = -1;
  rep(i, n) {
    ll h;
    cin >> h;
    if (chmin(value, abs(a - (t - h * 0.006))))
      ans = i+1;
  }

  cout << ans << endl;

  return 0;
}


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


int main() {
	int N;
	cin >> N;
	int flag = 0;
	vector<char>color(N);
	for(int i=0;i<N;i++){
		cin >> color.at(i);
	}
	int w = 0;
	int r = 0;
	for(int i=0;i<N;i++){
		if(color.at(i)=='W'){
			w++;
		}
		else{
			r++;
		}
	}
	w = 0;
	for(int i=0;i<N;i++){
		if(color.at(i)=='W'){
			if(w >= r){
				flag = 1;
				break;
			}
			else{
				w++;
				continue;
			}
		}
		else{
			r--;
			if(w >= r){
				flag = 1;
				break;

			}
			else{
				continue;
			}
		}
	}
	if(flag == 0){
		cout << 0 << endl;
	}
	else{
		cout << w << endl;
	}
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll N;
    ll count=1;
    cin>>N;
    ll ans=0;
    rep(i,N){
        ll A;
        cin>>A;
        if((count*A)%2==1)ans++;
        count++;
    }
    cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

ll n,x;
Vec sz;
Vec p;

ll cnt(ll lv,ll t){
    if(lv==0){
        return t>0?1:0;
    }
    if(t>=sz[lv-1]+2){
        return  p[lv-1]+ cnt(lv-1,t-sz[lv-1]-2) + 1;
    }else{
        return  cnt(lv-1,t-1);
    }
}

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

    cin>>n>>x;
    sz.resize(n+1);
    p.resize(n+1);
    p[0]=1;
    sz[0]=1;
    REP(i,1,n+1){
        sz[i] = sz[i-1] * 2 + 3;
        p[i] = p[i-1] * 2 + 1;
    }

    ll ans= cnt(n,x);
    cout<<ans<<endl;
    return  0;
}


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

struct st { int x, y, c; };
int d[100][100], b[100][100], x[11], y[11];
int dx[][6]{ { 0,-1,0,1,1,1, },{ -1,-1,-1,0,1,0 } };
int dy[]{ -1,0,1,1,0,-1 };
int main() {
	int m, n, s;
	while (scanf("%d%d", &m, &n), m) {
		scanf("%d", &s);
		rep(i, s)scanf("%d%d", &x[i], &y[i]), x[i]--, y[i]--;
		int t; scanf("%d", &t);
		int Max = 0;
		rep(i, t) {
			scanf("%d%d", &x[s], &y[s]); x[s]--; y[s]--;
			queue<st>que;
			memset(d, -1, sizeof(d));
			rep(j, s + 1) {
				d[x[j]][y[j]] = 0; b[x[j]][y[j]] = j;
				que.push({ x[j],y[j],j });
			}
			while (!que.empty()) {
				st p = que.front(); que.pop();
				rep(j, 6) {
					int nx = p.x + dx[!(p.y & 1)][j], ny = p.y + dy[j];
					if (0 <= nx&&nx < m && 0 <= ny&&ny < n) {
						if (d[nx][ny] == -1) {
							d[nx][ny] = d[p.x][p.y] + 1;
							b[nx][ny] = p.c;
							que.push({ nx,ny,p.c });
						}
						else if (d[nx][ny] == d[p.x][p.y] + 1&&b[nx][ny]!=p.c) {
							b[nx][ny] = -1;
							que.push({ nx,ny,p.c });
						}
					}
				}
			}
			int cnt = 0;
			rep(i, m)rep(j, n) {
				if (b[i][j] == s)cnt++;
			}
			Max = max(Max, cnt);
		}
		printf("%d\n", Max);
	}
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int lower = max(A, C);
  int upper = min(B, D);
  
  lower < upper 
    ? cout << upper - lower << endl
    : cout << 0 << endl;
  // cout << max(0, upper - lower) << endl;で簡潔に処理できる！
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
    string T;
    cin>>T;

    for(int i=0;i<T.size();i++){
        if(T[i]=='?'){
            T[i]='D';
        }
    }
    cout<<T<<endl;
}

Measured memory_bytes: 3736
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline LL ri() {LL x; scanf("%lld", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/

const int maxn = 500010;

char s[maxn];

int p[maxn][26], n, w[maxn], q[maxn][20];

int main() {
  memset(p, -1, sizeof p);
  //memset(q, -1, sizeof q);
  scanf("%s", s);
  n = strlen(s);
  for (int i = n - 1; i >= 0; i --) {
    int k = s[i] - 'a';
    p[i][k] = i + 1;
    rep(j, 25) {
      if (p[i][j] >= 0 && p[p[i][j]][j] >= 0) {
        p[i][j + 1] = p[p[i][j]][j];
      }
    }
    if (p[i][25] >= 0 && 
        p[p[i][25]][25] >= 0) {
      w[i] = p[p[i][25]][25];
      rep(j, k)
        p[i][j] = p[w[i]][j];
    } else w[i] = i;
  }

  w[n] = n;
  rep(i, n + 1) {
    q[i][0] = w[i];
  }

  drep(i, n + 1) {
    rep(j, 1, 20) {
      q[i][j] = q[q[i][j - 1]][j - 1];
    }
  }

  int Q; scanf("%d", &Q);
  rep(i, Q) {
    int l, r;
    scanf("%d %d", &l, &r);
    l --;
    //cout << l <<  ' ' << r << ' ' << q[l][0] << endl;
    drep(j, 20) {
      //assert(l >= 0);
      if (q[l][j] <= r) 
        l = q[l][j];
      //cout << l << ' ';
    }
    //cout << endl;
    if (l == r) {
      puts("Yes");
    } else {
      puts("No");
    }
  }

  return 0;
}


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


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

  int len = S.size();
  if(S[0] != 'A'){
    cout << "WA" << endl;
    return 0;
  }
  if(S[1] < 'a' || 'z' < S[1]){
    cout << "WA" << endl;
    return 0;
  }
  if(S[len-1] < 'a' || 'z' < S[len-1]){
    cout << "WA" << endl;
    return 0;
  }
  
  int num_C = 0;
  for(int ii=2; ii<len-1; ii++){
    if(S[ii] == 'C'){
      if(num_C != 0){
        cout << "WA" << endl;
        return 0;
      }
      num_C++;
    }else if(S[1] < 'a' || 'z' < S[1]){
      cout << "WA" << endl;
      return 0;
    }
  }
  if(num_C != 1){
    cout << "WA" << endl;
    return 0;
  }
  cout << "AC" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.OutputStream;
public class Main {
    public static void main(String args[]) {
        Sc sc = new Sc(System.in);
        int K = sc.nI();
        int T = sc.nI();
        int max = 0;
        for(int i = 0; i<T; i++) {
            max = Math.max(max, sc.nI());
        }
        int sum = K - max;

        if(max <= sum) System.out.println(0);
        else System.out.println(max - 1 - sum);
    }
}
class Sc {
    public Sc(InputStream i) {
        r = new BufferedReader(new InputStreamReader(i));
    }

    public boolean hasM() {
        return peekToken() != null;
    }

    public int nI() {
        return Integer.parseInt(nextToken());
    }

    public double nD() { 
        return Double.parseDouble(nextToken());
    }

    public long nL() {
        return Long.parseLong(nextToken());
    }

    public String n() {
        return nextToken();
    }

    private BufferedReader r;
    private String line;
    private StringTokenizer st;
    private String token;

    private String peekToken() {
        if (token == null) 
            try {
                while (st == null || !st.hasMoreTokens()) {
                    line = r.readLine();
                    if (line == null) return null;
                    st = new StringTokenizer(line);
                }
                token = st.nextToken();
            } catch (IOException e) { }
        return token;
    }

    private String nextToken() {
        String ans = peekToken();
        token = null;
        return ans;
    }
}

Measured memory_bytes: 8276
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string.h>
void Inverse(char*, char*);
int main() {
    char str[128] = "", strInverse[128] = "", *pt, *Ipt;
    int cnt = 0;
    while (~fscanf(stdin, "%s", str)) {
        pt = str, pt += strlen(str) - 1, Ipt = strInverse;
        Inverse(pt, Ipt);
        *(Ipt+strlen(str)) = '\0';
        if (strcmp(str, strInverse) == 0) cnt++;    
        str[0] = strInverse[0] = '\0';
    }
    fprintf(stdout, "%d\n", cnt);
    return 0;
}
 
void Inverse(char *pt, char *Ipt) {
    while (*pt)
        *Ipt = *pt,
        pt--, Ipt++;
}

Measured memory_bytes: 552
W=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
N = int(input())
S = input()
T=""
for i in range(len(S)):
        k = W.index(S[i])+N
        if k>25: k=k-26
        T += W[k]
print(T)


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

int main()
{

	int N, M, p, R, L, nextS, min = 999999;
	int d[10001];

	cin >> N >> M >> p;

	for( int i = 1; i < M + 1; i++ ) cin >> d[i];
	
	d[0] = p;

	sort( d, d + M + 1 );

	for( int i = 0; i < M + 1; i++ ) {

		nextS = d[i];

		R = d[i + 1 < M + 1 ? i + 1 : 0];
		L = d[i - 1 >= 0 ? i - 1 : M];

		int ca1 = (( p - nextS + N ) % N ) * 2 + ( L - p + N ) % N;
		int ca2 = (( nextS - p + N ) % N ) * 2 + ( p - R + N ) % N;

		if( min > ca1 ) min = ca1;
		if( min > ca2 ) min = ca2;

	}

	cout << min * 100 << endl;

	return 0;

}

Measured memory_bytes: 1216
if __name__ == '__main__':
    N, K = map(int, input().split())
    S = str(input())
    count = 0
    
    LR = 0
    RL = 0
    
    for i in range(N-1):
        if S[i] == 'R' and S[i+1] == 'R':
            count += 1
        elif S[i+1] == 'L' and S[i] == 'L':
            count += 1
    
    for i in range(N-1):
        if S[i] == 'L' and S[i+1] == 'R': #Lで不幸せな人を見つけた
            LR += 1  
                    
        elif S[i] == 'R' and S[i+1] == 'L': #Rで不幸せな人を見つけた
            RL += 1
    
    for i in range(K):
        if LR > 0 and RL > 0:
            LR -= 1
            RL -= 1
            count += 2
        else:
            if LR > 0 or RL > 0:
                count += 1
                break
            
    print(count)
    

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i];}cerr << endl;}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){

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

    int n;
    cin >> n;
    int s[n];
    vint notzero;
    rep(i, n){
        cin >> s[i];
        if(s[i]%10)
            notzero.push_back(s[i]);

    }

    int sum = accumulate(s, s+n, 0);
    if(sum%10 == 0){
        if(notzero.empty()){
            sum = 0;
        }
        else{
            sum -= *min_element(notzero.begin(), notzero.end());
        }
    }


    ppp(sum);



    return 0;
}


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

int main(){
    int S,h,m,s,i;
    cin >> S;
    h = S / 3600;
    i = S - h * 3600;
    m = i / 60;
    s = i - m * 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int main() {
  int  r,g,b;
  cin >> r >> g >> b;
  
  if ((r*100+g*10+b) % 4 == 0){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3604
#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(){
  ll n,k;
  cin >> n >> k;
  vector <ll> a(n);
  vector <ll> cnt(n+1,-1);
  ll s,m=1,now;
  rep(i,n)cin >> a[i];
  now=1;int i=0;
  vector<int> p;
  while(i!=n){
    if(cnt[now]==-1)cnt[now]=i;
    else{
      s=cnt[now];
      m=i-cnt[now];
      break;
    }
    p.push_back(now);
    //cout << now << i << endl;
    now=a[now-1];
    i++;
  }
  if(k < s)cout << p[k] << endl;
  else {
    k-=s;
    k%=m;
    
    cout << p[s+k] << endl;
  }
}


Measured memory_bytes: 7448
fun main(args: Array<String>) {
    var N= readLine()!!.toInt()
    var input = (1..N).map{
                readLine()!!.toInt()
            }.toList()
    var idx = 0
    for(i in 1..N){
        var next_i =input[idx]
        if(next_i == 2){
            println(i)
            return
        }
        idx = next_i-1
    }
    
    println(-1)
}


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

using namespace std;

int main(){

    int n,m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    vector<int> p(m);
    for(int i = 0; i < m; i++){
        int k;
        cin >> k;
        s[i].resize(k);
        for(int j = 0; j < k; j++){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    for(int i = 0; i < m; i++){
        cin >> p[i];
    }

    int ans = 0;
    
    for(int mask = 0; mask < (1 << n); mask++){
        bool check = true;
        for(int i = 0; i < m; i++){
            int cnt = 0;
            for(int id : s[i]){
                if((mask >> id) & 1){
                    cnt++;
                }
            }
            if(cnt % 2 != p[i]){
                check = false;
            }
        }
        if(check == true){
            ans++;
        }
    }

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


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

int main() {
  int N; cin >> N;
  int P;
  int tmp_min = 10000010;
  int ans = 0;
  for (int i=0; i<N; i++) {
    cin >> P;
    tmp_min = min(tmp_min, P);
    if (tmp_min == P) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <atcoder/scc>
#include <iostream>

using namespace std;
using namespace atcoder;

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

    scc_graph g(n);

    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g.add_edge(u, v);
    }

    auto scc = g.scc();

    cout << (int)scc.size() << endl;
    for (auto v : scc) {
        cout << (int)v.size();
        for (int x : v) {
            cout << " " << x;
        }
        cout << endl;
    }

    return 0;
}


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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
// clang-format on
/* }}} */


signed main() 
{
  string s;
  cin >> s;
  s[3]='8';
  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";


int main() {
    cin>>S;
    bool tbd = false;
    if(S[5] == '1') tbd = true;
    if(S[6] > '4') tbd = true;
    cout<<(tbd ? "TBD" : "Heisei")<<endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, K, S;
  vector<int> v;

  scanf("%d%d", &N, &K);

  int counter = 0, prev = 1;
  for (int i = 0; i < N; i++) {
    int x;
    scanf("%1d", &x);
    if (prev != x) {
      v.push_back(counter);
      counter = 0;
    }
    counter++;
    prev = x;
  }
  v.push_back(counter);

  if (v.size() % 2 == 0) v.push_back(0);


  int ans = 0, sum = 0;

  for (int i = 0; i < v.size(); i++) {
    if (i >= K * 2 + 1) sum -= v[i - (K * 2 + 1)];
    sum += v[i];

    if (i % 2 == 0)
      ans = max(ans, sum);
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 3916