akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	line := nextLine()
	input := strings.Split(line, " ")
	a, _ := strconv.Atoi(input[0])
	b, _ := strconv.Atoi(input[1])
	x, _ := strconv.Atoi(input[2])

	if a <= x && a+b >= x {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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

int Fee(int size, int weight)
{
  return (size <= 60 and weight <= 2) ? 600 :
         (size <= 80 and weight <= 5) ? 800 :
         (size <= 100 and weight <= 10) ? 1000 :
         (size <= 120 and weight <= 15) ? 1200 :
         (size <= 140 and weight <= 20) ? 1400 :
         (size <= 160 and weight <= 25) ? 1600 : 0;
}

int main(void)
{
  while (true)
  {
    int n;
    cin >> n;
    if (n == 0) break;

    int result = 0;
    for (int i = 0; i < n; ++i)
    {
      int x, y, h, weight;
      cin >> x >> y >> h >> weight;
      result += Fee(x + y + h, weight);
    }
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
ary = gets.chomp.split(' ').map(&:to_i)
ary_1 = ary.slice(0,2)
ary_2 = ary.slice(2,2)

multiples = []
ary_1.each do |i|
  ary_2.each do |j|
    multiples << i * j
  end
end

p multiples.max

Measured memory_bytes: 14368
#include<cstdio>
using namespace std;
int n,m,ans=(1<<30);
char s1[1010],s2[1010];
int main(){
	char ch=getchar();
	for (;ch<'a'||ch>'z';ch=getchar());
	for (;ch>='a'&&ch<='z';ch=getchar()) s1[++n]=ch;
	ch=getchar();
	for (;ch<'a'||ch>'z';ch=getchar());
	for (;ch>='a'&&ch<='z';ch=getchar()) s2[++m]=ch;
	for (int i=1;i<=n-m+1;i++){
		int sum=0;
		for (int j=1;j<=m;j++){
			if (s1[i+j-1]!=s2[j]) sum++;
		}
		if (sum<ans) ans=sum;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1584
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        boolean flag = false;

        for (int i = 0; i <s.length() - 1; i++) {
            if (s.charAt(i) == s.charAt(i+1)) {
                flag = true;
                break;
            }
        }

        if (flag) {
            System.out.println("Bad");
        
        } else {
            System.out.println("Good");
        }
    }
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] c = new int[3];
        for (int i = 0 ; i < s.length(); i++) {
            if (s.charAt(i) == 'a') {
                c[0]++;
            } else if (s.charAt(i) == 'b') {
                c[1]++;
            } else {
                c[2]++;
            }
        }
        if (s.length() == 1) {
            System.out.println("YES");
            return;
        }
        if (s.length() == 2) {
            if (c[0] != 2 && c[1] != 2 && c[2] != 2) {
                System.out.println("YES");
                return;
            } else {
                System.out.println("NO");
                return;
            }
        }

        int min = Math.min(c[0], Math.min(c[1], c[2]));
        int max = Math.max(c[0], Math.max(c[1], c[2]));
        if (max - min <= 1) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

}

Measured memory_bytes: 23916
N = gets.to_i
A = gets.split.map(&:to_i).unshift

cums = Array.new(N+1, 0)
N.times do |i|
  cums[i+1] = cums[i] + A[i]
end

hash = Hash.new { |h, k| h[k] = 0 }
cums.each do |cum|
  hash[cum] += 1
end

ans = 0
hash.each_value do |c|
  next unless c >= 2

  ans += c * (c-1) / 2
end

puts ans


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef pair<int,int> ii;

int h,w,mini[210][210];
string s[210];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

void bfs(int sx,int sy) {
  rep(i,h) rep(j,w) mini[i][j] = INT_MAX;
  deque<ii> deq;
  deq.push_back(ii(sx,sy));
  mini[sy][sx] = 0;
  while( !deq.empty() ) {
    ii cur = deq.front(); deq.pop_front();
    rep(i,4) {
      int nx = cur.first  + dx[i];
      int ny = cur.second + dy[i];
      if( !( 0 <= nx && nx < w && 0 <= ny && ny < h) ) continue;
      if( s[ny][nx] == '#' ) continue;
      if( mini[ny][nx] > mini[cur.second][cur.first] + 1 ) {
        mini[ny][nx] = mini[cur.second][cur.first] + 1;
        deq.push_back(ii(nx,ny));
      }
    }
  }
}

void compute() {
  int sx=-1,sy, gx=-1,gy;
  vector<ii> vec;
  rep(i,h) rep(j,w) {
    if( s[i][j] == '@' ) sx = j, sy = i, s[i][j] = '.';
    if( s[i][j] == '%' ) gx = j, gy = i;
    if( s[i][j] == '$' ) vec.push_back(ii(j,i)), s[i][j] = '.';
  }
  bfs(gx,gy);
  if( mini[sy][sx] == INT_MAX ) {
    puts("No");
    return;
  }
  rep(i,(int)vec.size()) {
    ii tmp = vec[i];
    if( mini[sy][sx] >= mini[tmp.second][tmp.first] ) {
      puts("No");
      return;
    }
  }
  puts("Yes");
}

int main() {
  cin >> h >> w;
  rep(i,h) cin >> s[i];
  compute();
  return 0;
}

Measured memory_bytes: 3620
n=int(input())
k=2
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    mini=100000000000000000
    for j in range(i+1,min(n,i+k+1)):
        x=abs(a[j]-a[i])+b[j]
        mini=min(mini,x)
    b[i]=mini
print(b[0])

Measured memory_bytes: 52208
H,W,K=map(int,input().split())
C=[input() for i in range(H)]
DP=[0]*(K+1)
X=[]
P=0
for i in range(1,1<<H):
  X=[0]*W
  for j in range(H):
    if i&(1<<j):
      for k in range(W):
        if C[j][k]=='#':
          X[k]+=1
  for j in range(K+1):
    DP[j]=0
  DP[0]=1
  for j in range(W):
    for k in range(K,-1,-1):
      if k+X[j]<=K:
        DP[k+X[j]]+=DP[k]
  P+=DP[K]
print(P)

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

int main() {
	string s; cin >> s;
	int i = 0;
	for (int j = 0; j < 4; j ++) {
		char ch = s[j];
		if (ch == '+') i ++; 
		else i --;
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        String ans = "Positive";
        
        if (a <= 0 && b >= 0) {
            ans = "Zero";
        } else if (a < 0 && (a + b) % 2 == 0) {
            ans = "Negative";
        }

        out.println(ans);
        
        out.flush();
    }
}

Measured memory_bytes: 21716
#include<cstdio>
#include<cstring>
char s[105];
int n,i;
int main(){
    scanf("%s",s);
    n=strlen(s);s[n]='E';
    for(i=0;s[i];i++)
    if(s[i]=='C')break;
    if(i>n){puts("No");return 0;}
    for(;s[i];i++)
    if(s[i]=='F')break;
    if(i>n){puts("No");return 0;}
    puts("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int group[1010];
int parent(int i){
	if(i==group[i])	return i;
	else return group[i]=parent(group[i]);
}
void merge(int i,int j){
	i=parent(i);	j=parent(j);
	group[i]=group[j];
}

int main(){
	int n;	cin>>n;
	int m;	cin>>m;
	for(int i=1;i<=n;i++)	group[i]=i;
	for(int j=0;j<m;j++){
		int a,b;	cin>>a>>b;
		merge(a,b);
	}
	map<int,int> kind;
	for(int i=1;i<=n;i++)	kind[parent(i)]++;
	int village=0,city=0;
	for(auto it:kind){
		if(it.second==1)	village++;
		else 	city++;
	}
	cout<<abs(village-city)<<endl;
	return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;

    vector<unsigned long long int> H;
    vector<vector<int>> L;

    for (int i = 0; i < n; i++)
    {
        int h;
        cin >> h;
        H.push_back(h);

        vector<int> l;
        L.push_back(l);
    }

    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;

        L[a-1].push_back(b-1);
        L[b-1].push_back(a-1);
    }

    int size = 0;

    for (int i = 0; i < n; i++)
    {
        bool frag = true;
        for (int j = 0; j < L[i].size(); j++)
        {
            if(H[i] <= H[L[i][j]]){
                frag = false;
                break;
            }
        }

        if(frag) size++;
        /* code */
    }
    
    cout << size << endl;

    return 0;
}

Measured memory_bytes: 9088
#include<string>
#include<set>
#include<map>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
using namespace std;
int rem[400],a[400][400],ff[400],pp[400];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= m; j ++){
            scanf("%d",&a[i][j]);
        }
    int ans = 0, p;
    for(int i = 1; i <= n; i ++)
        rem[a[i][1]] ++;
    for(int i = 1; i <= m; i ++){
        if(ans < rem[i])
            ans = rem[i], p = i;
    }
    for(int i = 1; i <= n; i ++)
        pp[i] = 1;
    
    for(int i = 1; i < m; i ++){
        int tem = 0;
        ff[p] = 1; rem[p] = 0;
        for(int i = 1; i <= n; i ++){
            if(!ff[a[i][pp[i]]])
                continue;
            while(ff[a[i][pp[i]]])
                pp[i] ++;
            rem[a[i][pp[i]]] ++;
        }
        for(int i = 1; i <= m; i ++){
            if(rem[i] > tem)
                p = i,tem = rem[i];
        }
        ans = min(ans, tem);
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

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

		int[] a = new int[5];
		int[] aa = new int[5];

		int i,j,temp;
		for(i = 0; i < 5; i++)
			a[i] = scan.nextInt();

		for(i = 0; i < 5; i++) {
			temp = a[i] / 10;
			if(a[i] % 10 != 0)
				temp++;
			temp *= 10;

			aa[i] = temp;
		}

		int min = Integer.MAX_VALUE;

		for(i = 0; i < 5; i++) {
			temp = 0;
			for(j = 0; j < 5; j++) {
				if(j == i) {
					temp += a[j];
				}else {
					temp += aa[j];
				}
			}
			min = Math.min(min, temp);
		}

		System.out.println(min);
	}
}


Measured memory_bytes: 22868
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

void insert(int);
void inorder(Node);
void preorder(Node);

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
      
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }

 
  }
  return 0;
  

}

