akhauriyash/Code-Regression huggingface dataset:
package main

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

type t struct {
	X int
	H int
}
type byX []t

func (a byX) Len() int           { return len(a) }
func (a byX) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a byX) Less(i, j int) bool { return a[i].X < a[j].X }

func main() {
	N := readInt()
	D := readInt()
	A := readInt()
	XH := make([]t, N)
	for i := 0; i < N; i++ {
		XH[i].X = readInt()
		XH[i].H = (readInt() + A - 1) / A
	}

	sort.Sort(byX(XH))
	result := 0
	cs := make([]int, N+1)
	for i := 0; i < N; i++ {
		x, h := XH[i].X, XH[i].H
		if i != 0 {
			cs[i] += cs[i-1]
		}
		h -= cs[i]
		if h < 0 {
			continue
		}
		result += h
		cs[i] += h

		ok := i
		ng := N
		for ng-ok != 1 {
			m := ok + (ng-ok)/2
			if XH[m].X <= x+2*D {
				ok = m
			} else {
				ng = m
			}
		}
		cs[ng] -= h
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


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

#define ll long long

int main() {
	long long n, m = 0, p = 0;
	cin >> n;
	vector<ll> v(n);
	vector<pair<ll, ll>> ans(n-1);
	for(int i = 0; i < n; i++){
		cin >> v[i];
		if(v[i] > 0){
			p++;
		}else{
			m++;
		}
	}
	sort(v.begin(), v.end());
	
	int i = 0;
	while(i < n - 1){
		if(m > 1){
			if(p >= 1){
				//cout << v[v.size() - 1] << " " << v[0] << endl;
				ans[i].first = v[v.size() - 1];
				ans[i].second = v[0];
				v[v.size() - 1] -= v[0];
				v.erase(v.begin());
				m--;
			}else if(p == 0){
				//cout << v[v.size() - 1] << " " << v[0] << endl;
				ans[i].first = v[v.size() - 1];
				ans[i].second = v[0];
				v[v.size() - 1] -= v[0];
				if(v[v.size() - 1] > 0){
					p++;
					m -= 2;
				}else{
					m --;
				}
				v.erase(v.begin());
			}
		}else if(m == 1){
			if(p > 1){
				//cout << v[0] << " " << v[1] << endl;
				ans[i].first = v[0];
				ans[i].second = v[1];
				v[0] -= v[1];
				v.erase(v.begin() + 1);
				p--;
			}else if(p == 1){
				//cout << v[v.size() - 1] << " " << v[0] << endl;
				ans[i].first = v[v.size() - 1];
				ans[i].second = v[0];
				v[v.size() - 1] -= v[0];
				if(v[v.size() - 1] > 0){
					p++;
					m -= 2;
				}else{
					m --;
				}
				v.erase(v.begin());
			}
		}else if(m == 0){
			//cout << v[0] << " " << v[1] << endl;
			ans[i].first = v[0];
			ans[i].second = v[1];
			v[0] -= v[1];
			v.erase(v.begin() + 1);
			p -= 2;
			m++;
		}
		i++;
	}
	
	cout << v[0] << endl;
	for(i = 0; i < n - 1; i++){
		cout << ans[i].first << " " << ans[i].second << endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 4224
n = int(input())

# タプル(時刻, x, y)のリストを生成する
data_list = [(0, 0, 0)]
for _ in range(n):
  temp = list(map(int, input().strip().split()))
  data_list.append((temp[0], temp[1], temp[2]))

# リストの行間において、移動が可能かを判定し、できなければそこで終了する
for i in range(n):
  time_diff = data_list[i + 1][0] - data_list[i][0]
  x_diff = abs(data_list[i + 1][1] - data_list[i][1])
  y_diff = abs(data_list[i + 1][2] - data_list[i][2])
  
  if ((x_diff + y_diff) % 2) != (time_diff % 2):
    print('No')
    exit()
  if x_diff + y_diff > time_diff:
    print('No')
    exit()

print('Yes')

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

using namespace std;

#define ll long long


int main() {
	int n;
	int i;
	cin >> n;

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

	sort(a.begin(), a.end());

	for (i = 0; i < a.size(); i++) {
		if (a[i] == a[i + 1])n--;
	}

	cout << n;
	return 0;

}

Measured memory_bytes: 9572
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

int a[100000 + 1];
int s[100000 + 1];

int main() {

	int n, k;
	int i, j, l;
	int sum = 0, asus = 0;

	while (true) {

		memset(s, 0, sizeof(s));
		memset(a, 0, sizeof(a));

		cin >> n >> k;
		if (n == 0 && k == 0) return 0;

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

		for (i = 0; i < n-k; ++i) {
			for (j = 0; j < k; ++j) {

				sum += a[i + j];
			}
			asus = max(asus, sum);
			sum = 0;
		}

		cout << asus << endl;
	}
}


Measured memory_bytes: 3812
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    /**
     * ??\?????????????????? / ????????????????????????
     */
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line = br.readLine();
        //??????????????¢?????§??????StringBuffer??????????????????
        StringBuffer sb = new StringBuffer(line);
        String answer = sb.reverse().toString();
        
        System.out.println(answer);
    }
}

Measured memory_bytes: 24148
MOD = 1000000007
def inv(x, mod=MOD):
    return pow(x, mod-2, mod)
n = int(input())
c = list(map(int, input().split()))

c.sort()

ans = 0

for i, x in enumerate(c, 1):
    mem = x
    mem = mem * pow(2, n-1, MOD) % MOD
    mem = mem * inv(pow(2, n, MOD) - 1) % MOD
    mem = mem * (1 + (n - i) * inv(2)) % MOD
    ans += mem
    ans %= MOD

ans = ans * (pow(2, n) - 1) % MOD
ans = ans * pow(2, n) % MOD
print(ans)


Measured memory_bytes: 87500
import math
import sys
from operator import itemgetter

# N, K = map(int, input().split())
# h = list(map(int, input().split()))
# S = [input() for _ in range(H)]
# X = [[0 for j in range(100)] for i in range(200)]


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

## solve
sum = 0
for i in L:
	sum += i
	
ans = "Yes"
if (max(L) >= sum - max(L)):
	print("No")
else:
	print("Yes")


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

typedef long long ll;

int main(){
	ll N;
	cin >> N;
	if(N == 1){
		cout << "Hello World" << endl;
	}
	else if(N == 2){
		ll A, B;
		cin >> A >> B;
		cout << A+B << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 256
alph="abcdefghijklmnopqrstuvwxyz"
s=input()
sb=s
n=len(s)
nb=n
ch=set(list(s))
mi=1000
for cha in ch:
  s=sb
  n=nb
  coun=0
  while(1):
    x=set(list(s))
    if(len(x)==1):break
    t=""
    for i in range(n-1):
      if(s[i]==cha):
        t+=s[i]
      elif(s[i+1]==cha):
        t+=s[i+1]
      else:
        t+=s[i]
    n-=1
    s=t
    coun+=1
  mi=min(coun,mi)
print(mi)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b; cin>>a>>b;
	cout<<b*2-a<<endl;
	
	return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#include <numeric>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i, n) for(int i = 1; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	int n, a; cin >> n;
	vector<int> A(n, 0);
	REP1(i, n) {
		cin >> a;
		A[a - 1]++;
	}
	REP(i, n) {
		cout << A[i] << endl;
	}
}


Measured memory_bytes: 3996
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;

const int Maxn = 10000;
int n;

int main ()
{
	scanf("%d",&n);
	if (n/100 == n%10)
		printf("Yes\n");
		else printf("No\n");



	return 0;
	}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
int x[maxn], y[maxn];
ll n, m;

ll uparent[maxn], usize[maxn];
ll result[maxn];

int ufind(int x) {
    while(x != uparent[x]) {
        x = uparent[x];
    }
    return x;
}

ll unite(int x, int y) {
    x = ufind(x);
    y = ufind(y);

    if(x == y) return 0LL;
    else {
        // pomalo na pogolemo
        if(usize[x] < usize[y]) {
            uparent[x] = y;
            ll a = usize[x];
            ll b = usize[y];
            usize[y] += usize[x];
            return 1LL * a * b;
        }
        else {
            uparent[y] = x;
            ll a = usize[x];
            ll b = usize[y];
            usize[x] += usize[y];
            return 1LL * a * b;
        }
    }
}

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

    for(int i=1;i<=m;i++) {
        cin>>x[i]>>y[i];
    }

    for(int i=1;i<=n;i++) {
        uparent[i] = i;
        usize[i] = 1LL;
    }

    result[m] = (1LL * n*(1LL * n-1))/2;
    for(int i=m;i>=1;i--) {
        result[i-1] = result[i] - unite(x[i], y[i]);
    }

    for(int i=1;i<=m;i++) {
        cout<<result[i]<<"\n";
    }

    return 0;
}

Measured memory_bytes: 4480
#include<iostream>
#include<cstdio>

using namespace std;

int main() {
  long long ans;
  long long t = 0, a = 0;
  int N, T, A;

  cin >> N;
  
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &T, &A);
    if (i == 0) {
      t = T;
      a = A;
    } else {
      long double n = max((long double)t / T, (long double)a / A);
      n = n > (long long)n ? (long long)n + 1 : (long long)n;
      long long dT = T * n, dA = A * n;
      /*while (t > dT || a > dA) {
        n++;
        dT = T * n;
        dA = A * n;
      }*/
      t = dT;
      a = dA;
      //cout << t << " " << a << endl;
    }
  }

  ans = t + a;

  cout << ans << endl;



  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct p{
    int l;
    int r;
}a[1000000];
bool cmp(p xx,p yy){
    return xx.l>yy.l;
}
int c,n,h,sum;
int main(){
    scanf("%d%d",&n,&h);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[c++].l);
        a[c].r=1;
        scanf("%d",&a[c++].l);
    }
    sort(a,a+c,cmp);
    for(int i=0;i<c;i++){
        if(a[i].r==1){
            sum++;
            h-=a[i].l;
            if(h<=0){
                printf("%d",sum);
                return 0;
            }
        }
        else
			if(a[i].r!=1){
        	    if(h%a[i].l==0)
					sum+=h/a[i].l;
        	    else
					sum+=h/a[i].l+1;
           	 	printf("%d",sum);
            	return 0;
        	}
    }
}

