akhauriyash/Code-Regression huggingface dataset:
N,C =map(int,input().split())
chan=[[] for i in range(C)]
for i in range(N):
    a,b,c=map(int,input().split())
    chan[c-1].append([a,b])
for i in range(C):
    chan[i].sort()
imos=[0]*(10**5+2)
for i in range(C):
    if len(chan[i])==0:
        continue
    imos[chan[i][0][0]]+=1
    imos[chan[i][0][1]+1]-=1
    for k in range(1,len(chan[i])):
        if chan[i][k][0]==chan[i][k-1][1]:
            imos[chan[i][k][0]+1]+=1
            imos[chan[i][k][1]+1]-=1
        else:
            imos[chan[i][k][0]]+=1
            imos[chan[i][k][1]+1]-=1

for i in range(1,10**5+2):
     imos[i] +=imos[i-1]  
print(max(imos))

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define SUM(v) accumulate((v).begin(),(v).end(),0ll)
#define range(i,left,right) (left<=i && i<right)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[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;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int iscount(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int n,k;
    cin>>n>>k;
    Vi a(n);
    REP(i,0,n) cin>>a[i];

    sort(ALL(a),greater<int>());
    if(a[k-1]*4*k>=SUM(a)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  string s, t;
  cin >> s >> t;
  int ssz=s.size(), tsz=t.size();
  int longest=0;
  rep(i, ssz-tsz+1){
    int num=0;
    for(int j=i;j<i+tsz; j++){
      if(s[j]==t[j-i]){
        num++;
      }
    }
    longest=max(longest, num);
  }
  cout << tsz-longest << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a,b,c,i,j,k=0;
    string s;
    cin>>s;
    a=s.size();
    b=(a/2);
    for(i=0;i<b;i++)
    {
        if(s[i]!=s[a-i-1])
        {
            k++;
        }
    }
    cout<<k<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
ll MOD = 1000000007ll;
using namespace std;

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    vector<int> a(n, 0);
    rep(i, n) cin >> a[i];
    map<int, ll> mp, mp2;
    rep(i, n) rep(j, i + 1, n)
    {
        if (a[i] > a[j])
            mp[i]++;

        if (a[j] > a[i])
            mp2[j]++;
    }
    ll ans = 0;
    ll kk = k * (k + 1) / 2;
    ll kk2 = k * (k - 1) / 2;
    kk2 %= MOD;

    kk %= MOD;
    rep(i, n)
    {
        ans += mp[i] * kk;
        ans %= MOD;
        ans += mp2[i] * kk2;
        ans %= MOD;
    }
    cout << ans % MOD << endl;
    return 0;
}


Measured memory_bytes: 512
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
   R = get_input(int)
   print(2 * math.pi * R)




if __name__ == '__main__':
    main()


Measured memory_bytes: 27092
mod = 10**9 + 7

def main():
    H = iip(listed=False)
    N = 1

    ret = 0
    while True:
        ret += N
        if H == 1:
            break
        else:
            H //= 2
            N *= 2
    print(ret)


#####################################################ライブラリ集ここから

def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    while r-l > 1:
        x = (l+r)//2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        return r
    if side == "right":
        return l+1



def iip(listed):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <=0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n-r+1, n+1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r+1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        #print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod-2)

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p//2) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod


if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
class Die
  def initialize(men)
    @t, @s, @e, @w, @n, @b = men
  end

  def top; @t; end
  def front; @s; end
  def right; @e; end

  def move(d)
    case d
    when 'N'
      @t, @s, @b, @n = @s, @b, @n, @t
    when 'W'
      @w, @b, @e, @t = @t, @w, @b, @e
    when 'E'
      @w, @b, @e, @t = @b, @e, @t, @w
    when 'S'
      @t, @s, @b, @n = @n, @t, @s, @b
    end
  end

  def make_top(num)
    3.times do
      move 'N'
      return if @t == num
      move 'E'
      return if @t == num
    end
    raise "#{num} is not found"
  end

  def rotate
    @n, @w, @s, @e = @w, @s, @e, @n
  end

  def rotate_until(num)
    4.times do
      rotate
      return if @s == num
    end
    raise "#{num} is not found"
  end

  def all
    [@t, @s, @e, @w, @n, @b]
  end


  def ==(other)
    cmp = self.all.sort.uniq
    if cmp.size == 6
      self.make_top(other.top)
      self.rotate_until(other.front)
      return self.all == other.all
    else
      3.times do
        move 'N'
        if @t == other.top
          4.times do
            rotate
            if @s == other.front
              return true if self.all == other.all
            end
          end
        end
        move 'E'
        if @t == other.top
          4.times do
            rotate
            if @s == other.front
              return true if self.all == other.all
            end
          end
        end
      end
    end
    false
  rescue
    false
  end