void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if (z->key < x->key)
      x=x->left;
    else
      x=x->right;
  }
  z->parent=y;
  if(y==NIL)
    root=z;
  else {
    if(z->key < y->key)
    y->left=z;
  else
    y->right=z;
  }
}

void inorder(Node u){
  if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  
}

void preorder(Node u){
  if (u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}



Measured memory_bytes: 25128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int age = in.nextInt();
            if (age == 1) {
                out.println("Hello World");
            } else {
                int a = in.nextInt();
                int b = in.nextInt();
                out.println(a + b);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int l = sc.nextInt() - 1;
    int r = sc.nextInt();
    int d = sc.nextInt();
    int mr = r / d;
    int ml = l / d;
    System.out.println(mr - ml);
  }
}

Measured memory_bytes: 32580
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int n;
	scanf("%d", &n);

	int a[100000];
	int max_first_value = -1, max_first_index = -1;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (max_first_value < a[i]) {
			max_first_value = a[i];
			max_first_index = i;
		}
	}

	int max_second_value = -1, max_second_index = -1;
	for (int i = 0; i < n; i++) {
		if (i == max_first_index)
			continue;
		if (max_second_value < min(a[i], a[max_first_index] - a[i])) {
			max_second_value = min(a[i], a[max_first_index] - a[i]);
			max_second_index = i;
		}
	}

	printf("%d %d\n", a[max_first_index], a[max_second_index]);

	return 0;
}