Measured memory_bytes: 1792
# include <iostream>
# include <map>
# include <algorithm>
# include <cctype>
using namespace std;

int main() {
    string s; getline(cin, s, '\0');
    transform(s.begin(), s.end(), s.begin(), ::tolower); // convert lowercase
    map<char, int> m_cnt;
    
    for (auto itr : s) ++m_cnt[itr];
    
    for (int i = 0; i < 26; ++i) {
        printf("%c : %d\n", 'a' + i, m_cnt['a' + i]);
    }
    
    return 0;
}


Measured memory_bytes: 3268
import java.math.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String o = sc.nextLine();
        String e = sc.nextLine();
        String ans = "";
        for (int i = 0; i < o.length(); i++) {
            ans += o.charAt(i);
            if (o.length() != e.length() && o.length() - i == 1)
                break;
            ans += e.charAt(i);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;

signed main() {
	string SA, SB, SC;
	cin >> SA >> SB >> SC;
	char turn = 'a';
	int a = 1, b = 0, c = 0;
	char ans;
	while (1) {
		if (turn == 'a') {
			if (a == SA.size()) {
				ans = 'A';
				break;
			}
			turn = SA[a];
			a++;
		}
		else if (turn == 'b') {
			if (b == SB.size()) {
				ans = 'B';
				break;
			}
			turn = SB[b];
			b++;
		}
		else {
			if (c == SC.size()) {
				ans = 'C';
				break;
			}
			turn = SC[c];
			c++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-

def main():
  while True:
    n = input()
    if not n: break

    w = 0
    a = [0, 0]
    ans = 0
    for s in raw_input().split():
      f = 0 if s[0] == "l" else 1
      u = 0 if s[1] == "d" else 1
      a[f] = u
      if w == 0 and a[0] == 1 and a[1] == 1:
        w = 1
        ans += 1
      elif w == 1 and a[0] == 0 and a[1] == 0:
        w = 0
        ans += 1

    print ans

  return 0

## -------------------------------------------
## TEMPLATE

from sys import stdin
from sys import setrecursionlimit
from copy import deepcopy
from math import sqrt
from itertools import permutations
from itertools import combinations

def getline():
  return stdin.readline()

def getLineAs(tp):
  return map(tp, getline().split())

def array(n, init = 0):
  return [deepcopy(init) for i in range(n)]

if __name__ == "__main__":
  setrecursionlimit(1024 * 1024)
  main()

Measured memory_bytes: 4492
#include<iostream>
using namespace std;
#define M 500000

struct Node{
  int key;
  Node *p,*l,*r;
};

Node *root,*NIL;

void insert(int k){
  Node *b=NIL;
  Node *a=root;
  Node *c;

  c=(Node *)malloc(sizeof(Node));
  c->key=k;
  c->l=NIL;
  c->r=NIL;

  while(a!=NIL){
    b=a;
    if(c->key < a->key){
      a=a->l;
    }else{
      a=a->r;
    }
  }
  c->p=b;
  if(b==NIL){
    root=c;
  }else{
    if(c->key < b->key){
      b->l=c;;
    }else{
      b->r=c;;
    }
  }
}
  
void In(Node *x){
  if(x==NIL)return;
  In(x->l);
  cout<<" "<<x->key;
  In(x->r);
}

void Pre(Node *x){
  if(x==NIL)return;
  cout<<" "<<x->key;
  Pre(x->l);
  Pre(x->r);
}

Node *serch(Node *x,int k){
  while(x!=NIL && k!=x->key){
    if(k<x->key)x=x->l;
    else x=x->r;
  }
  return x;
}

int main(){
  int m,x,i;
  string order;

  cin>>m;
  for(i=0;i<m;i++){
    cin>>order;
    if(order== "find"){
      cin>>x;
      Node *t=serch(root,x);
      if(t!=NIL)cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }else
      if(order== "insert"){
	cin>>x;
	insert(x);
      }else
	if(order=="print"){
	  In(root);
	  cout<<endl;
	  Pre(root);
	  cout<<endl;
	}
  }
  return 0;
}



Measured memory_bytes: 21824
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
    long long a, b, n;
    cin >> a >> b >> n;
    long long x = min(b-1, n);
    long long ans = (a*x)/b;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		Console.WriteLine("{0}",Max(s[2]-(s[0]-s[1]),0));
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 13268
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(1){
    if(x->right==NIL)break;
    x=x->left;
  }
    return x;
}

Node treeMaximum(Node x){
  while(1){
    if(x->right==NIL)break;
    x=x->right;
  }
    return x;
}

Node treeSearch(Node u, int k){
  while(u!=NIL && k!=u->key){
    if(k< u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)
    return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL)y=z;
  else y=treeSuccessor(z);
  if(y->left!=NIL)x=y->left;
  else x=y->right;
  if(x!=NIL) x->parent=y->parent;
  if(y->parent==NIL){
    root=x;
  }
  else{
    if(y==y->parent->left)
      y->parent->left=x;
    else y->parent->right=x;
  }
  if(y!=z){
    z->key=y->key;
  }
}

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(1){
    if(x==NIL)break;
    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){
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
  }
}

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

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25136
#include<stdio.h>
int main(){
  int a,b,ans=1, tmp=0;
  while(scanf("%d %d",&a,&b)!=EOF){
    tmp = a + b;
    while(tmp > 9){
      tmp = tmp / 10;
      ans++;
    }
    printf("%d\n",ans);
    ans=1;
    tmp=0;
  }
  return 0;
}

      
      

Measured memory_bytes: 600
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#include <unordered_map>

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

const double EPS = 1e-12;

struct BIT{
    int n;
    VL bit;

    BIT(){}
    BIT(int x){
        n = x;
        bit.resize(x+1);
    }

    void init(int x){
        n = x;
        bit.resize(x+1);
    }

    void add(int i, ll x){
        i++;
        while (i <= n){
            bit[i] += x;
            i += i & -i;
        }
    }

    // [0, i]
    ll sum(int i){
        i++;
        ll ret = 0;
        while (i > 0){
            ret += bit[i];
            i -= i & -i;
        }
        return ret;
    }

    // [l, r)
    ll sum(int l, int r){
        if (l >= r) return 0;
        return sum(r-1) - sum(l-1);
    }
};

VI compress_coordinate(vector<double> x){
    int n = x.size();
    vector<pair<double, int> > p(n);
    REP(i,n){
        p[i].first = x[i];
        p[i].second = i;
    }
    sort(ALL(p));
    VI ret(n);
    REP(i,n){
        ret[p[i].second] = i;
    }
    return ret;
}

double calc(VD a, VD b, VD c, ll k){
    int n = a.size();
    vector<pair<double, double> > line(n);
    REP(i,n){
        line[i].first =  - a[i] / b[i];
        line[i].second = c[i] / b[i];
    }
    sort(ALL(line));

    double le = -1e9, ri = 1e9;
    REP(_,100){
        double mi = (le + ri) / 2.0;
        VD c(n);
        REP(i,n) c[i] = line[i].second + line[i].first * mi;
        VI p = compress_coordinate(c);
        BIT bit(n);
        ll tmp = 0;
        REP(i,n){
            tmp += bit.sum(p[i]);
            bit.add(p[i],1);
        }
        if (tmp >= k) ri = mi;
        else le = mi;
    }
    return le;
}

int main() {
    int n;
    cin >> n;
    vector<double> a(n), b(n), c(n);
    REP(i,n) cin >> a[i] >> b[i] >> c[i];

    ll k = ((n * (n-1) / 2) + 1) / 2;

    double ansx = calc(a, b, c, k);

    REP(i,n) a[i] *= -1.0;
    double ansy = calc(b, a, c, k);

    printf("%.14f %.14f\n", ansx, ansy);

    return 0;
}





Measured memory_bytes: 4244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        ll tmp_a = 0;
        cin >> tmp_a;
        a[i] = tmp_a - ( i + 1 );
    }
    sort(a.begin(), a.end());
    ll b = 0;
    if ( n & 1 ) {
        b = a[n/2];
        ll ans = 0;
        for ( ll i = 0; i < n; i++ ) {
            ans += abs(a[i] - b);
        }
        cout << ans << endl;
        return 0;
    }
    else {
        ll b1 = a[n/2];
        ll b2 = a[n/2-1];
        ll ans1 = 0;
        ll ans2 = 0;
        for ( ll i = 0; i < n; i++ ) {
            ans1 += abs(a[i] - b1);
            ans2 += abs(a[i] - b2);
        }
        cout << min(ans1, ans2) << endl;
        return 0;
    }
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashSet<String> s = new HashSet<String>();
		sc.nextLine();
		while(n-- > 0){
			s.add(sc.nextLine());
		}
		System.out.println(s.size());
	}
}


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

