akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int a, b;
    int n = 0;
    //Cormen-- the best friend of man
//    cin>> a>>b;
//    int walks [a];
//    for (int i = 0; i< a; i++){
//        cin>> walks[i];
//    }
//    for (int i = 1; i<a; i++){
//        int h = b -(walks[i] + walks[i-1]);
//        if (h<= 0){
//            continue;
//        }
//        else {
//            walks[i]+=h;
//            n+= h;
//        }
//    }
//
////    if (a ==1){
////        n = b-walks[0];
////        if (n<0){
////            n =0;
////        }
////        else {
////            walks[0]+=n;
////        }
////    }
//
//    cout << n<< endl;
//    for (int i = 0; i< a; i++){
//        cout << walks[i]<< " ";
//    }
    //fifty -fifty
//    int samecharacter = 0;
//    char input[4];
//    for (int i = 0; i< 4; i++){
//        cin>> input[i];
//    }
//    for (int i = 0; i< 4; i++){
//        for (int j = i+1; j< 4; j++){
//            if (input[i] == input[j]){
//                samecharacter++;
//            }
//        }
//    }
//    if (samecharacter == 2){
//        cout << "Yes";
//    }
//    else {
//        cout << "No";
//    }
    //go to school
    cin>> a;
    int students[a];
    int studentoutput[a];
    
    for (int i = 0; i< a; i++){
        cin>> students[i];
        studentoutput[i] = 0;
    }
    for (int i = 0; i< a; i++){
        int h =
        studentoutput[students[i] - 1] = i+1;
    }
    for (int i = 0; i< a; i++){
        cout << studentoutput[i]<< " ";
    }
//    for (int i = 1; i< a+1; i++){
//        for (int j = 0; j< a; j++){
//            if (students[j] == i){
//                cout << j+1<< " ";
//                break;
//            }
//        }
//    }
    //turn the rectangles
//    bool pass = true;
//    int h;
//    cin>> a;
//    int rectangles [a][2];
//
//    for (int i = 0; i< a; i++){
//        for (int j = 0; j< 2; j++){
//            cin>> rectangles[i][j];
//        }
//    }
//    if (rectangles[0][0] >=rectangles[0][1]){
//        h = rectangles[0][0];
//    }
//    else {
//        h = rectangles[0][1];
//    }
//    cout << endl;
//    for (int i = 1; i< a; i++){
//        if(rectangles[i][0] <=h || rectangles[i][1]<=h){
//            if (rectangles[i][0]<=h && rectangles[i][1]<=h){
//                if (rectangles[i][0]<=rectangles[i][1]){
//                    h = rectangles[i][0];
//                }
//                else {
//                    h = rectangles[i][0];
//                }
//            }
//            else if (rectangles[i][0]<=h){
//                h = rectangles[i][0];
//            }
//            else if (rectangles[i][1]<=h){
//                h = rectangles[i][1];
//            }
////            cout << h;
//
//            continue;
//        }
//        else {
//            pass = false;
//            break;
//        }
//    }
//    if (pass){
//        cout << "YES";
//    }
//    else {
//        cout<< "NO";
//    }
    
    
    return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>

using namespace std;

struct Node
{
	int num, cost, ticket;
	Node(int n, int c, int t)
	{
		num = n;cost = c; ticket = t;
	}

	bool operator < (const Node &o) const
	{
		return cost > o.cost;
	}
};

const int MAX_NODE_ID = 512;
const int MAX_TICKET = 16;
bool visited[MAX_NODE_ID][MAX_TICKET];

int c, n, m, s, d;

#define MAX 50000
int map[101][101];

int main()
{
	while (true)
	{
		cin >> c >> n >> m >> s >> d;
		if (c == 0 && n == 0 && m == 0 && s == 0 && d == 0) break;
		for (int i = 0; i <= n; i++)
			for (int j = 0; j <= n; j++)
				map[i][j] = MAX;
		for (int i = 0; i < m; i++)
		{
			int a, b, f;
			cin >> a >> b >> f;
			map[a][b] = map[b][a] = f;
		}
		for (int i = 0; i < MAX_NODE_ID; i++)
			for (int j = 0; j < MAX_TICKET; j++)
				visited[i][j] = false;
		priority_queue<Node> que;
		que.push(Node(s, 0, c));
		while (!que.empty())
		{
			Node nod = que.top();
			que.pop();
			if (nod.num == d)
			{
				cout <<	nod.cost << endl;
				break;
			}
			else
			{
				for (int i = 1; i <= n; i++)
				{
					if (map[nod.num][i] < MAX && !visited[nod.num][nod.ticket])
					{
						que.push(Node(i, nod.cost + map[nod.num][i], nod.ticket));
						if (nod.ticket > 0)
						{
							que.push(Node(i, nod.cost + map[nod.num][i] / 2, nod.ticket - 1));
						}
					}
				}
			}
			visited[nod.num][nod.ticket] = true;
		}
	}
	return 0;
}