end

dice = []
gets.to_i.times do
  d = Die.new(gets.split)
  if dice.any? {|die| d == die }
    puts 'No'
    exit
  end
  dice << d
end
puts 'Yes'



Measured memory_bytes: 7164
package main

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

func solve() {
	n := getInt()
	as := getIntSlice(n)

	ans := make([]int, n)
	for i, a := range as {
		ans[a-1] = i + 1
	}

	for _, a := range ans {
		fmt.Fprintln(wr, a)
	}
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

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

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 4224
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,M,K=get_i
A=get_i
B=get_i
k=K
accum_a=array(N+1,0)
N.times do|i|
  accum_a[i+1]=accum_a[i]+A[i]
end
accum_b=array(M+1,0)
M.times do|i|
    accum_b[i+1]=accum_b[i]+B[i]
end
ans=0
(N+1).times do|i|
    break if accum_a[i]>=K
    head=-1
    tail=M+1
    k=K-accum_a[i]
    while tail-head>1
        mid=head+(tail-head)/2
        if accum_b[mid]<=k
            head=mid
        else
            tail=mid
        end
    end
    ans=max(ans,i+head)
end
(M+1).times do|i|
    break if accum_b[i]>=K
    head=-1
    tail=N+1
    k=K-accum_b[i]
    while tail-head>1
        mid=head+(tail-head)/2
        if accum_a[mid]<=k
            head=mid
        else
            tail=mid
        end
    end
    ans=max(ans,i+head)
end
puts ans

Measured memory_bytes: 49232
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
//https://www.creativ.xyz/dump-cpp-652/
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
 
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

#ifdef DEBUG_
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif


signed main(void) { cin.tie(0); ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    int r,s, pp; cin>>r>>s>>pp;
    string t; cin>>t;
    int ans = 0;
    rep(i,t.size()){
        if(i + k < t.size()){
            if(t[i] == t[i+k]){
                t[i+k] = '?';
            }
        }
        if(t[i] == 'p') ans += s;
        if(t[i] == 'r') ans += pp;
        if(t[i] == 's') ans += r;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        A: i32,
        B: i32,
    };
    let mut c = 0;
    let mut b = 1;
    while b < B {
        b += A - 1;
        c += 1;
    }
    println!("{}", c);
}


Measured memory_bytes: 2140
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()

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

i=0
while 1:
  if not x-i in p:
    print(x-i)
    exit()
  if not x+i in p:
    print(x+i)
    exit()
  i+=1

Measured memory_bytes: 61684
from heapq import heappop,heappush

def main():
    N,M,S=map(int,input().split())
    G=[[] for _ in range(N)]
    for i in range(M):
        U,V,A,B=map(int,input().split())
        G[U-1].append([V-1,A,B])
        G[V-1].append([U-1,A,B])
    C=[]
    D=[]
    for _ in range(N):
        c,d=map(int,input().split())
        C.append(c)
        D.append(d)

    MaxMoney=2500

    dp=[[float('inf') for __ in range(MaxMoney+1)] for _ in range(N)]

    cost=0
    money=min(S,MaxMoney)
    que=[]
    heappush(que,(cost,0,money)) #cost,node,money
    dp[0][money] = 0

    while len(que)>0:
        cost,node,money=heappop(que)

        stop_money=min(money+C[node],MaxMoney)
        stop_cost=cost+D[node]
        if stop_cost<dp[node][stop_money]:
            dp[node][stop_money]=stop_cost
            heappush(que,(stop_cost,node,stop_money))

        for to_node,to_money,to_cost in G[node]:
            money_=min(money-to_money,MaxMoney)
            if money_<0:
                continue
            cost_=cost+to_cost
            if dp[to_node][money_]<=cost_:
                continue

            dp[to_node][money_]=cost_
            heappush(que,(cost_,to_node,money_))

    for i in range(1,N):
        print(min(dp[i]))




if __name__=="__main__":
    main()

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

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  ll n, m;
  cin >> n >> m;
  if(2 * n >= m)cout << m / 2 << endl;
  else cout << n + (m - 2 * n) / 4 << endl;
	return 0;
}


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