typedef long long ll;

vector <ll> tree;

void update(int p, int n, ll val) {
    for (tree[p += n] = val; p > 1; p >>= 1)
	tree[p >> 1] = max(tree[p], tree[p^1]);
}

ll query(int l, int r, int n) {
    ll res = 0;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
	if (l & 1) res = max(res, tree[l++]);
	if (r & 1) res = max(res, tree[--r]);
    }
    return res;
}

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

    int n;
    cin >> n;

    tree.assign(2*n, 0);
    int h[n];
    ll a[n];

    for (int i = 0; i < n; i++)
	cin >> h[i], h[i]--;
    
    for (int i = 0; i < n; i++)
	cin >> a[i];

    for (int i = 0; i < n; i++) {
	ll mx = query(0, h[i] + 1, n);
	update(h[i], n, mx + a[i]);
    }

    cout << tree[1] << '\n';
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int l, max = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> l;
		if (l > max)max = l;
		sum += l;
	}
	if (sum - max > max) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

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

int can1[200010], can2[200010];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(can1, 0, sizeof can1);
	memset(can2, 0, sizeof can2);
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; ++i){
		int x,y;
		cin >> x >> y;
		int a = min(x, y);
		int b = max(x, y);
		if(a == 1) can1[b] = 1;
		if(b == n) can2[a] = 1;
	}
	if(can1[n] == 1) return cout << "POSSIBLE" << endl, 0;
	for(int i = 1; i < n; ++i) {
		if(can1[i] and can2[i]) return cout << "POSSIBLE" << endl, 0;
	}
	cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 1792