Measured memory_bytes: 640
n,m=map(int,input().split())
list=list(range(1,n+1))
if n%2==1:
  for i in range(m):
    print(list[i],list[-1-i])
elif n%4==0:
  h=n//2
  hh=n//4
  if hh>=m:
    for i in range(m):
      print(list[i],list[-1-i])
  else:
    for i in range(hh):
      print(list[i],list[-h-1-i])
    for i in range(m-hh):
      print(list[h+i],list[-2-i])
else:
  h=n//2
  hh=(h-1)//2
  if hh>=m:
    for i in range(m):
      print(list[i],list[-1-i])
  else:
    for i in range(hh):
      print(list[i],list[-h-1-i])
    for i in range(m-hh):
      print(list[h+i],list[-2-i])

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

using namespace std;

using int64 = long long;

struct Command {
  char c;
  char dir;
};

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

  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;

  vector<Command> commands(q);
  for (int i = 0; i < q; i++) {
    char c;
    char dir;
    cin >> c >> dir;
    commands.push_back(Command({c, dir}));
  }
  
  auto find_final_position = [&](int i) -> int {
    int cur = i;
    for (const auto& command : commands) {
      if (s[cur] == command.c) {
        if (command.dir == 'R') {
          cur++;
        } else if (command.dir == 'L') {
          cur--;
        }
      }
      if (cur == n) return n;
      if (cur == -1) return -1;
    }
    return cur;
  };

  auto find_r_limit = [&]() -> int {
    if (find_final_position(n - 1) != n) return n;
    int r = n - 1;
    if (find_final_position(0) == n) return 0;
    int l = 0;
    while (r - l >= 2) {
      int m = (l + r) / 2;
      if (find_final_position(m) == n) {
        r = m;
      } else {
        l = m;
      }
    }
    return r;
  };
  int r_limit = find_r_limit();
  int r_count = n - r_limit;

  auto find_l_limit = [&]() -> int {
    if (find_final_position(0) != -1) return -1;
    int l = 0;
    if (find_final_position(n - 1) == -1) return n - 1;
    int r = n - 1;
    while (r - l >= 2) {
      int m = (l + r) / 2;
      if (find_final_position(m) == -1) {
        l = m;
      } else {
        r = m;
      }
    }
    return l;
  };
  int l_limit = find_l_limit();
  int l_count = l_limit + 1;
  // cout << "l_limit: " << l_limit << " r_limit: " << r_limit << endl;
  cout << n - (l_count + r_count) << endl;
}


