akhauriyash/Code-Regression huggingface dataset:
import numpy as np

N, W = map(int, input().split())
goods = [tuple(map(int, input().split())) for _ in range(N)]

table = np.zeros((N + 1, W + 1), dtype=np.int64)
for n in range(N):
    tmp = np.zeros(W + 1, dtype=np.int64)
    tmp[goods[n][0]:] = table[n][:W + 1 - goods[n][0]] + goods[n][1]
    table[n + 1] = np.maximum(table[n], tmp)
print(table[N][W])


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

const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline int read()
{
    int x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=x*10+c-'0',c=Get();
    return x;
}

const int N=100010;
struct Edge{int to,next;} e[N<<1];
int h[N],sum=0,n;

void add_edge(int u,int v)
{
    e[++sum].to=v;
    e[sum].next=h[u];
    h[u]=sum;
}

int dfs(int u,int fa)
{
    int res=0;
    for(int tmp=h[u];tmp;tmp=e[tmp].next)
        if(e[tmp].to!=fa) res^=dfs(e[tmp].to,u)+1;
    return res;
}

int main()
{
    int u,v;n=read();
    for(int i=1;i<n;i++)
    {
        u=read();v=read();
        add_edge(u,v);
        add_edge(v,u);
    }
    puts(dfs(1,0)?"Alice":"Bob");
    return 0;
}

Measured memory_bytes: 7936
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String [] str = new String[N];
        String [] result = {"AC", "WA", "TLE", "RE"};
        HashMap<String, Integer> map = new HashMap<String, Integer>();

        for(int i = 0; i < N; i++) {
            str[i] = sc.next();

            if(map.get(str[i]) == null) {
                map.put(str[i], 1);
            } else {
                int count = map.get(str[i]);
                map.put(str[i], count + 1);
            }
        }

        for(int i = 0; i < 4; i++) {
            if(map.get(result[i]) == null) {
                System.out.println(result[i] + " x " + 0);
            } else {
                System.out.println(result[i] + " x " + map.get(result[i]));
            }
        }

    }
}

Measured memory_bytes: 64592
n,m,x=map(int,input().split())
a=list(map(int,input().split()))

cost_right=0
cost_left=0

for i in range(x,n):
    if i in a:
        cost_right+=1

for j in range(0,x):
    if j in a:
        cost_left+=1

print(min(cost_right,cost_left))


Measured memory_bytes: 3060
#include <cstdio>
int N;
char c;
int main()
{
  scanf("%d",&N);
  bool flag=false;
  for(int i=0;i<N;i++)
  {
    scanf("%c",&c);
    if(c=='Y') flag=true;
  }
  if(flag)puts("Four");
  else puts("Three");
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	int N,dir,D[100005]={0},maxD=0;
	long long sum;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>dir;
		if(i==0&&dir!=0){
			cout<<0;
			return 0;
		}	
      	if(dir>maxD)maxD=dir;
		D[dir]++;
	}
	if(D[0]!=1){
		cout<<0;
		return 0;
	}
    long mod = 998244353;
	sum=1;
	for(int i=2;i<=maxD;i++){
		if(D[i]!=0){
			for (int j=0;j<D[i];j++){
				sum*=D[i-1];
				sum%=mod;
			}
		}else{
			sum=0;
			break;
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;

namespace ITP1_6_B
{
    class Program
    {
        static HashSet<Card> Cards;

        static void Main(string[] args)
        {
            Cards = new HashSet<Card>();

            // init
            for (var i = 0; i < 4; i++)
            {
                Mark mark;
                switch(i)
                {
                    case 0: mark = Mark.Spades; break;
                    case 1: mark = Mark.Hearts; break;
                    case 2: mark = Mark.Clubs; break;
                    case 3: mark = Mark.Diamonds; break;
                    default: throw new Exception();
                }
                for (int j = 1; j < 14; j++) Cards.Add(new Card(mark, j));
            }

            // read
            var count = Convert.ToInt32(Console.ReadLine());

            for(var i = 0; i < count; i++)
            {
                var str = Console.ReadLine().Split(' ');

                Mark mark = MarkConverter.StringToMark(str[0]);
                int number = Convert.ToInt32(str[1]);

                Cards.Remove(new Card(mark, number));
            }


            // write
            foreach(var card in Cards)
            {
                string mark = MarkConverter.MarkToString(card.Mark);

                Console.WriteLine(mark + " " + card.Number);
            }
        }
    }
    public enum Mark : int
    {
        Spades = 0,
        Hearts = 1,
        Clubs = 2,
        Diamonds = 3
    }
    public class Card : IEquatable<Card>
    {
        public Mark Mark { get; protected set; }
        public int Number { get; protected set; }

        public Card(Mark mark, int num)
        {
            if(num < 1 || 13 < num) throw new Exception();
            Mark = mark;
            Number = num;
        }

        public bool Equals(Card card2)
        {
            if (card2 == null) return true;
            else if (Mark == card2.Mark && Number == card2.Number) return true;

            return false;
        }

        public override int GetHashCode()
        {
            return (int)Mark << 16 ^ Number;
        }
    }

    public static class MarkConverter
    {
        public static string MarkToString(Mark mark)
        {
            switch (mark)
            {
                case Mark.Spades: return "S";
                case Mark.Hearts: return "H";
                case Mark.Clubs: return "C";
                case Mark.Diamonds: return  "D";
            }
            throw new Exception();
        }

        public static Mark StringToMark(string str)
        {
            switch (str)
            {
                case "S": return Mark.Spades;
                case "H": return Mark.Hearts;
                case "C": return Mark.Clubs;
                case "D": return Mark.Diamonds;
            }
            throw new Exception();
        }

    }

}

Measured memory_bytes: 10028
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, const char* argv[]) {
  int N;
  string S, T;

  cin >> N >> S;

  if((N % 2) == 1){
	  cout << "No" << endl;
          return 0;
  }
  T = S.substr(0, N / 2);
  if(S == (T + T)){
	  cout << "Yes" << endl;
  }else{
	  cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 888
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}
func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 100000007)
	sc.Split(bufio.ScanWords)
	s := Scanner()
	a := make([]int, len(s))
	for i := 0; i < len(s); i++ {
		a[i], _ = strconv.Atoi(string(s[i]))
	}

	b := make([]int, len(s)+1)
	b[0] = 0
	c := 1
	for i := len(s) - 1; i >= 0; i-- {
		b[len(s)-i] = a[i]*c + b[len(s)-i-1]
		b[len(s)-i] %= 2019
		c *= 10
		c %= 2019
	}

	d := make(map[int]int)
	for i := range b {
		d[b[i]] += 1
	}

	ans := 0
	for _, j := range d {
		if j > 1 {
			ans += j * (j - 1) / 2
		}
	}
	fmt.Println(ans)
}


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