function main(input){
  input = input.split(' ').map(parseFloat);
  var total = 1;
  var result = 0;
  
  for(var i = 0;total < input[1];i++){
    total += input[0] - 1;
    result++;
  }
  console.log(result);
}
main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

//const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n;
  std::cin>>n;

  std::vector<std::vector<ll>> graph(n);
  rep(i,0,n-1){
    ll a,b;
    std::cin>>a>>b;
    a--;b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  std::vector<long double> dp(n);

  auto dfs1=[&](auto f,ll now,ll par)->void{
    dp[now]=0;
    ll cnt=0;
    for(auto e:graph[now]){
      if(e==par)continue;
      cnt++;
      f(f,e,now);
      dp[now]+=(dp[e]+1);
    }

    if(cnt!=0)dp[now]/=cnt;
  };

  dfs1(dfs1,0,-1);

  std::vector<long double> ans(n);

  auto dfs2=[&](auto f,ll now,ll par,long double d)->void{
    ans[now]=d+1;
    for(auto e:graph[now]){
      if(e==par)continue;
      ans[now]+=(dp[e]+1);
    }

    for(auto e:graph[now]){
      if(e==par)continue;
      long double val=ans[now];
      val-=(dp[e]+1);
      if(val)val/=(graph[now].size()-1);
      f(f,e,now,val);
    }
    ans[now]/=graph[now].size();
  };

  dfs2(dfs2,0,-1,-1);

  std::cout<<std::setprecision(10)<<std::fixed;
  rep(i,0,n){
    std::cout<<ans[i]<<"\n";
  }

  return 0;
}