Measured memory_bytes: 1420
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let m: usize = read!();
    let d: usize = read!();

    let mut ans = 0;
    for i in 1..=m {
        for j in 1..=d {
            let d1 = j % 10;
            let d2 = j / 10;
            if d1 >= 2 && d2 >= 2 && d1 * d2 == i {
                ans += 1;
            }
        }
    }

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


Measured memory_bytes: 2080
package main

import "fmt"

func main() {
	var n, money int
	fmt.Scan(&n, &money)

	for i := 0; i <= n; i++ {
		for j := 0; j <= (n-i); j++ {
			k := n-i-j
			if 10000*i+5000*j+1000*k == money {
				fmt.Println(i, j, k)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <cstdio>

using namespace std;

int main()
{
	int T;
	cin>>T;
	
	for (int ca = 1; ca <= T; ++ca)
	{
		int a, b, c;
		cin>>a>>b>>c;
		a *= a;
		b *= b;
		c *= c;
		
		if (a+b ==c || a+c == b || a == b+c)
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
package main
 
import (
  "fmt"
  "sort"
)
 
func main() {
 
  var n int
  fmt.Scanln(&n)
  v := scanFloats(n)
  sort.Float64s(v)
 
  result := v[0]
  for i := 1; i < n; i++ {
    result = (result + v[i]) / 2
  }
  
  fmt.Print(result)
}
 
func scanFloats(len int) (nums []float64) {
    var num float64
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,ans=1;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    if(ans*2>ans+k){
      ans+=k;
    }else{
      ans*=2;
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
H,W = map(int,input().split())
box_list = [input() for i in range(H)]

def search(i,j,box_list = box_list):
  count = 0
  if j > 0 and box_list[i][j-1] == "#":
    count += 1
  if j < W-1 and box_list[i][j+1] == "#":
    count += 1
  if i > 0 and box_list[i-1][j] == "#":
    count += 1
  if i < H-1 and box_list[i+1][j] == "#":
    count += 1
  if j > 0 and i < H-1 and box_list[i+1][j-1] == "#":
    count += 1
  if j < W-1 and i < H-1 and box_list[i+1][j+1] == "#":
    count += 1
  if j > 0 and i > 0 and box_list[i-1][j-1] == "#":
    count += 1
  if j < W-1 and i > 0 and box_list[i-1][j+1] == "#":
    count += 1
  return count


for i in range(H):
  answer = ""
  for j in range(W):
    if box_list[i][j] != "#": 
      answer += str(search(i,j))
    else:
      answer += "#"
  print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define Fail puts("NO"), exit(0);
#define eps 1e-10
#define maxn 100010
#define maxm 4010
#define inf 1000000007
#define mod 1000000007
#define G 3
#define pi acos(-1)
#define mp(x, y) make_pair(x, y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef bitset<maxn> bit;
int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch - '0' < 0 || ch - '0' > 9) {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch - '0' >= 0 && ch - '0' <= 9) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
int primesize, prime[maxn], miu[maxn];
bool notprime[maxn];
void init() {
    notprime[1] = 1;
    miu[1] = 1;
    for (int i = 2; i <= 100000; i++) {
        if (!notprime[i]) {
            prime[++primesize] = i;
            miu[i] = mod - 1;
        }
        for (int j = 1; j <= primesize && i * prime[j] <= 100000; j++) {
            notprime[i * prime[j]] = 1;
            if (i % prime[j] == 0) {
                miu[i * prime[j]] = 0;
                break;
            }
            miu[i * prime[j]] = mod - miu[i];
        }
    }
}
int n, K, ans;
int quick_pow(int x, int p) {
    int an = 1, po = x;
    while (p) {
        if (p & 1)
            an = 1ll * an * po % mod;
        po = 1ll * po * po % mod;
        p >>= 1;
    }
    return an;
}
int main() {
    init();
    n = read();
    K = read();
    for (int i = 1; i <= K; i++) {
        int sum = 0;
        for (int j = 1; j * i <= K; j++) {
            sum = (sum + 1ll * miu[j] * quick_pow(K / (i * j), n)) % mod;
        }
        ans = (ans + 1ll * sum * i) % mod;
    }
    cout << ans << endl;
    return 0;
}


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

string cmd_J(string s){
  string ret;
  for(int i = 1 ; i < (int)(s.size()) ; i++){
    ret += s[i];
  }
  ret += s[0];
  return ret;
}

string cmd_C(string s){
  string ret;
  ret += s[s.size()-1];
  for(int i = 0 ; i < (int)(s.size()-1) ; i++){
    ret += s[i];
  }
  return ret;
}

string cmd_E(string s){
  string a, b;
  
  if(s.size()%2 == 1){
    a = s.substr(0, s.size()/2);
    b = s.substr(s.size()/2+1, s.size());
    return b+s[s.size()/2]+a;
  }
  else{
    a = s.substr(0, s.size()/2);
    b = s.substr(s.size()/2, s.size());
    return b+a;
  }  
}

string cmd_A(string s){
  string ret = s;
  reverse(ret.begin(), ret.end());
  return ret;
}

string cmd_P(string s){
  for(int i = 0 ; i < (int)(s.size()) ; i++){
    if(isdigit(s[i])){
      int a = s[i]-'0';
      a++;
      if(a == 10) a = 0;
      s[i] = a+'0';
    }
  }
  return s;
}

string cmd_M(string s){
  for(int i = 0 ; i < (int)(s.size()) ; i++){
    if(isdigit(s[i])){
      int a = s[i]-'0';
      a--;
      if(a == -1) a = 9;
      s[i] = a+'0';
    }
  }
  return s;
}

int main(){
  int n;
  cin >> n;
  while(n--){
    string cmd, message;
    cin >> cmd >> message;
    for(int i = (int)(cmd.size()-1) ; i >= 0 ; i--){
      switch(cmd[i]){
      case 'J': 
	message = cmd_C(message);
	break;
      case 'C':
	message = cmd_J(message);
	break;
      case 'E': 
	message = cmd_E(message);
	break;
      case 'A':
	message = cmd_A(message);
	break;
      case 'P': 
	message = cmd_M(message);
	break;
      case 'M':
	message = cmd_P(message);
	break;
      }
    }
    cout << message << endl;
  }
  return 0;
}

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

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

M = int(input())

P,X = [],[]
for i in range(M):
    pi,xi = map(int,input().split())
    P.append(pi)
    X.append(xi)

tsum=sum(T[:N])

for i in range(M):
    print(tsum-T[P[i]-1]+X[i])

Measured memory_bytes: 3064
fn main() {
    proconio::input! {
        n: usize,
        a_s: [proconio::marker::Chars; n],
    }
    let a_s = a_s
        .iter()
        .map(|cs| {
            cs.iter()
                .collect::<String>()
                .split('.')
                .map(|x| x.to_string())
                .collect::<Vec<_>>()
        })
        .map(|a| {
            if a.len() == 1 {
                a[0].parse::<i128>().unwrap() * 1_000_000_000
            } else {
                a[0].parse::<i128>().unwrap() * 1_000_000_000
                    + a[1].parse::<i128>().unwrap() * 10i128.pow(9 - a[1].len() as u32)
            }
        })
        .collect::<Vec<_>>();
    let a_s = a_s
        .iter()
        .map(|a| {
            let mut a = *a;
            let mut count2 = 0;
            while a % 2 == 0 {
                count2 += 1;
                a /= 2;
            }
            let mut count5 = 0;
            while a % 5 == 0 {
                count5 += 1;
                a /= 5;
            }
            (count2, count5)
        })
        .collect::<Vec<_>>();
    let mut count25 = [[0; 19]; 19];
    for (c2, c5) in &a_s {
        for i in 0..=std::cmp::min(*c2, 18) {
            for j in 0..=std::cmp::min(*c5, 18) {
                count25[i][j] += 1;
            }
        }
    }
    let mut count = 0usize;
    for (c2, c5) in &a_s {
        let (remainc2, remainc5) = (18 - std::cmp::min(c2, &18), 18 - std::cmp::min(c5, &18));
        count += count25[remainc2][remainc5];
        if *c2 >= remainc2 && *c5 >= remainc5 {
            count -= 1;
        }
    }
    count /= 2;
    println!("{}", count);
}


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


int main()
{
  int a[5],b[5],k,t=643,s,h = 0;
  	for(k=0;k<5;k++)
    {
    cin >> a[k];
    }
  
	for(k=0;k<5;k++)
    {
      if((a[k]%10) == 0)
      {
    b[k] = a[k];
        continue;
      }
      b[k] = a[k] + (10 - (a[k]%10));
    }
  for(k=0;k<5;k++)
  {
  h += b[k];
  }
  
    for(k=0;k<5;k++)
  {
  s=h-b[k]+a[k];
  if(s<t)
  {t=s;}
  }
  
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 256
/* ****revpro**** */
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005
ll dp[3005][6005];
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n,t,a,b;
		cin>>n>>t;
		ll ans=0;
		vector <pii> v;
		rep(i,0,n) {
			cin>>a>>b;
			v.pb({a,b});
		}
		sort(all(v));
		rep(i,1,n+1){
			a=v[i-1].F;
			b=v[i-1].S;
			rep(j,0,6005) dp[i][j]=dp[i-1][j];
			rep(j,0,t) dp[i][j+a]=max(dp[i][j+a],dp[i-1][j]+b),ans=max(ans,dp[i][j+a]);
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 141184
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
#define X real()
#define Y imag()
const double INF = 1e9;
const double EPS = 1e-10;

double dot(P a, P b){return a.X*b.X + a.Y*b.Y;}

double cross(P a, P b){return a.X*b.Y - a.Y*b.X;}

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b, c) > EPS) return 1;
  if(cross(b, c) < -EPS) return -1;
  if(dot(b, c) < -EPS) return -2;
  if(norm(c) > norm(b) + EPS) return 2;
  return 0;
}

P projection(P a, P b){
  return dot(a, b)/norm(b)*b;
}

bool is_attacked(C ufo, P d, int R){
  //return (abs(ufo.first - d*(double)R) < ufo.second + EPS) || (dot(ufo.first, d) > EPS && abs(projection(ufo.first, d)) > R - EPS && abs(cross(ufo.first, d)) < ufo.second + EPS);
  P D = d*(double)R, p = ufo.first - D;
  double dist;
  if(dot(p, D) > EPS) dist = abs(cross(ufo.first, d));
  else dist = abs(p);
  return dist < ufo.second + EPS;
}

int main(){
  int R, N;
  while(cin >> R >> N){
    if(R == 0 && N == 0) break;
    vector<C> UFO(N);
    vector<int> V(N);
    for(int i = 0; i < N; ++i){
      double x, y, r;
      cin >> x >> y >> r >> V[i];
      UFO[i] = C(P(x, y), r);
    }
    int c = 0, ans = 0, t = 0;
    vector<bool> U(N, false);
    while(c < N){
      ++t;
      double closest = INF;
      int id = -1;
      for(int i = 0; i < N; ++i){
        if(U[i]) continue;
        if(abs(UFO[i].first) - t*V[i] < closest){
          if(abs(UFO[i].first) - t*V[i] <= R + EPS){
            ++c;
            ++ans;
            U[i] = true;
          }else{
            closest = abs(UFO[i].first) - t*V[i];
            id = i;
          }
        }
      }
      if(id < 0) continue;
      P d = UFO[id].first;
      d /= abs(d);
      U[id] = true;
      ++c;
      for(int i = 0; i < N; ++i){
        if(U[i]) continue;
        C ufo;
        P p = UFO[i].first;
        ufo.first = (abs(p) - t*V[i])/abs(p)*p;
        ufo.second = UFO[i].second;
        if(is_attacked(ufo, d, R)){
          U[i] = true;
          ++c;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3188
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (B % A == 0){
      System.out.println(B + A);
    }
    else{
      System.out.println(B - A);
    }
  }
}

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

cnt=0
flg =False

for i in range(N):
    D1,D2 = map(int,input().split())
    if  D1 == D2:
        cnt+=1
    else:
        cnt = 0
    
    if cnt >= 3:
        flg = True

if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62368
N = int(input())
T, A = (int(x) for x in input().split())
H = [int(x) for x in input().split()]


def calcTemp(x, y):
    return x - y * 0.006


min = 1000000
counter = 1
numPlace=0
for height in H:
    tmp = abs(A - calcTemp(T, height))
    if min > tmp:
        min = tmp
        numPlace = counter
    counter += 1
print(numPlace)


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

using namespace std;

int main()
{
    int h, w; cin >> h >> w;
    vector< vector<char> > s(h, vector<char>(w));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> s[i][j];
        }
    }

    string ans = "Yes";

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (s[i][j] == '#') {
                if ((i != 0 && s[i-1][j] != '#') && 
                    (i != h-1 && s[i+1][j] != '#') && 
                    (j != 0 && s[i][j-1] != '#') &&
                    (j != w-1 && s[i][j+1] != '#')) {
                        ans = "No";
                        break;
                }
            }
        }
        if (ans == "No") break;
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long int ll;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    double d,t,s;

    cin>>d>>t>>s;

    if(d/t > s){
        cout<<"No";
    }

    else cout<<"Yes";

    return 0;

}



Measured memory_bytes: 3732
//Love and Freedom.
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define inf 20021225
#define N 100010
#define mdn 1000000007
using namespace std;
int read()
{
	int s=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return f*s;
}
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
int pre[N],n,f[N]; ll a[N],A,B;
int get(int l,int r)
{
	if(l>r)	return 0;
	return !l?pre[r]:(pre[r]-pre[l-1]+mdn)%mdn;
}
int main()
{
	int n=read(); scanf("%lld%lld",&A,&B);
	if(A<B)	swap(A,B);
	for(int i=1;i<=n;i++)	scanf("%lld",&a[i]);
	pre[0]=f[0]=1; int l=0,r=0;
	a[0]=-1e18; a[n+1]=(2e18)+1;
	for(int i=1;i<=n+1;i++)
	{
		while(r<i&&a[i]>=a[r]+A)	r++; r--;
		if(a[i]-a[i-1]>=A)	f[i]=f[i-1];
		upd(f[i],get(l,min(r,i-2)));
		pre[i]=pre[i-1];
		if(a[i+1]-a[i-1]>=B)	upd(pre[i],f[i]);
		if(a[i]-a[i-1]<B)	l=i-1;
	}
	printf("%d\n",f[n+1]);
	return 0;
}

Measured memory_bytes: 1664
#define _DEBUG
#include "bits/stdc++.h"
#include <atcoder/all>
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace atcoder;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int T;
	scan(T);
	rep(t,T){
		int N,M,A,B;
		scan(N>>M>>A>>B);
		prin(floor_sum(N,M,A,B));
	}
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, M; 
  cin >> N >> M;

  vector<int> A(M), B(M);
  vector<vector<int>> C(M);
  REP(i, M){
    cin >> A[i] >> B[i];
    C[i].resize(B[i]);
    REP(j, B[i]){
      cin >> C[i][j];
      C[i][j]--;
    }
  }

  // i個まで見て, 開けた宝箱がj(bit)の時の最小値
  int dp[M+1][(1<<N)+1];
  REP(i, M+1) REP(j, (1<<N)) dp[i][j] = INF;
  dp[0][0] = 0;

  REP(i, M) REP(j, (1 << N)){
    int bit = 0;
    REP(k, B[i]) bit |= (1 << C[i][k]);

    chmin(dp[i+1][j], dp[i][j]);
    chmin(dp[i+1][(j | bit)], dp[i][j]+A[i]);
  }

  int ans = dp[M][(1<<N)-1];
  if(ans == INF) ans = -1;
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 32512
H,W = map(int,input().split())
N = int(input())
a = list(map(int,input().split()))

ans = [[0 for i in range(W)] for j in range(H)]

def nex(x,y):
    if y%2 == 0 and x == H-1:
        return x,y+1
    elif y%2 == 1 and x==0:
        return x,y+1
    elif y%2 ==0:
        return x+1,y
    else:
        return x-1,y

nowX,nowY = 0,0
for i in range(N):
    for j in range(a[i]):
        ans[nowX][nowY] = i+1
        nowX,nowY = nex(nowX,nowY)

for i in range(len(ans)):
    print(" ".join(list(map(str,ans[i]))))

Measured memory_bytes: 74224
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>

using namespace std;

int N,C;
int s[100001],t[100001],c[100001];
int sm[200002];
int tt[200002];
int main()
{
    cin >> N >> C;
    for(int i = 0; i < N; i++)
    {
        cin >> s[i] >> t[i] >> c[i];
    }

    for(int i = 1; i <= C; i++)
    {
        //0で初期化
        for(int j = 0; j < 200002; j++) tt[j] = 0;
        //それぞれのテレビ番組の始まる時間を1にして終わったところを-1する。
        //2倍して1引いたのは録画の間の0.5の時間をないことにするため。
        //ないことにすることで始まる時間と終わる時間が同じものは同一とみなされる。
        for(int j = 0; j < N; j++) if(c[j] == i) tt[s[j]*2-1]++, tt[t[j]*2]--;
        //累積和を作る。
        //これで録画時間が重なっている数がわかる。
        for(int j = 1; j < 200002; j++) tt[j] += tt[j-1];
        //それぞれの録画機で使う時間帯を記録したいから使っているところをチェックする。
        for(int j = 0; j < 200002; j++) if(tt[j] > 0) sm[j]++;
    }

    int ans = 0;
    //一番多く録画機を使っている時間帯を探してその数を出力したら答えになる。
    for(int j = 0; j < 200002; j++)
    {
        if(ans < sm[j]) ans = sm[j];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define N 100001
using namespace std;



int main()
{   IOS;
cout.precision(30);
    ll n,m;
    cin >> n >> m;
    ll res=100000,res1=0;
    for(int i=0;i<m;i++)
    {
        ll L , R;


        cin >> L >> R;
        res1=max(L,res1);
        res=min(R,res);

    }
//cout << res1 <<" " << res << endl;
    if(res>=res1)
        cout << res-res1+1;
    else
        cout << 0;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
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...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
//	inp_out();
	ll n;
	cin>>n;
	vll a(n);
	for(ll i=0;i<n;++i)
	{
		cin>>a[i];
	}

	ll dp[n];
	dp[0]=0;
	for(ll i=1;i<n;++i)
	{
		ll val=dp[i-1]+abs(a[i]-a[i-1]);
		if(i>1)
		{
			val=min(val,dp[i-2]+abs(a[i-2]-a[i]));
		}
		dp[i]=val;
	}
	cout<<dp[n-1];
	return 0;
}



Measured memory_bytes: 1792
n=int(input())
lists=list(map(int,input().split()))
uselists=[]
for _ in range(n):
    uselists.append(lists[_]-_-1)
uselist=sorted(uselists)
if n%2==0:
    num1=int(n/2-1)
    num2=int(n/2)
    numbers=min(uselist[num1],uselist[num2])
    
if n%2!=0:
    num1=int((n-1)/2)
    numbers=uselist[num1] 
ans=0
for x in range(n):
    ans+=abs(uselist[x]-numbers)
print(ans)

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int h1,h2,m1,m2,k;cin>>h1>>m1>>h2>>m2>>k;
	int x = (h2-h1)*60+m2-m1;
	if(x>=k) cout<<x-k;
	else cout<<0;
	return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
double PI = 3.14159;
int main(){

	cin >> n;
	printf("%0.9f\n",2*PI*n );

	
	return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
    #define ll long long
    using namespace std;
    const int N = 2e5 + 5, mod = 1e9 + 7;
     
    ll m[N];
     
    int main(){
        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
        int n, k;
        cin >> n >> k;
        ll ans = 0;
        for(int i = 1; i <= n; i++) m[i % k]++;
        ans = m[0] * m[0] * m[0];
        if(k % 2 == 0) ans += m[k >> 1 ] * m[k >> 1] * m[k >> 1];
        cout << ans;
     
        return 0;
    }

Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int i,n,count=0;
  string s;
  cin>>n>>s;
  
  for(i=0;i<n;i++){
	if(s[i]=='R'){
		count++;
    }
  }

  if(count>n/2){
	cout<<"Yes"<<endl;
  }else{
	cout<<"No"<<endl;
  }
}

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

int main()
{
  int r, c; cin >> r >> c;
  int ans[r+1][c+1] = {0};

  rep(x, r) {
    rep(y, c + 1) {
      if (y == c) {
        // ans[x][y] = summary(ans[r], c);
        int tmp = 0;
        rep (i, c) {
          tmp += ans[x][i];
        }
        ans[x][y] = tmp;
        break;
      }
      cin >> ans[x][y];
    }
  }

  // 列に対する合計計算
  rep(y, c + 1) {
    int colSum = 0;
    rep(x, r + 1) {
      if (x==r){
        ans[x][y] = colSum;
      }
      colSum += ans[x][y];
    }
  }

  rep(x, r+1) {
    rep(y, c+1) {
      cout << ans[x][y];
      if (y != c) {
        cout << " ";
      } else {
        cout << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define ST first
#define ND second
#define EB emplace_back
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
template<class T> int size(T &&x) {
	return int(x.size());
}
#ifdef DEBUG
template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto it = x.begin(); it != x.end(); ++it)
		out << *it << (it == --x.end() ? "" : ", ");
	return out << '}';
}
void dump() {}
template<class T, class... Args> void dump(T &&x, Args... args) {
	cerr << x << ";  ";
	dump(args...);
}
  const int seed = 1;
  struct Nl{~Nl(){cerr << '\n';}};
# define debug(x...) cerr << (#x != "" ? #x ":  " : ""), dump(x), Nl(), cerr
#else
  const int seed = chrono::system_clock::now().time_since_epoch().count();
# define debug(...) 0 && cerr
#endif
mt19937_64 rng(seed);
int rd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(rng);
}

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

	int x, a;
	cin >> x >> a;
	if(x < a) cout << 0 << "\n";
	else cout << "10\n";
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//入力値
      	int n = sc.nextInt();
      	//配列
      	int a[] =new int[n];
     	
     	//入力値を配列に格納
      	for(int i=0;i<n;++i){
          a[i] = sc.nextInt();
        }
      	//カウントする
      	int count = 0;
      	for(int i=0;i<n;i++){
        	while(a[i]%2==0){
            	a[i] = a[i]/2;
         	 	count++;
            }
        }
      System.out.print(count);
      
    }
}

Measured memory_bytes: 47964
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N, x; cin >> N >> x;
    if (x == 1 || x == 2*N-1) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    vector<int> ans(2*N-1);
    if (N == 2) ans = { 1, 2, 3 };
    else {
        if (x != 2) ans[N-3] = x-2;
        ans[N-2] = x+1;
        ans[N-1] = x;
        ans[N  ] = x-1;
        if (x == 2) ans[N+1] = x+2;
        int curr = 1;
        int s = (x == 2 ? x-1 : x-2);
        int e = (x == 2 ? x+2 : x+1);
        for (int i = 0; i < 2*N-1; i++) {
            if (ans[i] == 0) {
                if (curr == s) curr = e+1;
                ans[i] = curr;
                curr++;
            }
        }
    }
    for (auto a : ans) cout << a << '\n';
    return 0;
}

Measured memory_bytes: 2304