int main() {
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++){
    long long A, B;
    cin >> A >> B;
    long long N = sqrt(A * B);
    if (N * N == A * B) {
      N = 2 * N - 2;
      if (A == B) N++;
    }
    else {
      N = 2 * N;
      if ((N / 2) * (N / 2 + 1) >= A * B) N--;
    }
    cout << N - 1 << endl;
  }
}

Measured memory_bytes: 3604
import java.util.*;

import static java.lang.System.*;

// https://atcoder.jp/contests/abc085/tasks/abc085_c
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();

        solver(N, Y);
    }

    public static void solver(int N, int Y) {

        for(int x = 0; x <= N; x++){
            for(int y = 0; y <= N-x; y++){
                int z = N - x - y;
                if(10000 * x + 5000 * y + 1000 * z == Y){
                    out.println(x + " " + y + " " + z);
                    return;
                }
            }
        }
        out.println("-1 -1 -1");
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pf pop_front
#define mp make_pair
using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
		
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i]>>c[i];
	
	int dp[n][3];
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++)
			dp[i][j]=-1e9;
	
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	
	for(int i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][2],dp[i-1][0])+b[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
	}
	cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2])<<endl;
	
	
		
}

Measured memory_bytes: 2560
S = input()
T = input()

ans = ["UNRESTORABLE"]
for i in range(len(S)-len(T)+1):
	count = 0
	for j in range(len(T)):
		if (S[i+j] == T[j] or S[i+j] == "?"):
			count += 1
	if count == len(T):
		Sa = S[:i]+T+S[i+len(T):]
		pl = Sa.replace("?","a")
		ans.append(pl)

print(ans[-1])

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
    int n,p[20],ans = 0;

    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&p[i]);
    }
    
    for (int i = 0; i < n - 2; i++)
    {
        //printf("%d %d %d\n",p[i],p[i + 1],p[i + 2]);
        if (((p[i] < p[i + 1]) && (p[i + 1] < p[i + 2])) ||  ((p[i] > p[i + 1]) && (p[i + 1] > p[i + 2])))
        {
            ans ++;
        }
        
    }
    printf("%d",ans);
}

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

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