Measured memory_bytes: 21376
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    ll sum = 0LL;
    vll a(n); for(auto& e : a) cin >> e, sum += e;

    sort(_all(a));
    sum -= a[n - 1];
    int res = n;
    rrep(i, n - 1){
        if(a[i + 1] > sum * 2){
            res = n - i - 1;
            break;
        }
        sum -= a[i];
    }

    cout << res << endl;

    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 2 == 0 || b % 2 == 0) {
  	cout << "Even" << endl;
  }
  else {
  	cout << "Odd" << endl;
  }
}


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

using namespace std;

int dp[300000] = {0};//0:未定 1:素数である 2:素数でない


bool isSosu(int n){
  bool res = true;
  if(dp[n] == 1){
    res = true;
  }else if(dp[n] == 2){
    res = false;
  }else {
    if(n%2==0 && n!=2){
      res = false;
    }else{
      for(int i=2;i<=sqrt(n);i++){
	if(n%i==0){
	  res = false;
	  break;
	}
      }
    }

    dp[n] = res;
  }

  return res;
}

int solv(int f,int t){
  int res = 0;
  for(int i=f+1;i<=t;i++){
    if(isSosu(i))
      res++;
  }

  return res;
}

int main(){
  int n;
  cin>>n;
  while(n!=0){
    cout<<solv(n,n*2)<<endl;

    cin>>n;
  }

  return 0;

}