void solve(long long M, std::vector<long long> d, std::vector<long long> c){
    ll sum_digits = 0;
    ll num_digits = 0;
    REP(i, M){
        sum_digits += d.at(i) * c.at(i);
        num_digits += c.at(i);
    }
    cout << sum_digits / 9 - (sum_digits % 9 == 0) + num_digits - 1 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long M;
    scanf("%lld",&M);
    std::vector<long long> d(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&d[i]);
        scanf("%lld",&c[i]);
    }
    solve(M, std::move(d), std::move(c));
    return 0;
}


Measured memory_bytes: 3328
def operator( arg1, arg2, op):
    if op=='+': return arg1+arg2
    elif op=='-': return arg1-arg2
    elif op=='*': return arg1*arg2
    else: return arg1/arg2

    
def main():
    description=list(input().split())
    stack=[]
    for st in description:
        if st.isdigit():
            stack.append(st)

        else:
            op=st
            arg2=int(stack.pop())
            arg1=int(stack.pop())
            ans=operator( arg1, arg2, op)
            stack.append(ans)

    print(stack.pop())

if __name__=='__main__':
    main()
    



Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>



int main() {
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	while (n > 0) {
		ans++;
		n /= k;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
/*
Author: Fuadul Hasan(fuadul202@gmail.com)
BSMRSTU,Gopalganj
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
//#include<bits/stdc++.h>
using namespace std;
 
int         cinn()              {int x; scanf("%d", &x); return x;}
long long   scll()              {long long x; scanf("%lld", &x); return x;}
double      scd()               {double x; scanf("%lf", &x); return x;}
void        coutt(int x)        {printf("%d ", x);}
 
#define  scll                   scll()
#define  gcd(a,b)               __gcd(a,b)
#define  lcm(a,b)               (a*b)/gcd(a,b)
#define  PI                     acos(-1.0)
#define  vi                     std::vector<int>
#define  vll                    std::vector<ll>
#define  vit                    vector<int> :: iterator
#define  sit                    set<int> :: iterator
#define  mpsi                   std::map<string, int>
#define  pb                     push_back
#define  ll                     long long int
#define  ld                     long double
#define  ull                    unsigned long long int
#define  min3(a,b,c)            min(a,min(b,c))
#define  min4(a,b,c,d)          min(d,min(a,min(b,c)))
#define  max3(a,b,c)            max(a,max(b,c))
#define  max4(a,b,c,d)          max(d,max(a,max(b,c)))
#define  nl                     printf("\n");
#define  no                     printf("No");
#define  yes                    printf("Yes");
#define  F                      first
#define  S                      second

typedef pair<int,int> ii;
typedef std::vector<ii> vii;
 
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 1e6 + 5;
const int nn           = 2e5 + 5;


int siv[N];
long long a[200007];

int solve()
{
	int n,a1;
	cin>>n>>a1;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		a[i] = a[i]+a[i-1];
	}
	ll mxx = 0;
	for(ll i=a1;i<=n;i++){
		mxx =  max(mxx,(a[i]-a[i-a1]));
	}
	float x = float((float)(mxx+a1)/2.0);
	printf("%0.12f\n",x );


}

int main()
{
    int test = 1, tc = 0;
    //scanf("%d", &test);
   // (void)getchar();
    //cin >> test;
    while (test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
 
    return 0;
}

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


int main(){
  int N, K;
  cin >> N >> K;
  int ans = 0;
  for(int ii=0; ii<N; ii++){
    int x;
    cin >> x;
    ans += min(x, abs(x-K)) * 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; scanf("%d%d", &n, &m); std::vector<int> h(n);
	for(int i = 0; i < n; i++) scanf("%d", &h[i]);

	std::vector<int> ans(n);
	for(int i = 0; i < m; i++) {
		int a, b; scanf("%d%d", &a, &b);
		a--; b--;

		if(h[a] >= h[b]) ans[b] |= 1;
		if(h[a] <= h[b]) ans[a] |= 1;
	}
	
	printf("%d\n", n - std::accumulate(begin(ans), end(ans), 0));
	return 0;
}


Measured memory_bytes: 4052
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

h,w,d=nii()

a_dict={}
for i in range(h):
  a=lnii()
  for j in range(w):
    a_dict[a[j]]=(i,j)

b_dict={}
for i in range(1,d+1):
  num=i
  cy,cx=a_dict[num]
  b_dict[num]=0
  while num+d<=h*w:
    num+=d
    ny,nx=a_dict[num]
    b_dict[num]=b_dict[num-d]+abs(cy-ny)+abs(cx-nx)
    cy=ny
    cx=nx

q=int(input())
for i in range(q):
  l,r=nii()
  ans=b_dict[r]-b_dict[l]
  print(ans)

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

int main(){
    int n, x, t;
    cin >> n >> x >> t;

    int ans;
    if (n % x == 0){
        ans = int(n/x) * t;
    }else{
        ans = int(n/x+1)*t;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
using namespace std;



int main(){

  int a,b; cin >> a >> b;
  cout << max(a-2*b,0);



  return 0;
}


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

int main()
{
    string str;
    cin>>str;
    size_t fnd=str.find('7');
    if(fnd!=string::npos)
    {
        cout<<"Yes"<<endl;
    }
    else

    {
        cout<<"No"<<endl;
    }
    return 0;
}

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

int main(){
    int64_t a, b, x;
    cin >> a >> b >> x;

    int64_t ans;
    if(a % x == 0){
        ans = b / x - a / x + 1;
    }else{
        ans = b / x - a / x;
    }

    cout << ans << endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T,class U>
istream& operator >> (istream&is, P<T,U>&p){
  is >> p.first >> p.second;
  return is;
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v){
    is >> e;
  }
  return is;
}

int main(){
  int h,w; cin >> h >> w;
  int a[500][500];
  int cnt = 0;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      cin >> a[i][j];
      cnt += a[i][j] %= 2;
    }
  }
  cnt %= 2;
  vector<tuple<int,int,int,int>> v;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w-1; ++j){
      if(a[i][j]){
	v.emplace_back(i,j,i,j+1);
	a[i][j] = 0;
	a[i][j+1] = (a[i][j+1]+1)%2;
      }
    }
  }
  for(int i = 0; i < h-1; ++i){
    if(a[i][w-1] && cnt){
      cnt=0;
    } else if(a[i][w-1]){
      v.emplace_back(i,w-1,i+1,w-1);
      a[i][w-1] = 0;
      a[i+1][w-1] = (a[i+1][w-1]+1)%2;
    }
  }
  cout << v.size() << endl;
  for(auto&e:v){
    cout << get<0>(e)+1 << ' ' << get<1>(e)+1 << ' '
	 << get<2>(e)+1 << ' ' << get<3>(e)+1 << endl;
  }
}



Measured memory_bytes: 6348
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

while True:
    a, op, b = map(str, input().split())

    a = int(a)
    b = int(b)

    if op == "+":
        print(a+b)
    elif op =="-":
        print(a-b)
    elif op =="*":
        print(a*b)
    elif op =="/":
        print(a//b)
    else:
        exit(0)





Measured memory_bytes: 6928
program main
    implicit none
    integer(8) n,k
    integer(8), allocatable, dimension(:) :: a
    integer(8) i
    read(*,*) n,k
    allocate(a(n))
    read(*,*) a

    do i = k+1,n,1
        if(a(i) > a(i-k)) then
            write(*,*) "Yes"
        else
            write(*,*) "No"
        end if
    end do

end program


Measured memory_bytes: 4656
import           Data.Attoparsec.ByteString.Char8
import qualified Data.ByteString.Char8            as B

main :: IO ()
main = do
  Right (x, y) <- parseOnly ((,) <$> decimal <* space <*> decimal) <$> B.getLine
  print $ solve x y

solve :: Int -> Int -> Int
solve 1 1 = 1000000
solve x y = f x + f y
  where
    f 1 = 300000
    f 2 = 200000
    f 3 = 100000
    f _ = 0

Measured memory_bytes: 508
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
int gcd(int x,int y)
{
	if(y==0)return x;
	return gcd(y,x%y);
}
int main()
{
    int a,b;
	while(cin >> a >> b){
		int z=gcd(a,b);
        int w=a/z*b;
		printf("%d %d\n",z,w);
	}
    return 0;
}

Measured memory_bytes: 1144
N = int(input())
s = [int(input()) for i in range(N)]
s.sort()
SUM = sum(s)
if SUM%10 != 0:
    print(SUM)
else:
    flag = 0
    for i in range(N):
        if (SUM-s[i])%10 != 0:
            print(SUM-s[i])
            flag = 1
            break
        else:
            pass
    if flag == 0:
        print(0)
    

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Abc126A
{
    static void Main(string[] args)
    {
        var NK = Console.ReadLine().Split().ToList().ConvertAll(int.Parse);
        var N = NK[0];
        var K = NK[1];
        var S = Console.ReadLine();
        var t = new char[N];
        for(var i = 0; i != N; ++i) {
            if(i == K - 1) {
                if(S[i] == 'A') t[i] = 'a';
                else if(S[i] == 'B') t[i] = 'b';
                else if(S[i] == 'C') t[i] = 'c';
            }
            else {
                t[i] = S[i];
            }
        }
        var answer = new string(t);
        Console.WriteLine(answer);
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a,b;
    cin>>a>>b;
    cout << a/b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

long long bipow(long long n, long long k){
    if(k == 0) return 1;
    if(k%2==0) return bipow((n*n)%MOD, k/2);
    else return (n*bipow(n, k-1))%MOD;
}

map<int, int> prime_factor(int n) {
    map<int, int> res;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];
    vector<map<int, int>> primes(N);
    REP(i, N) primes[i] = prime_factor(A[i]);

    map<int, int> mp;
    REP(i, N) for(auto x : primes[i])
        mp[x.first] = max(mp[x.first], x.second);

    long long num = 1;
    for(auto x : mp){
        num *= bipow(x.first, x.second);
        num %= MOD;
    }

    long long ans = 0;
    REP(i, N){
        long long tmp = num;
        tmp *= bipow(A[i], MOD-2);
        tmp %= MOD;
        ans += tmp;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int r,c;
    cin>>r>>c;
    int**a=new int*[r+1];
    for(int i=0;i<=r;i++){
        a[i]=new int[c+1];
    }
    for(int i=0;i<r;i++){
        a[i][c]=0;
        for(int j=0;j<c;j++){
            cin>>a[i][j];
            a[i][c]+=a[i][j];
        }
    }
    a[r][c]=0;
    for(int j=0;j<c;j++){
        a[r][j]=0;
        for(int i=0;i<r;i++){
            a[r][j]+=a[i][j];
        }
        a[r][c]+=a[r][j];
    }
    for(int i=0;i<=r;i++){
        cout<<a[i][0];
        for(int j=1;j<=c;j++){
            cout<<" "<<a[i][j];
        }
        cout<<endl;
    }
    for(int i=0;i<=r;i++){
        delete[] a[i];
    }
    delete[] a;
    return 0;
}


Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int cnt=0;
		for(int i=a;i<=b;i++) {
			//n1: iを反転した１つ目の桁
			int n1 = i%10,n5=i/10000%10;
			int n2 = i/10%10,n4=i/1000%10;
			if(n1==n5&&n2==n4)cnt++;
		}
		System.out.println(cnt);
		sc.close();
	}

}


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

using namespace std;

int main() {
  // O: looks like just a n^2*2^n bitmask DP
  // n*2^n states: dp[i][ii] = processed the first i men,
  // ii is bitmask of women left unpaired
  // n transitions
 
  cin.tie(0);
  cin.sync_with_stdio(0);
  int n; cin >> n;
  vector<vector<int> > adj(n);
  for(int i = 0; i<n; ++i) {
    for(int j = 0; j<n; ++j) {
      int is_pair; cin >> is_pair;
      if(is_pair == 1) {
        adj[i].push_back(j);
      }
    }
  }

  // O(n^2 2^n) is too slow!  We need O(n 2^n) instead
  vector<pair<int, int> > stateorder;
  for(int i = 0; i<(1<<n); ++i) {
    stateorder.push_back(make_pair(__builtin_popcount(i), i));
  }
  sort(stateorder.begin(), stateorder.end());

  long long MOD = 1e9+7;
  vector<long long> dp(1<<n, 0);
  dp[0] = 1;
  for(int jj = 0; jj<(1<<n)-1; ++jj) {
    int i = stateorder[jj].first;
    int j = stateorder[jj].second;
    for(int l = 0; l<adj[i].size(); ++l) {
      // for all possible pairings for i...
      int k = adj[i][l];
      if((j >> k) & 1) {
        // make sure they're not already taken
        continue;
      }
      dp[j+(1<<k)] = (dp[j+(1<<k)] + dp[j]) % MOD;
    }
  }
  cout << dp[(1<<n) - 1] << endl;
}


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

const long long MOD=1e9+7;

string pat="ABC";
string datas;

LL memo[100005][5];
int p;
LL solve(int ix, int tk)
{
	if(ix >= p)
	{
		if(tk>=3) return 1;
		return 0;
	}
	if(memo[ix][tk]!=-1) return memo[ix][tk];
	LL ret=0;
	if((datas[ix]=='?' || datas[ix]==pat[tk]) && tk<3)
	{
		ret=(ret+solve(ix+1, tk+1)%MOD)%MOD;
	}
	if(datas[ix]=='?')
	{
		ret=(ret+(3*(solve(ix+1, tk)%MOD))%MOD)%MOD;
	}
	else
	{	
		ret=(ret+solve(ix+1, tk)%MOD)%MOD;
	}
	return memo[ix][tk]=ret%MOD;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>datas;
	p=datas.length();
	memset(memo, -1, sizeof(memo));
	LL hasil=solve(0, 0);
	cout<<hasil%MOD<<endl;
	return 0;
}

Measured memory_bytes: 9040
import java.util.Scanner;

public class Main {
	// 2-100
	public static String check(int x, int y) {
		
		return "";
	}
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int ans = 0;
		int vit = 0;
		for(int i=1; i<n; i++) {
	        for(int j=1; i*j<n; j++) {
	            ans++;
	        }
	    }
		System.out.println(ans);

	}

}

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

ll a[200010];

int main()
{
   ll n,m,k;
   cin>>n>>k;
   for(int i=1; i<=n; i++)
    cin>>a[i];

   for(ll i=k+1; i<=n; i++)
   {
       if(a[i]>a[i-k]) printf("Yes\n");
       else printf("No\n");
   }
}



Measured memory_bytes: 5188
fn main(){
    let n: i64 = read();
    let a: Vec<i64> = read_vec();
    let ans: i64 = a.iter().sum::<i64>() - n;
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
import sys

def solve(numbers):
    max = -sys.maxsize
    for i in range(0, len(numbers)):
        sum = 0
        for j in range(i, len(numbers)):
            sum += numbers[j]
            if sum > max:
                max = sum
    return max


while True:
    n = int(input())
    if n == 0:
        break
    numbers = []
    for i in range(0, n):
        numbers.append(int(input()))

    print(solve(numbers))

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

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

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

  ll n, m; cin >> n >> m;

  ll ans = 0;
  if(n*2 <= m) {
    ans += n;
    m -= 2*n;
  } else {
    ans += m/2;
    m = 0;
  }
  ans += m/4;

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


Measured memory_bytes: 256
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let (n, m): (u64, u64) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        let mut ws = s.split_whitespace();
        let a = ws.next().unwrap().parse().unwrap();
        let b = ws.next().unwrap().parse().unwrap();
        (a, b)
    };

    let a: Vec<u64> = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.split_whitespace().map(|x| x.parse().unwrap()).collect()
    };

    let b: Vec<u64> = a.iter().map(|x| x / 2).collect();
    // let lcm_all = b.iter().fold(1, |acc, x| lcm(acc, *x));
    let mut lcm_all = 1;
    for &x in &b {
        lcm_all = lcm(lcm_all, x);
        if lcm_all > 10u64.pow(9) {
            // debugln!("overflow");
            println!("0");
            return;
        }
    }

    for &x in &b {
        if (lcm_all / x) % 2 == 0 {
            println!("0");
            return;
        }
    }

    let l = m / lcm_all;
    println!("{}", (l + 1) / 2);
}

fn gcd(a: u64, b: u64) -> u64 {
    let c = a % b;
    if c == 0 {
        b
    } else {
        gcd(b, c)
    }
}

fn lcm(a: u64, b: u64) -> u64 {
    (a * b) / gcd(a, b)
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn lcm_test() {
        assert_eq!(6, lcm(2, 3));
        assert_eq!(12, lcm(4, 6));
        assert_eq!(30, lcm(6, 10));
        assert_eq!(2, lcm(2, 2));
        assert_eq!(6, lcm(1, 6));
    }
}


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

int main()
{
	const int INF = 1<<29;
	int N, M;
	cin >> N >> M;

	int a[1001] = {0};
	int b[1001] = {0};
	int c[1001] = {0};
	int dist[101][101] = {0};

	//ワーシャルフロイド法の初期化
	for(int i = 0; i < N; i++)
	{
		for(int j = 0; j < N; j++)
		{
			dist[i][j] = INF;
		}
		dist[i][i] = 0; //自分への距離はゼロ
	}

	for(int i = 0; i < M; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--; //インデックスのベースを１→０
		dist[a[i]][b[i]] = c[i];
		dist[b[i]][a[i]] = c[i];
	}

	//ワーシャルフロイド法
	for(int k = 0; k < N; k++)
	{
		for(int i = 0; i < N; i++)
		{
			for(int j = 0; j < N; j++)
			{
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	//この時点でdistには各頂点間の最短経路が入ってる

	//a[i]→b[i]間の距離が更新されている場合は、迂回路のほうが最短経路であるということ
	//つまりそのa[i]→b[i]は、いかなる経路においても最短経路として使われない経路である
	//(a[i]→b[i]を移動したいとき迂回経路のほうが最短経路となっているということ)
	int cnt = 0;
	for(int i = 0; i < M; i++)
	{
		if(c[i] > dist[a[i]][b[i]]) cnt++;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=1e4+5;
int n,k,tmp,Mx,len[N];
char str[N],ans[N],Mi='z';

bool flag=false;
inline void copy(int pos) {
	for(int i=1;i<=n;++i) ans[i]=str[pos+i-1];
}
inline void solve(int pos) {
	if(!flag) return flag=true,copy(pos),void();
	for(int i=1;i<=n;++i) 
		if(ans[i]<str[pos+i-1]) return void();
		else if(ans[i]>str[pos+i-1]) return copy(pos),void();
}

int main() {
	scanf("%d%d%s",&n,&k,str+1);
	for(int i=1;i<=n;++i) Mi=min(Mi,str[i]);
	for(int i=1;i<=n;++i) str[(n<<1)-i+1]=str[i];
	if(k>=15) {for(int i=1;i<=n;++i) putchar(Mi);return 0;}
	if(k==1) {
		for(int i=1;i<=n+1;++i) solve(i);
		return printf("%s\n",ans+1),0;
	}
	for(int i=1;i<=n+n;++i) if(str[i]==Mi) len[i]=len[i-1]+1;
	for(int i=1;i<=n+n;++i) Mx=max(Mx,len[i]);
	tmp=Mx<<k-1;
	if(tmp>=n) {for(int i=1;i<=n;++i) putchar(Mi);return 0;}
	for(int i=1;i<=n+Mx;++i) if(len[i]==Mx) solve(i-len[i]+1);
	for(int i=1;i<=tmp;++i) putchar(Mi);
	for(int i=1;i<=n-tmp;++i) putchar(ans[i+Mx]);
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val v = readLine()!!.split(" ").map { it.toInt() }
    val c = readLine()!!.split(" ").map { it.toInt() }

    var ans = 0

    for (i in 0 until n) {
        if (v[i] - c[i] > 0){
            ans += v[i] - c[i]
        }
    }
    print(ans)
}

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

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i=0; i<N; i++) cin >> A[i];

    long long sum=0;
    vector<long long> candidate(2);
    // 和の符号が負、正、負、正、、、、
    long long ans=0;
    for (int i=0; i<N; i++) {
        sum += A[i];
        if (i%2 == 0 and sum>=0) {
            ans += sum+1;
            sum += -1-sum;
        }
        else if (i%2 == 1 and sum<=0) {
            ans += 1-sum;
            sum += 1-sum;
        }
    }
    candidate[0] = ans;

    // 和の符号が正、負、正、負、、、、
    ans=0;
    sum=0;
    for (int i=0; i<N; i++) {
        sum += A[i];
        if (i%2 == 0 and sum<=0) {
            ans += 1-sum;
            sum += 1-sum;
        }
        else if (i%2 == 1 and sum>=0) {
            ans += sum+1;
            sum += -1-sum;
        }
    }
    candidate[1] = ans;

    cout << min(candidate[0], candidate[1]) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define mod 1000009
#define line cout<<"--------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
vector<pair<ll ,ll > > v;
ll  n;
ll  dp[2009][2009];
ll  call(ll  ind, ll  pre)
{
    if(ind==v.size()) return 0;
    ll  ses=n-1-(ind-pre);
    ll  &ret=dp[ind][pre];
    if(ret!=-1) return ret;
    ll  a=0,b=0;
    a=v[ind].first*(v[ind].second-pre)+call(ind+1,pre+1) ;
    b=v[ind].first*(ses-v[ind].second)+call(ind+1,pre) ;
    return ret=max(a,b);
}
int   main()
{
    memset(dp,-1,sizeof dp );
    cin>>n;
    for(ll  i=0;i<n;i++)
    {
        int x; cin>>x;
        v.pb(mp(x,i));
    }
    sort(v.rbegin(),v.rend());
    cout<<call(0,0)<<endl;
}



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

int a[51];
int b[51];
int c[51];
int d[51];
const int INF = 1 << 29;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    for(int i = 0; i < N; ++i)
        cin >> a[i] >> b[i];

    for(int i = 0; i < M; ++i)
        cin >> c[i] >> d[i];
        
    
    for(int i = 0; i < N; ++i){
        int m = INF;
        int ans = 0;
        for(int j = 0; j < M; ++j){
            int x = a[i] - c[j];
            int y = b[i] - d[j];
            if(x < 0) x = -x;
            if(y < 0) y = -y;
            if(x + y < m){
                m = x + y;
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

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

int main() {
  
  string S; int64_t K; cin >> S >> K;
  
  int position = -1, ans = 1; K--;
  
  for (int i = 0; i < S.size(); i++) {
    
    string tmp = S.substr(i, 1);
    
    if (tmp != "1") {
      
      position = i; ans = stoi(tmp); break;
      
    }
    
  }
    
  if (K < position || position == -1) cout << 1 << endl;
  
  else cout << ans << endl;
  
}

Measured memory_bytes: 256
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb push_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
// #define fill(x, v) memset(x, v, sizeof(x))
#define FER(i,a,b) for(int i=int(a); i< int(b); ++i)
#define IFR(i,a,b) for(int i=int(a); i>=int(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
// #define N 21000000
// #define M 19
// #define mod 
#define mod  998244353
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 3000000000000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<vi> vv;
typedef vector<ii> vii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}
 
inline ll add(ll a, ll b, ll m) { return a+b < m? a+b : a+b-m;}
inline ll rem(ll a, ll b, ll m) { return a >= b? a - b: a- b + m;}
inline ll mul(ll a, ll b, ll m) { return (long long) a*b%m;}
inline void Mul(ll &a, ll b, ll m) { a = (long long) a*b%m;}
inline ll bp(ll a, ll p, ll m){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a, m)) (p & 1) && (Mul(ret, a, m), 1);
	return ret;
}
 
static inline void read(ll &x) { cin>>x;}

int main(){
	fastio;
	ll x; read(x);
	vi tnt = {0, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000};
	FER(i, 0, sz(tnt)){
		if(x >= tnt[i] and x < tnt[i+1]){
			cout<<9 - i<<"\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3628