int main(){
    int N;
    string S;
    cin >> N >> S;
    for(int i=0;i<S.length();i++){
        if(S[i]+N>90)printf("%c",S[i]+N-26);
        else printf("%c",S[i]+N);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

int main()
{
  int n, k;
  cin >> n >> k;
  cout << (n >= 2 * k - 1 ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
n,y=map(int,input().split())
for i in range(n+1):
  for j in range(n-i+1):
    if n-i-j>=0 and 10000*i+5000*j+1000*(n-i-j)==y:
      print(i,j,n-i-j)
      exit()
print('-1 -1 -1')

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int count = 0;
    for (int i = 1; i < n - 1; i++) {
        if ((p[i - 1] < p[i] && p[i] < p[i + 1]) ||
            (p[i - 1] > p[i] && p[i] > p[i + 1])) {
            count++;
        }
    }
    cout << count << endl;
}

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

using namespace std;

#define LIMIT 100
typedef int64_t ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int t, x, y;
  int x0 = 0, y0 = 0, t0 = 0;
  for (int i = 0; i < n; ++i) {
    cin >> t >> x >> y;
    if( abs(x-x0) + abs(y-y0) > abs(t-t0)){
      std::cout << "No" << std::endl;
      return 0;
    }
    if( abs(x-x0) + abs(y-y0) < abs(t-t0) &&
       (abs(x-x0) + abs(y-y0) )%2 != (t-t0)%2){
      std::cout << "No" << std::endl;
      return 0;
    }
    x0= x;
    y0= y;
    t0= t;
  }
  std::cout << "Yes" << std::endl;

  return 0;
}



Measured memory_bytes: 256
D = int(input())#D=365
c = list(map(int, input().split()))#0<=c<=100
s = [list(map(int, input().split())) for _ in range(D)]#0<=s<=20000

t = [int(input()) for _ in range(D)]


v = []
last = [0] * 26
value = 0
for d in range(D):
    type = t[d]
    value += s[d][type - 1]
    last[type - 1] = d + 1
    for i in range(26):
        value -= c[i] * (d + 1 - last[i])
    v.append(value)

for i in range(D):
    print(v[i])


Measured memory_bytes: 9360
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    vector<int> v(3);
    for(auto& a:v){
        cin>>a;
    }
    sort(v.begin(), v.end());
    if(v[0]==5&&v[1]==5&&v[2]==7){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
def resolve():
    sx, sy, tx, ty = [int(i) for i in input().split()]
    x = tx - sx
    y = ty - sy
    print("U" * y, "R" * x, sep="", end="")
    print("D" * y, "L" * x, sep="", end="")
    print("L", "U" * y, "U", "R" * x, "RD", sep="", end="")
    print("R", "D" * y, "DL", "L" * x, "U", sep="", end="")
    print()

resolve()



Measured memory_bytes: 9192
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
#include <complex>
using namespace std;
int main()
{
    int a,b,sum=0,s=1,c,i;
    cin>>a>>b;
    c=b;
    while(1)
    {
        sum++;
        if(b<10) break;
        b/=10;
    }
    for(i=1;i<=sum;i++) s*=10;
    sum=a*s+c;
    for(i=1;(i*i)<=sum;i++) 
    {
        if((i*i)==sum)
        {
            cout<<"Yes";
            system ("pause");
            return 0;
        }
    }
    cout<<"No";
    system ("pause"); 
    return 0;
}

Measured memory_bytes: 504
n = gets.to_i
require 'prime'

a = (n-1).prime_division
x = 1
a.each do |i|
  x *= (i[1]+1)
end

def divisors(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
  end.sort
end

b = divisors(n)
bs = b.size

b.slice!((bs/2).ceil,bs/2)
b.shift

b.each do |j|
  m = n
  while true
    if m%j==0
      m /= j
    elsif m%j== 1
      x += 1
      break
    else
      break
    end
  end
end
puts x

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

int main(){
  int N;
  //int x[365],y[365],b[365],p[365];
  int x,y,b,p;
  
  cin >> N;
  
  for(int i = 0;i<N;++i){
    cin >> x >> y >> b >> p;

    
    if(b >= 5 && p >= 2){
      cout << (x*b + y*p)*0.8 << endl;
    }else{
      if(b<= 5 && p <= 2){
	if(b*x + p*y >= (x*5 + y*2)*0.8){
	  cout << (x*5 + y*2)*0.8 << endl;
	}else{
	  cout << b*x + y*p << endl;
	}
      }else if(b> 5){
	if(b*x + p*y >= (b*x + y*2)*0.8){
	  cout << (b*x + y*2)*0.8 << endl;
	}else{
	  cout << b*x + p*y << endl;
	}
      }else{
	if(b*x + p*y >= (x*5 + p*y)*0.8){
	  cout << (x*5 + p*y)*0.8 << endl;
	}else{
	  cout << b*x + p*y << endl;
	}
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;

template <class T> using Vec = vector<T>;

/* 定数 */
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    u32 N;
    cin >> N;
    cout << (u32)ceil(N / 2.0) << endl;
}


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

int main(){
	int n, k, q, t;
	cin >> n >> k >> q;
	vector<int> a(n, k-q);

	for(int i=0; i<q; i++){
		cin >> t;
		a[t-1]++;
	}
	//for(int i=0; i<n; i++){
	//	cout << a[i] << endl;
	//}
	for(int i=0; i<n; i++){
		if(a[i]>0){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();

            if (ab[0] == ab[1]) Console.WriteLine("Draw");
            else if (ab[0] == 1 || (ab[1] != 1 && ab[0] > ab[1])) Console.WriteLine("Alice");
            else Console.WriteLine("Bob");
        }
    }
}


Measured memory_bytes: 13396
x = int(input())

for i  in range( x ):
    j = i + 1
    if j % 3 == 0:
        print(f" {j}", end = "" )
    else:
        for k in range(4):
            if ( (j//10**k) %10) == 3:
                print(f" {j}", end = "")
                break
print(sep = "\n")



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

ll S(ll n){
  return n*(n+1)/2;
}
bool OK=true;

int main(){
  ll X; cin>>X;
  for(int n=1;OK;n++){
    if(S(n-1)<X && X<=S(n)){
      OK=false;
      cout<<n;
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#define true 1
#define false 0

int A[20], n;

int solve(int, int);

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

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

int main(){
  int q, m[200];
  int i;
  
  scanf("%d", &n);
  for(i=0; i<n; i++)
    scanf("%d", &A[i]);

  scanf("%d", &q);
  for(i=0; i<q; i++)
    scanf("%d", &m[i]);

  for(i=0; i<q; i++){
    if(solve(0, m[i]) == true) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define ALL(v) (v).begin(),v.end()
using namespace std;

#ifdef _DEBUG
#define debug_io fstream cin("input.txt");ofstream cout("output.txt");
#else
#define debug_io ;
#endif
using pii = pair<int, int>;
bool check(string tile[], vector<string> ot, int n)
{
	REP(i, n) {
		if (tile[i] != ot[i]) {
			return false;
		}
	}
	return true;
}

int bet[30][4];
int main()
{
	debug_io;
	int n;
	cin >> n;
	REP(i, n) {
		int xn, yn;
		string tile[53];
		REP(i, 30)REP(j,4) {
			bet[i][j] = -1;
		}
		cin >> yn >> xn;
		REP(y, yn) {
			cin >> tile[y];
		}
		REP(y, yn) {
			REP(x, xn) {
				if (tile[y][x] != '.') {
					auto it = tile[y][x] - 'A';
					REP(i, 4) {
						if (bet[it][i] == -1) {
							if (i == 0 || i ==1) {
								bet[it][i] =  y;
							}						
							else if (i == 2 || i ==3) {
								bet[it][i] =  x;
							}
						}
						else {
							if (i == 0) {
								bet[it][i] = min(bet[it][i], y);
							}
							else if(i == 1){
								bet[it][i] = max(bet[it][i], y);
							}
							else if (i == 2) {
								bet[it][i] = min(bet[it][i], x);
							}
							else if (i == 3) {
								bet[it][i] = max(bet[it][i], x);
							}
						}
					}
				}//if
			}//xn
		}//yn
		vector<int> ats;
		REP(i, 30) {
			if (bet[i][0] != -1) {
				ats.push_back(i);
			}
		}
		bool ok = false;
		do {
			vector<string> ot(yn);
			REP(i, yn) {
				ot[i] = string(xn,'.');
			}
			REP(i, ats.size()) {
				for(int j = bet[ats[i]][0];j <= bet[ats[i]][1];++j)
					for (int k = bet[ats[i]][2]; k <= bet[ats[i]][3]; ++k) {
						ot[j][k] = ats[i] + 'A';
					}
			}
			ok |= check(tile, ot, yn);
		} while (next_permutation(ALL(ats)));

		if (ok) {
			cout << "SAFE" << endl;
		}
		else {
			cout << "SUSPICIOUS" << endl;
		}
	}//n
}

Measured memory_bytes: 3180
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		int sum = 0;
		int max = 0;
		for(int i = 1; i <= N; i++) {
			sum += i;
			if(sum >= N) {
				max = i;
				break;
			}
		}
		ans = sum - N;
		for(int i = 1; i <= max; i++) {
			if(i == ans) continue;
			System.out.println(i);
		}
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

class BFSearch
{
public:
  int solve();
};

int BFSearch::solve()
{
  int n;
  cin >> n;

  vector<vector<int>> adj( n + 1, vector<int>( n + 1, -1));

  int u, k, v;

  for ( auto j = 0; j < n; ++j )
    {
      cin >> u >> k;

      for ( auto i = 0; i < k; ++i )
        {
          cin >> v;
          adj[u][v] = 1;
        }
    }
  
  queue<int> q;
  vector<int> d(n + 1, -1);

  u = 1;
  d[u] = 0;
  q.push(u);

  while ( !q.empty() )
    {
      u = q.front();
      
      for ( auto i = 1; i <= n; ++i )
        {
          if ( adj[u][i] == 1 && d[i] == -1 )
            {
              d[i] = d[u] + 1;
              q.push( i );
            }
        }
      
      q.pop();
    }
  
  for ( auto i = 1; i <= n; ++i )
    cout << i << " " << d[i] << endl;
  
  return 0;
}

int main()
{
  BFSearch b;

  b.solve();

  return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;


int main() {
    int N;
    cin >> N;
    vector<string> Si(N);
    vector<int> Pi(N);
    for (int i=0;i<N;i++){
        cin >> Si[i] >> Pi[i];
    }
    vector<pair<string,pair<int,int>>> Vi;
    for(int i=0;i<N;i++){
        Vi.push_back(make_pair(Si[i],make_pair(100-Pi[i],i)));
    }
    sort(Vi.begin(),Vi.end());
    for (int i=0;i<N;i++){
        cout << Vi[i].second.second + 1 << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	class p{
		int x;
		int y;
		p(int x,int y){
			this.x = x;
			this.y = y;
		}
		final int[] gx = {-1,0,1,-2,2,-2,2,-2,2,-1,0,1};
		final int[] gy = {-2,-2,-2,-1,-1,0,0,1,1,2,2,2};
		LinkedList<p> canGoDo(p nextSp){
			LinkedList<p> ret = new LinkedList<Main.p>();
			for(int i = 0; i < gx.length;i++){
				p c= new p(	x + gx[i],y + gy[i]);
				if(nextSp.in(c)) ret.add(c);
			}
			return ret;
		}
		
		boolean in(p a){
			if(a.x<0) return false;
			if(a.y<0) return false;
			if(a.x>9) return false;
			if(a.y>9) return false;
			if(Math.abs(a.y-y)<=1 && Math.abs(a.x-x)<=1) return true;
			return false;
		}
	}
	void run(){
		for(;;){
			int x0 = sc.nextInt();
			int y0 = sc.nextInt();
			if((x0|y0) == 0)
				break;
			p start = new p(x0, y0);
			int n = sc.nextInt();
			p []sp = new p[n];
			for(int i = 0; i<n;i++){
				sp[i] = new p(sc.nextInt(),sc.nextInt());				
			}
			
			int now = 0;
			LinkedList<p> q = new LinkedList<Main.p>();
			q.add(start);
			String ret = "NA";
			for(;!q.isEmpty();){
				if(now >= n){
					ret = "OK";
					break;
				}
				LinkedList<p> nq = new LinkedList<Main.p>();
				for(p z: q){
					LinkedList<p> c = z.canGoDo(sp[now]);
					for(p w:c){
						if(!nq.contains(w)){
							nq.add(w);
						}
					}
				}
				q = nq;
				now++;
			}
			System.out.println(ret);
		}
		
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 100010;
int a[N],ord[N],n,p,mx[N],tmp;
signed main() {
  scanf("%lld",&n);
  for (int i = 1 ; i <= n ; ++ i) {
    scanf("%lld",&a[i]);
    ord[i] = a[i];
    mx[i] = max(mx[i-1],a[i]); 
  }
  p = 1;
  sort(ord+1,ord+n+1);
  for (int i = 1 ; i <= n ; ++ i) {
    if (a[i] <= mx[i-1]) puts("0");
    else {
      tmp = 0;
      while (p <= n && ord[p] <= a[i])
	tmp += ord[p++] - mx[i-1];
      tmp += 1ll * (n - p + 1) * (a[i] - mx[i-1]);
      printf("%lld\n",tmp);
    }
  }
  return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
  cin>>a>>b>>c;
  bool flag=false;
  if(a==b && c!=a)
    flag=true;
  if(a==c && b!=a)
    flag=true;
  if(b==c && a!=c)
    flag=true;
  if(flag)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  
  
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define vi vector<int>

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N = 10;
int f[N];
int main(){
	string s; cin >> s;
	int n = s.length();
	string t ="keyence";
	for(int i = 0; i < n; i++)
	for(int l = 0; i + l <= n; l++){
		if(s.substr(0, i) + s.substr(i + l, n - i - l) == t){
			cout << "YES"<<endl;
			return 0;
		}
	}
	cout << "NO"<<endl;
}

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

int main(){
    int n;
    cin>>n;
    char num[101];

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

    set<char> color;
    for(int i=0;i<n;i++)
        color.insert(num[i]);

    if(color.size()==4)
        cout<<"Four";
    else
        cout<<"Three";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        char[][] map = new char[N][N];
        for (int i=0;i<N;i++) {
            String S = sc.next();
            for (int j=0;j<N;j++) {
                map[i][j] = S.charAt(j);
            }
        }

        int ans = 0;
        for (int k=0;k<N;k++) {
            char[][] map_2 = new char[N][N];
            for (int i=0;i<N;i++) {
                for (int j=0;j<N;j++) {
                    map_2[i][j] = map[(i+k)%N][j];
                }
            }

            int flag = 0;
            loop:for (int i=0;i<N;i++) {
                for (int j=i;j<N;j++) {
                    if (map_2[i][j]!=map_2[j][i]) {
                        flag=1;
                        break loop;
                    }
                }
            }
            if (flag==0) ans++;
        }
        System.out.println(ans*N);
    }
}

Measured memory_bytes: 48800
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;

int main(){
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> xs, ys;
	int xr = x, yl=y;
	for (int i = 0; i < n; ++i) {
		int xi;
		cin >> xi;
		xs.push_back(xi);
		xr = max(xr, xi);
	}
	for (int i = 0; i < m; ++i) {
		int yi;
		cin >> yi;
		ys.push_back(yi);
		yl = min(yl, yi);
	}
	if (xr < yl) cout << "No War" << endl;
	else cout << "War" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  ll n,k;
  cin>>n>>k;
  if(k==0){
    cout<<n*n<<endl;
    return 0;
  }
  ll ans=0;
  int b;
  loop(b,k+1,n+1){
    if(n%b<k){
      ans+=(b-k)*(n/b);
    }else{
      int t=max(k,n%b);
      ans+=(t-k+1)*(n/b+1)+(b-t-1)*(n/b);
    }
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<algorithm>
using namespace std;
int dp[100001][4];
int recur(int n,int i,int z,int a[],int b[], int c[]){
if(i==n){
    return 0;
}
if(dp[i][z]!=0){
    return dp[i][z];
}
else{
    int ans=0;
    if(z==1){
        ans=max(recur(n,i+1,2,a,b,c),recur(n,i+1,3,a,b,c));
        ans+=a[i];
    }
    else if(z==2){
        ans=max(recur(n,i+1,1,a,b,c),recur(n,i+1,3,a,b,c));
        ans+=b[i];
    }
    else if(z==3){
        ans=max(recur(n,i+1,1,a,b,c),recur(n,i+1,2,a,b,c));
        ans+=c[i];
    }
    dp[i][z]=ans;
    return ans;
    
}
}
int main(){
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<100001;i++){
        for(int j=0;j<4;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
cout<<max(max(recur(n,0,1,a,b,c),recur(n,0,2,a,b,c)),recur(n,0,3,a,b,c))<<endl;
    
    return 0;

}

Measured memory_bytes: 14020
n=int(input())
h=list(map(int,input().split()))

dp=[float("inf")]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])


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

using namespace std;


int main(){
  int n,sumd,sumu;
  cin>>n;
  int w[n];
  rep(i,n) cin>>w[i];
  int min=10000000;
  rep(i,n){
    sumd = 0;
  for(int j = 0;j<i;j++) sumd+=w[j];
    sumu=0;
    for(int q=0;q<n;q++) sumu+=w[q];
    if(min>abs(2*sumd-sumu))min = abs(2*sumd-sumu);
       }
  cout << min <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int main(){
    int n,m,p;
    scanf("%d%d%d",&n,&m,&p);
    vector<int> adjlist[n];
    int a[m], b[m], c[m];
    for (int i = 0; i < m; i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        c[i] = p-c[i];
        a[i]--, b[i]--;
        adjlist[b[i]].push_back(a[i]);
    }
    int dist[n]; fill(dist,dist+n,INF);
    dist[n-1] = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            if (dist[b[j]] != INF && dist[a[j]] > dist[b[j]]+c[j]){
                dist[a[j]] = dist[b[j]]+c[j];
            }
        }
    }
    int inq[n]; memset(inq,0,sizeof(inq));
    queue<int> q;
    for (int j = 0; j < m; j++){
        if (dist[b[j]] != INF && dist[a[j]] > dist[b[j]]+c[j] && inq[a[j]] == 0){
            inq[a[j]] = 1;
            q.push(a[j]);
        }
    }
    while (q.size()){
        int u =q.front(); q.pop();
        for (auto v : adjlist[u]){
            if (inq[v] == 0){
                inq[v] = 1;
                q.push(v);
            }
        }
    }
    if (inq[0]){
        printf("-1");
        return 0;
    }
    printf("%d",max(0,-dist[0]));
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

signed main() {
  ll N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;

  map<ll, ll> m;
  rep(i, N) {
    vector<bool> v(N);
    queue<P> q;
    q.push({i, 0});
    // debug(i);
    while (!q.empty()) {
      P i = q.front();
      q.pop();
      ll index = i.first;
      ll before = i.second;
      // debug(index);
      if (index < 0 || N <= index) {
        continue;
      }
      if (v[index]) {
        continue;
      }
      // debug(before + 1);
      v[index] = true;
      m[before + 1]++;
      q.push({index - 1, before + 1});
      q.push({index + 1, before + 1});
      if (index == X) {
        q.push({Y, before + 1});
      }
      if (index == Y) {
        q.push({X, before + 1});
      }
    }
  }

  rep(i, N - 1) {
    if (i == 0) {
      continue;
    }
    ll ans = m[i + 1] / 2;
    // ll ans = m[i - 1].second / 2;
    COUT(ans);
  }

  COUT(0);
  return 0;
}

Measured memory_bytes: 384
N = int(input())
A = [int(i) for i in input().split()]
d = {}
for i in A:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
summ = 0
for i in d:
    summ += d[i] * (d[i] - 1) // 2
for i in A:
    print(summ - d[i] + 1)

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

int main(void){
  int n; cin >> n;
  char s[n], t[n];
  for(int i = 0; i < n; ++i){
    cin >> s[i];
  }
  rep(i,n){
    cin >> t[i];
  }
  rep(i,n){
    cout << s[i] << t[i];
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/errno.h>

#define READ_BUF_SIZE 1024
#define ASIZE(a) (sizeof (a) / sizeof (a[0]))

static int
read_str (char **out, int out_size, int max)
{
  char *p;
  char buf[READ_BUF_SIZE];
  int i = 0;
  char format[128];

  sprintf (format, "%%%d[^\n]%%*[^\n]", READ_BUF_SIZE);
  if (scanf (format, buf) == EOF)
    {
      printf ("EOF\n");
      fseek (stdin, 0L, SEEK_SET);
      return -1;
    }
  getchar ();

  for (p = strtok (buf, " "); p; p = strtok (NULL, " "))
    {
      strncpy ((char *) out, p, out_size);
      out = (char **) ((char *) out + out_size - 1); 
      *(char *) out = '\0';
      out = (char **) ((char *) out + 1); 
      i++;
      if (i >= max)
	break;
      
    }
  return i;
}

static int
read_num (int *out, int max)
{
  char *p;
  char buf[READ_BUF_SIZE];
  int i = 0;
  char format[128];

  sprintf (format, "%%%d[^\n]%%*[^\n]", READ_BUF_SIZE);
  if (scanf (format, buf) == EOF)
    {
      printf ("EOF\n");
      fseek (stdin, 0L, SEEK_SET);
      return -1;
    }
  getchar ();

  for (p = strtok (buf, " "); p; p = strtok (NULL, " "))
    {
      char *endptr = NULL;
      long num = strtol (p, &endptr, 10);
      if (*endptr != '\0' || errno == ERANGE)
	continue;
      else
	out[i++] = num;
      if (i >= max)
	break;
    }
  return i;
}

int
main (int argc, char *argv[])
{
  char input[10][20];
  read_str ((char **) input, ASIZE (input[0]), 1); 
  char keyword[] = {'A', 'C', 'G', 'T'};
  int i, j;
  int select = 0, max = 0;

  for (i = 0; i < ASIZE (input[0]); i++)
  {
    int flg = 0;
    for (j = 0; j < ASIZE (keyword); j++)
      if (input[0][i] == keyword[j])
	flg = 1;
    if (flg)
      select++;
    else
      {
	if (select > max)
	  max = select;
	select = 0;
      }
  }

  printf ("%d\n", max);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


ll check[30];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string str ; cin >> str;
  rep(i,str.size())
    check[(str[i]-'a')] ++ ;
  rep(i,30){
    if(check[i] % 2 != 0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<set>   
#include<map>   
#include<stack>   
#include<cmath>   
#include<cstdio>   
#include<queue>   
#include<vector>   
#include<climits>   
#include<cstring> 
#include<iostream> 
#include<algorithm> 
#define LL long long 
using namespace std;      
int read(){      
    int f=1,x=0;char c=getchar();         
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}        
    while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();      
    return x*f;     
}
#define MAXN 30
#define INF 0x3f3f3f3f
int k[MAXN+5],top[MAXN+5];
int main(){
	int n=read(),m=read();
	for(int i=1;i<=n;i++){
		k[i]=read();
		for(int j=1;j<=k[i];j++)
			top[read()]++;
	}
	int ans=0;
	for(int i=1;i<=m;i++)
		if(top[i]==n)
			ans++;
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
S = input()
for i in range(len(S)):
    c = S[i]
    if (i % 2 == 0 and c == 'L'):
        print('No')
        exit(0)
    if (i % 2 == 1 and c == 'R'):
        print('No')
        exit(0)
print('Yes')


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Program{
  public static void Main(){

    //入力
    var input = Console.ReadLine().Split();
    int n = int.Parse(input[0]);
    int a = int.Parse(input[1]);
    int b = int.Parse(input[2]);
    
    var input2 = Console.ReadLine().Split();
    long[] v = new long[n];
    for(int i=0; i<n; i++){
      v[i] = long.Parse(input2[i]);
    }
    
    //処理
    
    //降順に並べ替え
    Array.Sort(v);
    Array.Reverse(v);
    
    //解答用の変数の宣言
    double ave = 0;
    long num = 0;
    
    //一番大きい数とA番目に大きい数が同じ場合
    if(v[0] == v[a-1]){
      ave = v[0];
      
      //同じ要素の個数を数える
      int cnt = 0;
      for(int i=0; i<n; i++){
        if(v[0] != v[i]) break;
        else cnt++;
      }
      
      //dpでパスカルの三角形をつくる
      long[,] dp = new long[cnt+1,cnt+1];
      dp[0,0] = 1;
    　for(int i=1; i<=cnt; i++){
       for(int k=0; k<=i; k++){
        if(k >= 1){
          dp[i,k] = dp[i-1,k-1] + dp[i-1,k];
        }
        else {
          dp[i,k] = dp[i-1,k];
        }
       }
     }
      
      int sml = Min(b,cnt);
      for(int i=a; i<=sml; i++){
        num += dp[cnt,i];
      }
    }

    
    //一番大きい要素とA番目に大きい数が異なる場合
    else{
      long wa = 0;
      for(int i=0; i<a; i++){
        wa += v[i];
      }
      ave = (double)wa / a;
      
      //v[a-1]と同じ値の要素数を数える
      bool flg = false;
      int cnt = 0;
      int index = 0;
      
      for(int i=0; i<n; i++){
        if(v[i] == v[a-1]){
          if(!flg){
            index = i;//同じ値の要素番号をメモ
            flg = true;
          }
          cnt++;
        }
        if(flg == true && v[i] != v[a-1]){
          break;
        }
      }
      
      //dpでパスカルの三角形をつくる
      long[,] dp = new long[cnt+1,cnt+1];
      dp[0,0] = 1;
    　for(int i=1; i<=cnt; i++){
       for(int k=0; k<=i; k++){
        if(k >= 1){
          dp[i,k] = dp[i-1,k-1] + dp[i-1,k];
        }
        else {
          dp[i,k] = dp[i-1,k];
        }
       }
     }
      
      num = dp[cnt,a-index];
    }
    
    Console.WriteLine(ave);
    Console.WriteLine(num);
  }
}

Measured memory_bytes: 13268
INF = 99999999999

N, K = map(int, input().split())
hN = list(map(int, input().split()))

dp = [INF for _ in range(N)]

dp[0] = 0

for i in range(N):
    for k in range(1, K + 1):
        if i + k < N:
            diff = dp[i] + abs(hN[i] - hN[i + k])
            dp[i + k] = min(dp[i + k], diff)
        else:
            break
    # print("i={}, dp={}".format(i, dp))

print(dp[N - 1])


Measured memory_bytes: 56544
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int N; cin >>N;
  vector<int> v(N * 2);
  REP(i, N * 2) cin >>v[i];
  SORT(v);
  int sum = 0;
  for(int i = 0; i < N * 2; i += 2) sum += v[i];
  cout <<sum <<endl;
  return 0;
}


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

const int maxn = 1e5 + 10;
vector < int > g[maxn];
int num[maxn], num1[maxn];
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		g[a].push_back(b);
		num[i] = a;
		num1[i] = b;
	}
	for(int i = 1; i <= n; i++){
		sort(g[i].begin(), g[i].end());
	}
	for(int i = 1; i <= m; i++){
		int y = num1[i], z = num[i];
		int x = upper_bound(g[z].begin(), g[z].end(), y) - g[z].begin();
		printf("%06d%06d\n", z, x);
	}
	return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

bool can(bool f, int cur, int to) {
	if(f) {
		if(cur % 3 == 1 && to % 3 != 1) return false;
		if(cur % 3 == 2 && to % 3 == 0) return false;
		return true;
	} else {
		if(cur % 3 == 0 && to % 3 != 0) return false;
		if(cur % 3 == 2 && to % 3 == 1) return false;
		return true;
	}
}

int main() {
	string s;
	while(cin >> s) {
		if(s == "#") break;

		vector<int> v(s.size());
		rep(i, s.size()) v[i] = s[i] - '0';

		int ans = INF, res = 0;
		int left = v[0], right = 0, ord = 0;

		REP(i, 1, v.size()) {
			if(ord & 1) {
				if(can(1, right, v[i])) {
					left = v[i];
					ord++;
				} else {
					right = v[i];
					res++;
				}
			} else {
				if(can(0, left, v[i])) {
					right = v[i];
					ord++;
				} else {
					left = v[i];
					res++;
				}
			}
		}

		ans = min(ans, res);

		res = 0;
		left = 0, right = v[0], ord = 1;
		REP(i, 1, v.size()) {
			if(ord & 1) {
				if(can(1, right, v[i])) {
					left = v[i];
					ord++;
				} else {
					right = v[i];
					res++;
				}
			} else {
				if(can(0, left, v[i])) {
					right = v[i];
					ord++;
				} else {
					left = v[i];
					res++;
				}
			}
		}

		ans = min(ans, res);
		cout << ans << endl;
	}
	return 0;
}

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

const ll MX = 1e18;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  int zero = 0;
  ll prod = 1;
  rep (i, n) if (a[i] == 0) zero++;
  if (zero) {
    cout << 0 << endl;
    return 0;
  }

  rep (i, n) {
    if (a[i] <= MX / prod) {
      prod *= a[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  printf("%lld\n", prod);
  return 0;
}

Measured memory_bytes: 3992
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int a;
  cin >> a;
  int ret = a + a * a + a * a * a;
  cout << ret << endl;
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;

#define deb(x) cerr<<#x<<":"<<x<<"\n";
#define dvi(x) for(ll i=0;i<x.size();i++)cerr<<#x<<"["<<i<<"]:"<<x[i]<<" ";
#define iter(v) for(auto it:v)
#define wt ll t;cin>>t;while(t--)
#define rl(x) ll x;cin>>x;
#define rvi(x,n) vi x(n);for(ll i=0;i<n;i++) cin>>x[i];
#define rs(x) string x;cin>>x;
#define w(x) cout<<x<<endl;
#define wvi(x) for(ll i=0;i<x.size();i++) cout<<x[i]<<" ";cout<<endl;
#define ws(x) cout<<x<<endl;
#define all(v) v.begin(),v.end()
#define pb push_back
#define ppb pop_back
#define pll pair<ll, ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
const ll N = 1e9+7;

map<long long, long long> factorize(long long n) {	//returns map containing factor and multiplicity, Eg: 60 = {{2,2},{3,1},{5,1}}
	map<long long, long long> ans;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ans[i]++;
			n /= i;
		}
	}
	if (n > 1) {
		ans[n]++;
		n = 1;
	}
	return ans;
}

void FAST() {	//FAST Input Output, DONT use both scnaf,prllf / cin,cout , Use any ONE system
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt","w", stdout);
    #endif
	FAST();
	rl(a) rl(b) rl(c) rl(d)
	ll mx=a*c;
	mx=max(mx,a*d);
	mx=max(mx,b*c);
	mx=max(mx,b*d);
	cout<<mx<<"\n";
}

Measured memory_bytes: 3652