Measured memory_bytes: 2124
#include<cstdio>
#include<string>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<vector>
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)

using namespace std;
long long n,m;
long long hai[100006];
long long p[100005];
long long ans;
long long a,b,c;
int main()
{
	cin>>n;
	cin>>m;
	rep(i,m){cin>>p[i];p[i]--;}
	rep(i,m-1)
	{
		hai[min(p[i],p[i+1])]++;
		hai[max(p[i],p[i+1])]--;
	}
	rep2(i,1,n-1)hai[i]+=hai[i-1];
	rep(i,n-1)
	{
		cin>>a>>b>>c;
		ans+=min(a*hai[i],b*hai[i]+c);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2720
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define vint vector<int>


int main(){
	int a,n;
	cin >> n >> a;
	cout << n*n-a << endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 3540
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        FastScanner sc = new FastScanner();

        int n = sc.nextInt();
        int[] a = new int[n];
        int[] array = new int[n];
        int add = 0;
        double ave = 0;

        for(int i = 0;i < n;i++){

            a[i] = sc.nextInt();
            array[i] = a[i];

            add += a[i];

        }


        ave = (double)add / n;
        int index = 0;
        double sub=100;
//        System.out.println(ave);
        for(int i = 0;i < n;i++){
            if(Math.abs(ave - a[i]) < sub){
                index = i;
                sub = Math.abs(ave - a[i]);
            }
        }

        System.out.println(index);






    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int n,m,ans;
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m);
	for (int i=1;i<=n;i++)
	for (int j=10;j<=m;j++)
		if ((j%10)>=2&&(j/10)>=2&&(j%10)*(j/10)==i) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
  long long a,b,c,d;
  cin >> a >> b >> c >> d;
  long long max = -1e18;
  if(max < a * c) max = a * c;
  if(max < a * d) max = a * d;
  if(max < b * c) max = b * c;
  if(max < b * d) max = b * d;
  cout << max << endl;

}

Measured memory_bytes: 3632
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K, C = map(int, input().split())
S = input()

l = []
r = []
i = 0
while i < N:
    if S[i] == 'o':
        l.append(i + 1)
        i += C + 1
        if len(l) >= K:
            break
    else:
        i += 1

S = "".join(reversed(S))
i = 0
while i < N:
    if S[i] == 'o':
        r.append(N - i)
        i += C + 1
        if len(r) >= K:
            break
    else:
        i += 1

r = list(reversed(r))
# print(l)
# print(r)
for i in range(K):
    if l[i] == r[i]:
        print(l[i])





    

Measured memory_bytes: 26908
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll int
#define N 2005
#define rep(i,j,k) for (ll i=j;i<=k;++i)
#define per(i,j,k) for (ll i=j;i>=k;--i)
using namespace std;
inline ll read(){
	char ch=getchar(); ll x=0,f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}
ll n,k,num,ans=1<<30,tot,head[N];
struct edge{ ll from,to,next; }e[N<<1];
void add(ll u,ll v){
	e[++tot]=(edge){u,v,head[u]}; head[u]=tot;
}
void dfs(ll u,ll fa,ll deep){
	if (deep>k/2) return; ++num;
	for (ll i=head[u],v=e[i].to;i;i=e[i].next,v=e[i].to){
		if (v==fa) continue; dfs(v,u,deep+1);
	}
}
void work1(ll x){
	num=0; dfs(x,-1,0);
	ans=min(ans,n-num);
}
void work2(ll x){
	num=0;
	dfs(e[x].from,e[x].to,0);
	dfs(e[x].to,e[x].from,0);
	ans=min(ans,n-num);
}
int main(){
	n=read(); k=read();
	rep(i,2,n){
		ll u=read(),v=read();
		add(u,v); add(v,u);
	}
	if (!(k&1)){
		rep(i,1,n) work1(i);
		return printf("%d",ans)&0;
	}else{
		rep(i,1,n-1) work2(i*2-1);
		return printf("%d",ans)&0;
	}
}

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

int main(){

int M,N,sum;
sum=0;
cin >> N>>M;
for(int i=0;i<M;i++){
    int A;
    cin>>A;
    sum+=A;
}
int ans =N-sum;
if(ans<0){
    cout <<-1<<endl;
}
else{
    cout <<ans<<endl;

}
}

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

vector<int>adj[200005];
bool vis[200005];

int dfs(int u)
{ int ans=0;
  if(!vis[u])
{  ans++;
    vis[u]=true;
    for(auto i:adj[u])
    { ans+=dfs(i);
    }
}
 return ans;
}

int main()
  
{memset(vis,false,sizeof(vis));
 
  int n,m;
  cin>>n>>m;
  while(m--)
  { int a,b;
   cin>>a>>b;
   adj[a].push_back(b);
   adj[b].push_back(a);
  }
 int maxi=0;
 
 for(int i=1;i<=n;i++)
 { if(!vis[i])
 { maxi=max(maxi,dfs(i));
 }
 }
 cout<<maxi;

}

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

int main()
{
    int n,a; cin>>n;
    vector<int> x,y,z;
    for(int i=0; i<n; i++)
    {
        cin>>a;
        y.push_back(a);
        x.push_back(i+1);
    }
    for(int i=0; i<n; i++)
    {
        cin>>a;
        z.push_back(a);
    }
    int c=0,d=0,count=1;
    do
    {
        int t=0;
        for(int i=0; i<n; i++)
            if(x[i]==y[i]) t++;
        if(t==n) c=count;
        t=0;
        for(int i=0; i<n; i++)
            if(x[i]==z[i]) t++;
        if(t==n) d=count;
        count++;
    } while(next_permutation(x.begin(),x.end()));
    cout<<abs(c-d)<<endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List

f :: Int -> Int -> Int
f l r
    | l < 0 && r < 0 = -l
    | l > 0 && r > 0 = r
    | otherwise = r - l + min r (-l)

main = do
    [n, k]  <- map read . words <$> getLine
    xs <- map read . words <$> getLine
    let l = take (n - k + 1) xs
    let r = drop (k - 1) xs
    print $ foldl min maxBound $ zipWith f l r


Measured memory_bytes: 70140
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	h, w, k := scanInt(), scanInt(), scanInt()
	x1, y1, x2, y2 := scanInt()-1, scanInt()-1, scanInt()-1, scanInt()-1
	c := make([]string, h)
	ans := make([][]int, h)
	for i := 0; i < h; i++ {
		c[i] = scanString()
		ans[i] = make([]int, w)
		for j := 0; j < w; j++ {
			ans[i][j] = -1
		}
	}

	q := []p{p{x1, y1, 0}}
	ans[x1][y1] = 0
	dx, dy := []int{-1, 0, 1, 0}, []int{0, -1, 0, 1}
	for len(q) != 0 {
		ne := q[0]
		q = q[1:]

		for i := 0; i < 4; i++ {
			nx, ny := ne.x, ne.y
			for j := 0; j < k; j++ {
				nx += dx[i]
				ny += dy[i]
				if nx < 0 || ny < 0 || nx >= h || ny >= w || c[nx][ny] == '@' || ans[nx][ny] != -1 && ans[nx][ny] != ne.c+1 {
					break
				}

				if ans[nx][ny] == -1 {
					ans[nx][ny] = ne.c + 1
					q = append(q, p{nx, ny, ne.c + 1})
				}
			}
		}
	}

	fmt.Fprintln(wr, ans[x2][y2])

}

type p struct {
	x, y, c int
}


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

int main(){
    int N;
    cin>>N;
    int arr[N+1];
    for (int i = 1; i <= N; ++i) {
        cin>>arr[i];
    }
    int cost[N];
    cost[1] = 0;
    cost[2] = abs(arr[2] - arr[1]);
    if(N==2){
        cout<<cost[2]<<endl;
    }
    else{
        for (int i = 3; i <= N; ++i) {
            cost[i] = min(cost[i-2] + abs(arr[i] - arr[i-2]), cost[i-1] + abs(arr[i-1] - arr[i]));
        }
        cout<<cost[N]<<endl;
    }
}

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

using namespace std;

int main()
{
    int N;

    cin >> N;

    string ANS = "";

    string S = std::to_string(N);

    int size = S.length();

    string b = "";

    if (size == 1)
    {
        b = S;
    }
    else if (size == 2)
    {
        b = S.substr(1);
    }
    else
    {
        b = S.substr(2);
    }

    if (b == "2" || b == "4" || b == "5" || b == "7" || b == "9")
    {
        ANS = "hon";
    }
    else if (b == "0" || b == "1" || b == "6" || b == "8")
    {
        ANS = "pon";
    }
    else
    {
        ANS = "bon";
    }

    cout << ANS << endl;
}

Measured memory_bytes: 3700
N,M,C= map(int,input().split())
B = list(map(int,input().split()))

A = []
for it in range(N):
    A.append(list(map(int,input().split())))


# print("==")
# print(N,M,C)
# print(B)
# print(A)

def j(A,B,C):
    ab = 0
    for it in range(M):
        ab += A[it]*B[it]
    ans = ab + C
    # print(ans)
    if ans > 0:
        return True

    else:
        return False

count = 0
for it in range(N):
    if j(A[it],B,C):
        count += 1

print(count)


Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
  int A,B,K,count=0,i; scanf("%d%d%d",&A,&B,&K);
  for(i=(A>=B)?A:B;i>0;i--){
    if(A%i==0&&B%i==0){
      count++;
      if(count>=K){
        break;
      }
    }
  }
  printf("%d\n",i);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N; cin >> N;
	int A[200010];
	for(int i = 1; i < N * 2; i++) cin >> A[i];
	int B[200010];
	int ok = 1; int ng = N * 2 - 1;
	while(ng - ok > 1){
		int top = 0;
		int mid = (ng + ok) / 2;
		for(int i = 1; i < N * 2; i++){		
			if(A[i] >= mid) B[i] = 1;
			else B[i] = 0;
		}
		int L = 1; int R = N * 2 - 1;
		if(B[N] == B[N + 1] || B[N] == B[N - 1]){
			top = B[N];
			if(top) ok = mid;
			else ng = mid;
			continue;
		}
		for(int i = N; i < N * 2 - 1; i++){
			if(B[i] == B[i + 1]){
				R = i; break;
			}
		}
		for(int i = N; i > 1; i--){
			if(B[i] == B[i - 1]){
				L = i; break;
			}
		}
		if(L == 1 && R == N * 2 - 1) top = B[1]; 
		else if(L % 2 == R % 2){
			top = B[L];
		}else if(L + R < N * 2){
			top = B[R];
		}else{
			top = B[L];
		}
		if(top) ok = mid;
		else ng = mid;
	}
	cout << ok << "\n";
}