Measured memory_bytes: 0
from collections import deque

def bfs(s):
    ans = [-1] * (n + 1)
    ans[s] = 0
    q = deque()
    q.append(s)
    while q:
        p = q.popleft()
        for i in G[p]:
            if ans[i] == -1:
                ans[i] = p
                q.append(i)
    return ans

n, m = map(int, input().split())
G = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
a = bfs(1)
print("Yes")
for i in range(2, n + 1):
    print(a[i])

Measured memory_bytes: 94760
n = int(input())
a = list(map(int,input().split()))
MX = 10**18
ans = 1
a.sort()
for x in a:
    if x == 0:
        print(0)
        exit(0)
    else:
        ans *= x
        if ans > MX:
            print(-1)
            exit(0)
print(ans)

Measured memory_bytes: 84744
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#define mem(u, v) memset(u, v, sizeof(u))
#define INF 0x3f3f3f3f
#define pii pair<int, int >
#define LL long long
#define mid (l + r) / 2
#define lowbit(x) x & -x
using namespace std;
const int MAXN = 1e5 + 7,  MAXM = 1e5 + 7, MAXK = 1e5 + 7;

LL gcd(LL a, LL b){
	if (b == 0) return a;
	else return gcd(b, a % b);
}

int main(){
	int T;
	scanf("%d", &T);
	while (T--){
		LL a, b, c, d;
		scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
		if (a < b) printf("No\n");
		else if (d < b) printf("No\n");
		else if (c + 1 >= b) printf("Yes\n");
		else {
			LL g = gcd(b, d);
			if ((a - b) / g - (a - c - 1) / g >= 0) printf("Yes\n");
			else printf("No\n");
		}
	}
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

int main() {
    int N; cin >> N;
    int ans = 0;

    rep(i,N){
        if(i+1 < 105) continue;
        int num = i+1;
        if(num%2==0) continue;
        int tmp = 0;
        rep(j,num){
            if(num % (j+1) == 0) tmp++;
        }
        if(tmp == 8) ans++;
    }

    cout << ans << "\n";
    return 0;
}


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

int main(){
	int x,t; cin>>x>>t;
	if(x-t<=0) cout<<0<<endl;
	else cout<<x-t<<endl;
}

Measured memory_bytes: 3564
def process(a):
    tmp = a[0]
    pushed = set()
    cnt = 1
    while not tmp in pushed:
        if tmp == 2:
            return cnt
        pushed.add(tmp)
        tmp = a[tmp - 1]
        cnt += 1
    return -1

if __name__ == '__main__':
    a = [int(input().strip()) for _ in range(int(input().strip()))]
    print(process(a))

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

int top = 0, S[1000];

int pop(){
	top--;
	return S[top + 1];
}

void push(int x){
	S[++top] = x;
}

int main(){
	char s[100];
	while(scanf("%s", s) != EOF){

		if(s[0] == '+'){
			int a = pop();
			int b = pop();
			push(a + b);
		}else if(s[0] == '*'){
			int a = pop();
			int b = pop();
			push(a * b);
		}else if(s[0] == '-'){
			int a = pop();
			int b = pop();
			push(b - a);
		}else{
			push(atoi(s));
		}
		//break;
	}

	printf("%d\n", S[1]);
	return 0;
}



Measured memory_bytes: 3192
(defun main ()
  (let* ((s (read-line))
         (lens (length s))
         (ans (make-array lens :element-type 'integer
                               :initial-element 0
                               :adjustable t))
         (lc 0)
         (rc 1)
         (pre #\R))
    (loop for i from 1 below lens
          do (cond ((equal (char s i) #\R) (incf rc)
                    (setf pre #\R))
                   ((equal pre #\R) (incf (aref ans i) (floor rc 2))
                    (incf (aref ans (1- i)) (floor (1+ rc) 2))
                    (setf rc 0)
                    (setf pre #\L))))
    (loop for i from (1- lens) downto 0
          do (cond ((equal (char s i) #\L) (incf lc)
                    (setf pre #\L))
                   ((equal pre #\L) (incf (aref ans (1+ i)) (floor (1+ lc) 2))
                    (incf (aref ans i) (floor lc 2))
                    (setf lc 0)
                    (setf pre #\R))))
    (loop for i from 0 below (1- lens)
          do (format t "~A " (aref ans i)))
    (format t "~A~%" (aref ans (1- lens)))))


(main)


Measured memory_bytes: 10856
#include <stdio.h>
int main(int argc, char *argv[])
{
	int a,b,c,x,y,z,s;
	scanf("%d %d %d",&a,&b,&c);
	x=a+b;
	y=a+c;
	z=b+c;
    s=x<y?x:y;
    s=s<z?s:z;
    printf("%d",s);
	return 0;
}

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

struct Data{
  int a,b,c;
  Data(){    a=b=c=-1;  }
  void insert(int x){
    if(a==x||b==x||c==x)return;
    c=b;
    b=a;
    a=x;
  }
  bool count(int x){
    return (a==x||b==x||c==x);
  }
  int size(){
    return (a>=0)+(b>=0)+(c>=0);
  }
  void erase(int x){
    if(a==x){
      a=b;b=c;c=-1;
    }else if(b==x){
      b=c;c=-1;
    }else if(c==x){
      c=-1;
    }
  }
};

int N,K;
vector<int> G[MAX];
Data g[MAX];

int f[MAX],bs[MAX];
bool visited[MAX];


int px[MAX],py[MAX];


bool dfs(int v){
  visited[v]=true;
  for(int i=0;i<(int)G[v].size();i++){
    int u=G[v][i];
    

    if(f[u]>(int)g[u].size()){
      g[v].insert(u);
      g[u].insert(v);
      return true;
    }
    
    for(int j=0;j<(int)G[u].size();j++){
      int w=G[u][j];
      if(g[u].count(w)==0)continue;
      
      if(!visited[w]&&dfs(w)){
        g[v].insert(u);
        g[u].insert(v);

        g[u].erase(w);
        g[w].erase(u);
        return true;
      }
    }
  }
  return false;
}

void rec(int v,int depth=0){
  if(bs[v]!=-1)return;
  bs[v]=depth%2;
  for(int i=0;i<(int)G[v].size();i++){
    rec(G[v][i],depth+1);
  }
}

int main(){
  cin>>N>>K;
  for(int i=0;i<N;i++){
    cin>>px[i]>>py[i];
    for(int j=0;j<i;j++){
      int X=px[i]-px[j];
      int Y=py[i]-py[j];
      if( abs(X) <=1 && abs(Y)<=1){
        G[i].push_back(j);
        G[j].push_back(i);
      }
    }
  }
  for(int i=0;i<N;i++){
    sort(G[i].begin(),G[i].end());
  }
  
  memset(bs,-1,sizeof(bs));
  for(int i=0;i<N;i++){
    rec(i);
  }
  
  fill(f,f+MAX,1);
  int maxflow=0;
  for(int i=0;i<N;i++){
    if(f[i]==(int)g[i].size())continue;
    memset(visited,false,sizeof(visited));
    if( dfs(i) )maxflow++;
  }
  
  if( N-maxflow < K ){
    cout<<-1<<endl;
    return 0;
  }

    bool ans[MAX]={};
  for(int v=0;v<N;v++){
    bool flg=false;
    for(int i=0;i<(int)G[v].size();i++){
      if( ans[G[v][i]] ){
        flg=true;
      }
    }
    if(flg)continue;
    f[v]=3;
    
    int c=0;
    while(1){
      memset(visited,false,sizeof(visited));
      int a=dfs(v);
      if(a==0)break;
      c++;
    }
    
    if( N - (maxflow+c)>= K ){
      ans[v]=true;
      maxflow+=c;
    }else{
      f[v]=1;
      while(g[v].size()>1){
        int u=g[v].a;
        g[u].erase(v);
        g[v].erase(u);
      }
    }
  }
  
  for(int i=0;i<N;i++){
    if(ans[i]&&K>0){
      cout<<i+1<<endl;
      K--;
    }
  }
  return 0;
}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define pb			    push_back
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    int a[n+9];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n, greater<int>());
    ll sum = 0;
    for(int i = 1; i < n; ++i) {
        sum += (ll)a[i / 2];
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
	lli n;
	scanf("%d",&n);
	lli a[n];
	for(int i=0;i<n;++i){
		scanf("%lld",&a[i]);
	}
	lli ans=1;
	lli sum=0;
	sort(a,a+n);
	for(int i=0;i<n;++i){
		if(sum*2>=a[i])
			++ans;
		else
			ans=1;
		sum+=a[i];
	}
	printf("%lld",ans);
	return 0;
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

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

  string s, t;
  cin >> s >> t;
  rep(i, s.size()) {
    if (s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3656
import itertools
import math
import fractions
import functools
import copy
n, m = map(int, input().split())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))

ab.sort(key=lambda x: x[0])

yen = 0
amount = 0
index = 0
for i in range(n):
    if amount < m:
        yen += ab[i][0] * ab[i][1]
        amount += ab[i][1]
        index = i
    else: break
b = 0
for i in range(index):
    b += ab[i][1]
print(yen - ab[index][1]*ab[index][0] + ab[index][0]*(m-b))


Measured memory_bytes: 90196
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}


pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: i64 = 1_000_000_007;
const INF: i64 = std::i64::MAX/3;

fn solve() {
	let n = read!(usize);
	let ab = read!(i64,i64;n);
	let mut a = ab.iter().map(|&(x,y)| x).collect::<Vec<i64>>();
	let mut b = ab.iter().map(|&(x,y)| y).collect::<Vec<i64>>();
	a.sort();
	b.sort();
	let u = a[(n-1)/2];
	let v = b[(n-1)/2];
	let w = a[n/2];
	let x = b[n/2];
	let mut ans = v-u+1;
	if n%2==0 {
		ans = ((v+x) - (u+w)+1);
	}
	println!("{}",ans);
}

fn run() {
    solve();
}


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

using namespace std;

long long INF = 1LL << 60;

long long a[100005];
long long max_non_leaf[100005];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i <= n; i++) {
        cin >> a[i];
    }
    if (n == 0) {
        if (a[0] == 1) {
            cout << 1 << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }
    max_non_leaf[0] = 1;
    for (int i = 0; i < n; i++) {
        max_non_leaf[i + 1] = min(INF, max_non_leaf[i] * 2LL - a[i + 1]);
        if (max_non_leaf[i + 1] < 0) {
            cout << -1 << endl;
            return 0;
        }
    }
    if (a[0] != 0) {
        cout << -1 << endl;
        return 0;
    }

    long long ans = a[n];
    long long nodes = a[n];
    for (int i = n - 1; i >= 0; i--) {
        nodes = min(max_non_leaf[i], nodes) + a[i];
        ans += nodes;
    }
    cout << ans << endl;
    return 0;
}

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

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

using namespace std;

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

    string s;
    cin >> s;
    s[3] = '8';
    cout << s << '\n';
}

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

int main(){
  int n , k, sum = 0;
  cin >> n >> k;
  vector<int> vec(n);
  for(int i = 0; i < n; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  
  for(int i = 0; i < k; i++){
    sum += vec.at(i);
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	// CODE FESTIVAL 2016 qual A-C, 1048, 
	string s; int k; cin >> s >> k;
	int len = s.size();
	rep(i, len) {
		if (s[i] == 'a') continue;
		if ('z' - s[i] + 1 <= k) {
			k -= 'z' - s[i] + 1;
			s[i] = 'a';
		}
	}
	k %= 26;
	s.back() += k;
	if ('z' < s.back()) s.back() -= 26;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3736
#define _CRT_NO_SECURE_WARNINGS
#include <stdio.h>
#include <iostream>
using namespace std;


int main()
{
	
	char a[5];
	char b[5];
	//gets_s(a);
	cin >> a;
	int count1 = 0, count2 = 0;

	for (int i = 0; i < 3; i++)
	{			
		if (a[0] == a[i+1])
		{
			count1++;			
		}
		else
		{			
			if (b[0] == a[i + 1])
			{
				count2++;
			}
			b[0] = a[i + 1];
		}
		
	}
	if (count1 == 1 && count2 == 1) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }


}

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

public class Main {
public static void main(String args[])
{
	Scanner scan=new Scanner(System.in);
	int n=scan.nextInt();
	int k=scan.nextInt();
	int h[]=new int[n];
	for(int i=0;i<n;i++)
	{
		h[i]=scan.nextInt();
	}
	long dp[]=new long[n];
	Arrays.fill(dp,Long.MAX_VALUE);
	dp[0]=0;
	
	for(int i=1;i<n;i++)
	{
		//1 step to k steps
		long dist=-1;
		for(int cur=1;cur<=k;cur++) {
			if(i-cur<0)
			{
				break;
			}
			else {
			dp[i]=Math.min(Math.abs(h[i]-h[i-cur])+dp[i-cur],dp[i]);
			}
		}
//		System.out.println(dp[i]);
	}
	System.out.println(dp[n-1]);
	
}
}


Measured memory_bytes: 50468
from collections import deque

def main():
    s=deque(input())
    q=int(input())
    
    right=True
    for _ in range(q):
        l=list(map(str,input().split()))
        if l[0]=='1':
            if right:
                right=False
            else:
                right=True
        else:
            if l[1]=='1':
                if right:
                    s.appendleft(l[2])
                else:
                    s.append(l[2])
            else:
                if right:
                    s.append(l[2])
                else:
                    s.appendleft(l[2])
    
    if right:
        print(''.join(s))
    else:
        print(''.join(list(s)[::-1])) 

if __name__=='__main__':
    main()

Measured memory_bytes: 10228
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int dp[1000030] = {};
int ok[1000030] = {};
int ok1[1000030] = {};
int main() {
	int n;
	cin >> n;
	vector<int>v;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		v.push_back(a);
		dp[a]++;
	}
	sort(v.begin(), v.end());
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		if (ok[v[i]] == 0 && dp[v[i]] == 1) {
			ans++;
		}
		if (ok1[v[i]] == 0) {
			for (int j = v[i]; j <= 1000000; j = j + v[i]) {
				ok[j] = 1;
			}
			ok1[v[i]] = 1;
		}
	}
	cout << ans;
}

Measured memory_bytes: 15868
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int N;
   string S;
   cin>>N>>S;
   map<char,int> dataA;
   map<char,int> dataB;
   int maxC=0;
   rep(i,N-1){
       int cnt=0;
       dataA.clear();
       dataB.clear();
       rep(j,i+1){
           dataA[S[j]]++;
       }
       rep(k,N-i-1){
           dataB[S[N-k-1]]++;
       }
       
       for(auto mapA : dataA){
           auto K=mapA.first;
           
           if(dataB.count(K)){
               cnt++;
           }
       }
       maxC=max(maxC,cnt);
   }
   cout<<maxC<<endl;
 
}

Measured memory_bytes: 3620
from itertools import product
n, m = map(int, input().split())
xyz = [tuple(map(int, input().split()))for _ in range(n)]

ans = 0
for subset in product((-1, 1), repeat=3):
    def func(xyz):
        return sum(x*a for x, a in zip(xyz, subset))
    score = sum(sorted(map(func, xyz), reverse=True)[:m])
    if ans < score:
        ans = score
print(ans)


Measured memory_bytes: 9212
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n, p, o;
	int[] r = {0, 0, 0};
	String[] event = {"HIT", "HOMERUN", "OUT"};
	String a;

	while (sc.hasNextInt()) {
	    n = sc.nextInt();
	    while (n-- > 0) {
		p = 0;
		o = 0;

		while (true) {
		    a = sc.nextLine();
		    if (a.equals(event[0])) {
			if (r[2] == 1) {
			    r[2] = 0;
			    p++;
			}
			if (r[1] == 1) {
			    r[1] = 0;
			    r[2]++;
			}
			if (r[0] == 1) {
			    r[0] = 0;
			    r[1]++;
			}
			r[0]++;
		    }
		    else if (a.equals(event[1])) {
			if (r[2] == 1) p++;
			if (r[1] == 1) p++;
			if (r[0] == 1) p++;
			p++;
			r[2] = 0;
			r[1] = 0;
			r[0] = 0;
		    }
		    else if (a.equals(event[2])){
			o++;
			if (o == 3) {
			    r[0] = 0;
			    r[1] = 0;
			    r[2] = 0;
			    break;
			}
		    }
		}
		System.out.println(p);
	    }
	}
    }
}

Measured memory_bytes: 25872
n = int(input())
A = list(map(int, input().split()))

dp = [[0, float("-inf")] for i in range(n+1)]

for i in range(n):
	dp[i+1][0] = max(dp[i][0]+A[i], dp[i][1]-A[i])
	dp[i+1][1] = max(dp[i][0]-A[i], dp[i][1]+A[i])

print(dp[n][0])

Measured memory_bytes: 25644
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    N = get_ln_int_inputs()[0]
    A = get_ln_int_inputs()[0]
    print(N * N - A)
    return


main()

Measured memory_bytes: 3064
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, K);
    ll a = 0;
    ll x = 7 % K;
    REP(i, 10 * K)
    {
        a = (a + x) % K;
        if (a == 0)
        {
            OUT(i + 1);
            return 0;
        }
        x = (10 * x) % K;
    }
    OUT(-1);
}

Measured memory_bytes: 3600
N = int(input())
S = str(input())

animal = ["S", "W"]

start = [[0, 0], [0, 1], [1, 0], [1, 1]]#最初の2つを指定

for i, j in start:
  ans = [-1] * N
  ans[0] = i
  ans[1] = j
  p = 0
  for k in range(N - 1):
    #print(ans)
    if p == 0:
      if k == 0:
        if S[k] == "o":
          if ans[k] == 0:
            ans[-1] = ans[1]
          else:
            ans[-1] = 1 - ans[1]
        else:
          if ans[k] == 0:
            ans[-1] = 1 - ans[1]
          else:
            ans[-1] = ans[1]
      else:
        if S[k] == "o":
          if ans[k] == 0:
            now = ans[k - 1]
            if ans[k + 1] == 1 - now:
              p = 1
            else:
              ans[k + 1] = now
          else:
            now = 1 - ans[k - 1]
            if ans[k + 1] == 1 - now:
              p = 1
            else:
              ans[k + 1] = now            
        else:
          if ans[k] == 0:
            now = 1 - ans[k - 1]
            if ans[k + 1] == 1 - now:
              p = 1
            else:
              ans[k + 1] = now
          else:
            now = ans[k - 1]
            if ans[k + 1] == 1 - now:
              p = 1
            else:
              ans[k + 1] = now
  
  #N == 3の時に備えて
  if ans[-1] == 0:
    if S[-1] == "o":
      if ans[-2] != ans[0]:
        p = 1
    else:
      if ans[-2] == ans[0]:
        p = 1
  else:
    if S[-1] == "o":
      if ans[-2] == ans[0]:
        p = 1
    else:
      if ans[-2] != ans[0]:
        p = 1
  
  if p == 0:
    #print(ans)  
    for i in range(N):
      if ans[i] == 0:
        print("S", end = "")
      else:
        print("W", end = "")
    quit()
    
print(-1)
            
        
        
        
        
          
          
          
          

Measured memory_bytes: 10600
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 710;
const int MOD = 1000000007;

ll dp[MAX][MAX];
// dp[i][j] is from i to j no max can remove

int main(){
  vector<ll> ans;
  while(1){
    ll N; cin >> N; if(N == 0) break;
    vector<ll> a(N); rep(i,N) cin >> a[i];
    // dp syokika
    rep(i,MAX) rep(j,MAX) dp[i][j] = 0;

    repn(i,N){
      // i は何個先か
      rep(j,N){
        // j is start
        if(dp[j + 1][j + i - 1] == (i - 1) and abs(a[j] - a[j + i]) < 2){
          // 両端に追加できる
          dp[j][j + i] = max(dp[j][j + i] , dp[j + 1][j + i - 1] + 2);
        }
        for(ll k = j; k <= i + j; k++){
          // kを飛ばす
          dp[j][j + i] = max(dp[j][j + i] , dp[j][k] + dp[k + 1][j + i]);
        }
      }
    }
    ans.pb(dp[0][N - 1]);
  }

  rep(i,ans.size()) cout << ans[i] << endl;
}



Measured memory_bytes: 7104
#include <stdio.h>

int main(){
  int n, q , a[100005], b[100005];;
  scanf("%d %d", &n, &q);
  char s[100005];  scanf("%s", s);

  int ac[100005] = {0}, now = 0;
  for(int i=1; i<n; i++){
    if(s[i-1]=='A' && s[i]=='C')
      now++;
    ac[i] = now;
  }

  for(int i=0;i<q;i++){
   scanf("%d %d", &a[i], &b[i]);
  }
  for(int i=0;i<q;i++){

    printf("%d\n", ac[b[i]-1]-ac[a[i]-1]);
  }




  return 0;
}


Measured memory_bytes: 2980
n=int(input())
l=list(map(int,input().split()))

right_list=[] #右に進む
left_list=[] #左に進む
diff_list=[] #差分

right_list.append(l[0])
left_list.append(l[n-1])

for i in range(1,n):
    right_list.append(right_list[i-1]+l[i])
    left_list.append(left_list[i-1]+l[n-1-i])

left_list.reverse()

for i in range(0,n-1):
    diff_list.append(abs(right_list[i]-left_list[i+1]))

print(min(diff_list))

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

int main() {
  int n=0;
  int ac=0;
  int wa=0;
  int tle=0;
  int re=0;
  cin>>n;
  rep(i,0,n){
    string s="";
    cin>>s;
    if(s=="AC"){
      ac++;
    }
    if(s=="WA"){
      wa++;
    }
    if(s=="TLE"){
      tle++;
    }
    if(s=="RE"){
      re++;
    }
  }
    cout<<"AC x "<<ac<<endl<<"WA x "<<wa<<endl<<"TLE x "<<tle<<endl<<"RE x "<<re;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int k, s; cin >> k >> s;

    int ans = 0;

    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k; ++j) {
            if (0 <= s - i - j && s - i - j <= k) {
                ++ans;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
string S;
int ans=0;
void solve(){
    vector<int> Z(S.size());
    Z[0] = S.size();
    int i = 1, j = 0;
    while(i < S.size()){
        while(i + j < S.size() && S[j] == S[i + j]) j++;
        Z[i] = j;
        if(j == 0){
            i++;
            continue;
        }
        int k = 1;
        while(k < j && k + Z[k] < j){
            Z[i + k] = Z[k];
            k++;
        }
        i += k;
        j -= k;
    }
    rep(i,S.size()-1) if(Z[i+1]<=i+1) ans=max(ans,Z[i+1]);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin>>n>>s;
    rep(i,n){
        S.clear();
        S=s.substr(i,n-i);
        solve();
    }
    cout<<ans;
}

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

int main() {
  int N;cin>>N;
  int X;cin>>X;
  int L;L=0;
  int kyori;kyori=0;
  for(int i=0;i<N;i++){
    cin>>L;
    kyori+=L;
    if(kyori>X){
      cout<<i+1<<endl;
      return 0;
    }
  }
  cout<<N+1<<endl;
  return 0;
}

Measured memory_bytes: 384
N,T = map(int,input().split())
t = list(map(int,input().split()))
ans = 0
for i in range(N-1):
  if t[i+1] - t[i] > T:
    ans += T
  else:
    ans += t[i+1] - t[i]
ans += T
print(ans)
    

Measured memory_bytes: 30772
#include<stdio.h>
#include<string.h>
#define N 1000

int maxs(int i,int j){
  if(i>j)return i;
  else return j;
}

int lcs(char X[],char Y[]){
  int m,n;
  int max=0;
  int i,j;
  int c[N+1][N+1];
  m=strlen(X);
  n=strlen(Y);
  for(i=0;i<=m;i++){
    c[i][0]=0;
  }
  for(j=1;j<=n;j++){
    c[0][j]=0;
  }
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i-1]==Y[j-1])c[i][j]=c[i-1][j-1]+1;
      else c[i][j]=maxs(c[i][j-1],c[i-1][j]);
    max=maxs(max,c[i][j]);
  }
  }
 return max;
}

int main(){
  char X[N],Y[N];
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%s%s",X,Y);
  printf("%d\n",lcs(X,Y));
  }
  return 0;
}



Measured memory_bytes: 5620
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;
const int INF = 1001001001;


int main() {

    int n,k;
    cin >> n >> k ;
    int a[n];
    int ans ;

    for(int i=0;i<n;i++){
        cin >> a[i] ;
    }

    double tmp = n-k ;
    if(tmp==0){
     cout << 1 << endl ;
     return 0 ;
    }
    else{
     double tmp2 = tmp/(k-1) ;
     ans = ceil(tmp2) ;
    }

    cout << ans+1 << endl ;

    return 0 ;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;

int main()
{
	int n;
	cin >> n;
	vector<int> p(n + 1);
	rep1(i, n) cin >> p[i];
	int ans = 0;
	int i = 1;
	while(i<= n)
	{
		if (p[i] == i)
		{
			ans++;
			i += 2;
		}
		else
		{
			i++;
		}
	}
	co(ans);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll scoring(ll score , ll choose, ll day, vector<ll> &c,vector<vector<ll>> s,vector<ll> last){
    //--choose;
    score += s[day][choose];
    ll hiku = 0;
    ++day;
    last[choose] = day;
    rep(i,26){
        hiku += c[i]*(day - last[i]);
    }
    score -= hiku;
    return score;
}

//ミョ(-ω- ?)
int main() {
    ll d;
    cin >> d;
    const ll n = 26;
    vector<ll> c(n,0);
    rep(i,n)cin >> c[i];
    vector<vector<ll>> s(365,vector<ll>(n,0));
    rep(i,d)rep(j,n)cin >> s[i][j];
    vector<ll> last(n,0);
    ll score = 0;
    rep(i,d){
        ll res = 0;
        ll max_score = LONG_LONG_MIN;
        rep(j,n){
            int ch = scoring(score,j,i,c,s,last);
            if(max_score < ch){
                res = j;
                max_score = ch;
            }
            if(i > 52)cerr << ch << " " << i << "日" << j << "選択" << endl;
        }
        cout << res + 1 << endl;
        last[res] = i+1;
        score = max_score;
    }
    return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	vector<ll> a(n);
	ll q=0, j;
	for(auto &x : a)
		cin >> x;
	for(ll i=1; i<n; i++){
		if(i == 1)
			q = __gcd(a[i], a[i-1]);
		else
			q = __gcd(q, a[i]);
	}
	cout << q;
	return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int a[100001];

int main() {

	ll n;
	ll a[100001];
	ll c[100001]={};

	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	sort(a,a+n);

	ll x=0;
	ll y=0;
	for(ll i=n-1; i>=1; i--){
		if(a[i]==a[i-1]){
			x=a[i];
			c[i]=1;
			c[i-1]=1;
			break;
		}
	}
	for(ll i=n-1; i>=1; i--){
		if(a[i]==a[i-1]){
			if(c[i]==0){
				y=a[i];
				break;
			}
		}
	}
	cout<<x*y<<endl;

	return 0;
}


Measured memory_bytes: 1792
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 300005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	fast
	ll n, d;
	cin >> n >> d;
	ll ans = 0;
	loop(i, n)
	{
		ll x, y;
		cin >> x >> y;
		if ((x * x + y * y) <= d * d)
			++ans;
	}
	cout << ans << END;



// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}


Measured memory_bytes: 3656
from math import ceil
N, A, B = map(int, raw_input().split(' '))
h = [int(raw_input()) for _ in range(N)]

def enough(T):
    bt = B * T
    ab = A - B
    atk = sum([ceil(float(v - bt) / ab) for v in h if v > bt])
    if atk <= T:
        return True
    return False

l = 0
r = max(h) / B + 1
while r - l > 1:
    T = (l + r) / 2
    if enough(T):
        r = T
    else:
        l = T
if r == 2:
    if enough(1):
        r = 1
print r

Measured memory_bytes: 11928
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
          int num1 = scan.nextInt();
          int num2 = scan.nextInt();
   int s=num1*num2;
   int l=(num1+num2)*2;
   System.out.print(s);
   System.out.print(" ");
System.out.println(l);
          scan.close();

}
}



Measured memory_bytes: 26100
#include<iostream>
#include<queue>
#include<algorithm>
#include<numeric>
#include<string>
#include<map>
#include<bitset>
#include<cmath>

using namespace std;
using int_greater_PQ = priority_queue<int,vector<int>,greater<int>>;


int main() 
{
    int N;
    cin>>N;

    string S;
    cin>>S;

    if(N%2==1)
    {
        cout<<"No"<<endl;
        return 0;
    }

    string S1;
    for (int i = 0; i < N/2; i++)
    {
        S1.push_back(S[i]);
    }
    S.erase(0,N/2);

    if(S1==S)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    else
    {
        cout<<"No"<<endl;
        return 0;
    }
    
    
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=1e6+10;
int a[N];

int main(){
	ll i,j,k=1,n;
	cin>>n;
	while(k<=n){
		k*=2;
	}
	cout<<k/2;
	return 0;
}


Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int N, M;
  cin >> N >> M;
  ll maxL = 1;
  ll minR = N;
  rep(i, N){
    ll l, r;
    cin >> l >> r;
    maxL = max(maxL, l);
    minR = min(minR, r);
  }
  ll ans = max(0LL, minR - maxL + 1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int r, g, b;
    cin >> r >> g >> b;

    if ((r * 100 + g * 10 + b) % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a=[]
ans=1
for _ in range(n):
  a.append(int(input()))
 
a = sorted(a, reverse=True)
 
for i in range(n-1):
  if a[i]<a[i+1]:
    break
  elif a[i]==a[i+1]:
    continue
  else:
    ans+=1
 
print(ans) 

Measured memory_bytes: 3060
import sys
import re
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))

ans = []
while 1:
	s1 = input()
	if s1 == ".":
		break
	s2 = input()

	if s1 == s2:
		ans.append("IDENTICAL")
	else:
		if s1.count('"') != s2.count('"'):
			ans.append("DIFFERENT")

		else:
			s1 = s1.split('"')
			s2 = s2.split('"')
			cnt = 0
			for i in range(min(len(s1), len(s2))):
				if i % 2 == 0 and s1[i] != s2[i]:
					ans.append("DIFFERENT")
					break
				elif i % 2 == 1 and s1[i] != s2[i]:
					cnt += 1
					if cnt >= 2:
						ans.append("DIFFERENT")
						break
			else:
				ans.append("CLOSE")
for i in ans:
	print(i)



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(N); REP(i, N) cin >> A[i];
    double B = 1 / ((double)M * 4.0);
    int C = accumulate(all(A), 0);
    int cnt = 0;
    double D = C * B;
    REP(i, N) {
        if(A[i] >= D) cnt++;
    }
    if(cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    ll K, A, B;
    cin >> K >> A >> B;
    ll res = K + 1;
    if (B > A + 1)
    {
        if (K >= A + 1)
        {
            ll tmp = A + (K - A + 1) / 2 * (B - A);
            if ((K - A + 1) % 2)
                tmp++;
            res = max(res, tmp);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256