Measured memory_bytes: 5180
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let a: usize = itr.next().unwrap().parse().unwrap();
    let b: usize = itr.next().unwrap().parse().unwrap();
    let h = 100;
    let w = 100;

    let mut g: Vec<char> = vec!['.'; h * w];
    for i in 0..50 {
        for j in 0..100 {
            g[i * w + j] = '#';
        }
    }

    let mut y = 1;
    let mut x = 1;
    let mut cnt = 1;
    while cnt < a {
        g[y * w + x] = '.';
        x += 2;
        if x >= 100 {
            x = 1;
            y += 2;
        }
        cnt += 1;
    }
    y = 51;
    x = 1;
    cnt = 1;
    while cnt < b {
        g[y * w + x] = '#';
        x += 2;
        if x >= 100 {
            x = 1;
            y += 2;
        }
        cnt += 1;
    }

    let mut out = Vec::new();
    writeln!(out, "{} {}", h, w).ok();
    for i in 0..h {
        for j in 0..w {
            write!(out, "{}", g[i * w + j]).ok();
        }
        writeln!(out, "").ok();
    }
    stdout().write_all(&out).unwrap();
}


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

int main()
{
    int n;
    cin>>n;
    
    string s;
    cin>>s;
    
    vector<int> r,g,b;
    
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='R')
        {
            r.push_back(i);
        }
        else if(s[i]=='G')
        {
            g.push_back(i);
        }
        else
        {
            b.push_back(i);
        }
    }
    
    long long int ans=0;

    for(int i=0;i<r.size();i++)
    {
        for(int j=0;j<b.size();j++)
        {
            int flag=0;
            int t=max(r[i],b[j]);
            int tt=min(r[i],b[j]);
            
            if((t-tt)%2==0)
            {
                int temp=(t+tt)/2;
                if(s[temp]=='G')
                {
                    flag++;
                }
            }
            if((2*tt)-t>=0)
            {
                if(s[(2*tt)-t]=='G')
                {
                    flag++;
                }
            }
            if((2*t)-tt<n)
            {
                if(s[(2*t)-tt]=='G')
                {
                    flag++;
                }
            }
            
            ans+=g.size()-flag;
        }
    }
    
    cout<<ans;
}

Measured memory_bytes: 3672
#include <algorithm>
#include <array>
#include <iostream>
#include <string>
#include <vector>

int main() {
  using namespace std;
  long long n;
  long long sum = 0;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      sum += i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3624
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream>

using namespace std;

int A, B, C, X;

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

    cin >> A >> B >> C >> X;

    X /= 50;

    int ans = 0;
    for (int a = 0; a <= A; a++) {
        for (int b = 0; b <= B; b++) {
            for (int c = 0; c <= C; c++) {
                if (10 * a + 2 * b + c == X) {
                    ans++;
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int n, A[50];

int solve (int i, int m) {
	if (m == 0) return 1;
	if (i >= n) return 0;
	int res = solve(i+1, m) || solve(i+1,m - A[i]);
	return res;
}

int main(){
	int q, M, i;

	scanf("%d", &n);
	for (i = 0; i<n;i++) scanf("%d", &A[i]);
	scanf("%d", &q);
	for (i = 0; i<q;i++) {
		scanf("%d", &M);
		if ( solve(0,M) )printf("yes\n");
		else printf("no\n");
	}
	return 0;
}



Measured memory_bytes: 3140