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

def main():
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    nisuu = a[0]
    syukudai = np.sum(np.array(b))
    if nisuu >= syukudai:
        print(nisuu-syukudai)
    else:
        print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 27692
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define loop(i,s,e) for(ll i=s; i<e; i++)
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX
#define minusinf INT_MIN

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

ll n, k;
ll arr[100001];

ll dp[100001];

ll util(ll i){
	if(i>=n-1) return 0;

	if(dp[i]!=-1) return dp[i];

	ll ans = inf;

	for(ll j=1; j<=k; j++){
		if(i+j<=n-1) ans = min(ans, abs(arr[i]-arr[i+j]) + util(i+j) );
	}

	//bug(i, ans);

	return dp[i] = ans;
}

void alpha(){

	cin>>n>>k;
	memset(dp, -1, sizeof(dp));
	
	loop(i,0,n) cin>>arr[i];

	cout<<util(0)<<endl;

	return;

}

int main(){

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


    ll t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}

Measured memory_bytes: 6528
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <list>
#include <forward_list>
#include <array>
#include <cstring>
#include <cmath>
#include <tuple>
#include <complex>
#include <bitset>
#include <climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pld = pair<LD, LD>;
const int MAX_NR = 1e6, SQRT_MAX_NR = 1e3;  // = sqrt(10^6)
bitset<MAX_NR + 1> is_prime = move(bitset<MAX_NR + 1>().set());
vector<int> primes = {2}, prime_occ(MAX_NR);
int max_occ;


void eratosthenes()
{
    is_prime[0] = is_prime[1] = false;

    for (int j = 4; j * j <= MAX_NR; j += 2)
    {
        is_prime[j] = false;
    }

    int i = 3;
    for (; i * i <= MAX_NR; i += 2)
    {
        if (is_prime[i])
        {
            primes.emplace_back(i);
            for (int j = i * i; j <= MAX_NR; j += i)
            {
                is_prime[j] = false;
            }
        }
    }

    for (i += !(i % 2); i <= MAX_NR; i += 2)
    {
        if (is_prime[i])
        {
            primes.emplace_back(i);
        }
    }
}


void get_prime_facs(int nr)
{
    for (const int &prime : primes)
    {
        if (prime * prime > nr)
        {
            break;
        }

        if (nr % prime == 0)
        {
            max_occ = max(max_occ, ++prime_occ[prime]);

            while (nr % prime == 0)
            {
                nr /= prime;
            }
        }
    }

    if (nr > 1)
    {
        max_occ = max(max_occ, ++prime_occ[nr]);
    }
}


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

    for (int i = 1; i <= N; ++i)
    {
        int nr;
        scanf("%d", &nr);

        get_prime_facs(nr);
    }

    if (max_occ == N)
    {
        printf("not coprime");
    }
    else if (max_occ > 1)
    {
        printf("setwise coprime");
    }
    else
    {
        printf("pairwise coprime");
    }
}


Measured memory_bytes: 7880
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, M, Q;;
char S[2010][2010];
int V[2010][2010], E1[2010][2010], E2[2010][2010];



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M >> Q;
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= M; j++){
            cin >> S[i][j];
        }
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= M; j++){
            V[i][j] += S[i][j] - '0';
        }
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= M; j++){
            if(S[i - 1][j] == '1' && S[i][j] == '1'){
                E1[i][j]++;
            }
            if(S[i][j - 1] == '1' && S[i][j] == '1'){
                E2[i][j]++;
            }
        }
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= M; j++){
            V[i + 1][j] += V[i][j];
            E1[i + 1][j] += E1[i][j];
            E2[i + 1][j] += E2[i][j];
        }
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= M; j++){
            V[i][j + 1] += V[i][j];
            E1[i][j + 1] += E1[i][j];
            E2[i][j + 1] += E2[i][j];
        }
    }

    for(int i = 0; i < Q; i++){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int v = V[x2][y2] - V[x2][y1 - 1] - V[x1 - 1][y2] + V[x1 - 1][y1 - 1];
        int e1 = E1[x2][y2] - E1[x2][y1 - 1] - E1[x1][y2] + E1[x1][y1 - 1];
        int e2 = E2[x2][y2] - E2[x2][y1] - E2[x1 - 1][y2] + E2[x1 - 1][y1];
        cout << v - e1 - e2 << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>> &pq) {return (ll)pq.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>, greater<T>> &pq) {return (ll)pq.size(); }
ll sz(string &s) {return (ll)s.size(); } 
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }
bool checkindex(ll i,ll n){ return (i < n && i >= 0); }

ll dx[4] = {0,1,0,-1},dy[4] = {1,0,-1,0};

int main(){
    ll n;
    cin >> n;
    ll memo[n][n] = {};
    ll memo2[n][n] = {};
    ll memox[n*n+1] = {};
    ll memoy[n*n+1] = {};

    rep(i,1,n+1){
        rep(j,1,n+1){
            memox[n*(i-1)+j] = i-1;
            memoy[n*(i-1)+j] = j-1;
        }
    } 

    rep(i,0,n){
        rep(j,0,n){
            memo[i][j] = min(min(i,j),min(n-1-i,n-1-j));
            memo2[i][j] = 1; 
        }
    }

    ll ans = 0,a;
    rep(i,0,n*n){
        cin >> a;  
        ll temp = memo[memox[a]][memoy[a]];
        ans += temp;
        memo2[memox[a]][memoy[a]] = 0;

        queue<P> que;
        que.push(P(memox[a],memoy[a]));
        while(!que.empty()){
            P p = que.front();
            que.pop();
            rep(j,0,4){
                if(checkindex(p.fs+dx[j],n) && checkindex(p.sc+dy[j],n)){
                    ll x = p.fs+dx[j], y = p.sc+dy[j];
                    if(memo[x][y] > memo[p.fs][p.sc]+memo2[p.fs][p.sc]){
                        memo[x][y] = memo[p.fs][p.sc]+memo2[p.fs][p.sc];
                        que.push(P(x,y));
                    }
                }
            }
        } 
    }
    cout << ans << endl;

    

    return 0;
}



Measured memory_bytes: 11412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
#define int long long
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

signed main() {
    int n;
    cin >> n;
    int a[n];
    rep (i, 0, n) cin >> a[i];
    sort (a, a + n, greater<int>());
    priority_queue<int> pq;
    int ans = 0;
    rep (i, 0, n) {
        if (i == 0) {
            pq.push (a[i]);
        } else {
            int now = pq.top();
            pq.pop();
            ans += now;
            pq.push (a[i]);
            pq.push (a[i]);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6832
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-7
#define MOD 999377ll
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pr;
typedef pair<int, pair<int, int>> tup;

void update(int pos, ll val, vector<ll> &fenv)
{
	while (pos < fenv.size())
	{
		fenv[pos] += val;
		pos = (pos | (pos + 1));
	}
}

ll sum(int pos, vector<ll> &fenv)
{
	ll res = 0;
	while (pos >= 0)
	{
		res += fenv[pos];
		pos = (pos & (pos + 1)) - 1;
	}
	return res;
}

ll s(int l, int r, vector<ll> &fenv)
{
	return sum(r, fenv) - sum(l - 1, fenv);
}

inline void solve()
{
	ll n, d, a;
	cin >> n >> d >> a;
	vector<pr> v(n);
	fore(i, 0, n)
		cin >> v[i].first >> v[i].second;
	sort(v.begin(), v.end());

	vector<ll> fenv(n + 1, 0);
	ll otv = 0;


	fore(i, 0, n)
	{
		ll su = s(i, n, fenv);

		if (v[i].second - su > 0)
		{
			ll cnt = (v[i].second - su) / a + ((v[i].second - su)  % a > 0 ? 1 : 0);
			pr ne_p = { v[i].first + 2 * d, inf };
			auto ub = upper_bound(v.begin(), v.end(), ne_p);
			int pos = ub - v.begin();
			if (ub != v.end())
				pos--;
			update(pos, cnt * a, fenv);
			otv += cnt;
		}
	}

	cout << otv;
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}


Measured memory_bytes: 4992
#include <iostream>
#include <math.h>
using namespace std;
int main( void )
{
	int x, h;
	while ( cin >> x >> h && x && h )
	{
		double xx = x;
		double S = xx * xx;

		double hh = sqrt( ((xx/2.0)*(xx/2.0)) + (h*h) );

		S += hh * xx / 2.0 * 4.0;

		cout.setf(ios::fixed);
		cout.precision( 6 );
		cout << S << endl;

	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#define ld long double
using namespace std;

int a,b,c,d,e,f;
int sugar,water;
ld maxi;
int vtx,vty;
int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> a >> b >> c >> d >> e >> f;
	a*=100;
	b*=100;
	maxi=0;
	for (int i=0; a*i<=f; i++)
	for (int j=0; a*i+b*j<=f; j++)
	for (int z=0; c*z+a*i+b*j<=f; z++)
	for (int t=0; d*t+c*z+a*i+b*j<=f; t++)
	{
		sugar=c*z+d*t;
		water=a*i+b*j;
		//cout << i << ' ' << j << ' ' << z << ' ' << t << ' ' << water << ' ' << sugar << '\n';
		if (sugar*100<=e*water)
		{
			if (100.0*(ld) sugar/((ld) water+(ld) sugar)>maxi)
			{
				maxi=100.0*(ld) sugar/((ld) water+(ld) sugar);
				vtx=water;
				vty=sugar;
			}
		}
	}
	if (maxi==0) cout << a << ' ' << 0 << '\n';
	else
	cout << vtx+vty << ' ' << vty;
	return 0;
}
			
			
		

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

int n, k, s;
int main() {
	int i, j;
	cin >> n >> k;
	s = (n-1) * (n-2) / 2;
	if(k > s) return puts("-1"), 0;
	s -= k;
	cout << n - 1 + s << endl;
	for(i=2; i<=n; i++) printf("1 %d\n", i);
	for(i=2; s && i<n; i++) {
		for(j=i+1; s && j<=n; j++, s--) {
			printf("%d %d\n", i, j);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//最大公約数を返す関数.
long long int gcd(long long int x, long long int y){
    if (x < y) swap(x,y);
    while (y > 0){
        long long int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	rep(i, n - 2)
	{
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace d
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var n = int.Parse(_[0]);
            var m = int.Parse(_[1]);
            var a = Console.ReadLine();

            var d = new Dictionary<long, long>();
            foreach(var i in a.Split()){
                var x = long.Parse(i);
                if(d.ContainsKey(x)){
                    d[x] += 1;
                }else{
                    d.Add(x, 1);
                }
            } 

            for(var i = 0; i < m; i++){
                var t = Console.ReadLine().Split();
                var b = long.Parse(t[0]);
                var c = long.Parse(t[1]);
                if(d.ContainsKey(c)){
                    d[c] += b;
                }else{
                    d.Add(c, b);
                }
            }

            BigInteger total = 0;
            var count = 0L;
            foreach(var i in d.OrderByDescending(i => i.Key)){
                var key = i.Key;
                var val = i.Value;
                if(count + val <= n){
                    total += (key * val);
                    count += val;
                }else{
                    total += (key * (n - count));
                    break;
                }

            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 42404
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       a: usize,
       b:usize
    }

    let mut ans: usize = 0;
    ans = a * b;
    echo!(ans);
}


Measured memory_bytes: 2160
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

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

ll n, m, s, t;

ll fare[2][112345];
const int _yen = 0, _snuuk = 1;
const ll inf = 1123456789012345678;
vector<vector<pair<ll, ll>>> cost[2];

int main() {

	scanf("%lld%lld%lld%lld", &n, &m, &s, &t);
	cost[0].resize(n + 1);
	cost[1].resize(n + 1);
	rep(i, m) {
		ll u, v, a, b;
		scanf("%lld%lld%lld%lld", &u, &v, &a, &b);
		cost[_yen][u].push_back({ v, a });
		cost[_yen][v].push_back({ u, a });
		cost[_snuuk][u].push_back({ v, b });
		cost[_snuuk][v].push_back({ u, b });
	}

	rep(i, 2) {
		ll from = i ? t : s, to = i ? s : t;
		bool closed[112345] = {};
		int closed_num = 0;
		priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<>> pq; //f:cost,s:v
		rep(j, n + 1) fare[i][j] = inf;
		fare[i][from] = 0;
		closed[from] = true;
		closed_num++;
		for (auto v : cost[i][from]) {
			fare[i][v.first] = v.second;
			pq.push({ v.second, v.first });
		}

		while (!pq.empty()) {
			auto t = pq.top();
			pq.pop();
			for (auto v : cost[i][t.second]) {
				ll alt = fare[i][t.second] + v.second;
				if (fare[i][v.first] > alt) {
					fare[i][v.first] = alt;
					pq.push({ alt, v.first });
				}
			}
		}
	}

	vector<ll> c;
	rep(i, n) c.push_back(fare[0][i + 1] + fare[1][i + 1]);

	rep(i, n - 1) c[n - 2 - i] = min(c[n - 1 - i], c[n - 2 - i]);

	rep(i, n) {
		printf("%lld\n", 1000000000000000 - c[i]);
	}

	return 0;
}


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

using namespace std;

typedef long long ll;
#define mems(p) memset(p,-1,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

const int mxN = 1e5;
const ll MOD = 1e9 + 7;

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

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

int main() {
	fast();

	string s,t;
	cin >> s >> t;
	int ans =0;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] != t[i]) {
			++ans;
		}
	}
	cout << ans << nl;
}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(int i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(int i = 0; i < n; i++)
#define float long double
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;
 
 
int32_t main()
{
    fast_io;
    
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int m=t.size();
    int ans=LLONG_MAX;
    for(int i=0;i<=n-m;i++)
    {
        int diff=0;
        for(int j=0;j<m;j++)
        {
            if(s[i+j]!=t[j])
            diff++;
        }
        ans=min(diff,ans);

    }
    cout<<ans<<lc;
    return 0;
}

Measured memory_bytes: 3564
(N, Q) = gets.split.map(&:to_i)
S = gets.chomp

d = Array.new(N + 1, 0)

2.upto(N) do |i|
  if S[i - 2...i] == "AC"
    d[i] = d[i - 1] + 1
  else
    d[i] = d[i - 1]
  end
end

Q.times do
  l, r = gets.split.map(&:to_i)
  puts d[r] - d[l]
end

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

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String buffer;
		int count = 0;

		int n = 0;
		int m = 0;
		int[][] matrix = null;
		int[] vector = null;

		try {
			while ((buffer = reader.readLine())  != null) {
				String[] strings = buffer.split(" ");
				++count;
				if (count == 1) {
					n = Integer.valueOf(strings[0]);
					m = Integer.valueOf(strings[1]);
					matrix = new int[n][m];
					vector = new int[m];
				}
				else {
					if (1 < count && count <= 1 + n) {
						for (int w = 0; w < m; w++) {
							matrix[count - 2][w] = Integer.valueOf(strings[w]);
						}
					}
					if (1 + n < count && count <= 1 + n + m) {
						vector[count - 2 - n] = Integer.valueOf(strings[0]);
					}
					if (1 + n + m == count) {
						for (int h = 0; h < n; h++) {
							int calc = 0;
							for (int w = 0; w < m; w++) {
								calc += (matrix[h][w] * vector[w]);
							}
							System.out.println(calc);
						}
					}
				}
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}



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

int main() {


//long long a,b;
//int *num=new int[4];
//char *s=new char[3];
string s;
cin >> s;

if (s.find("AC") != std::string::npos) {
   cout << "Yes" << "\n";
}else
cout << "No" << "\n";


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	int N,K;
	cin >> N >> K;
	vector<vector<int> > D(K);
	vector<int> d(K);
	map<int, int> mp;
	rep(i,K){
		cin >> d[i];
		D[i] = vector<int>(d[i]);
		rep(j,d[i]) {
			cin >> D[i][j];
			D[i][j]--;
			mp[D[i][j]]++;
		}
	}
	int ans = 0;
	rep(i,N) {
		if(mp[i] == 0) ans++;
	}
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

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

        while(in.hasNext()){
            double weight = in.nextDouble();
            String rank;

            if(weight <= 48.00){
                 rank = "light fly";
            }else if(weight > 48.00 && weight <= 51.00){
                rank = "fly";
            }else if(weight > 51.00 && weight <= 54.00){
                rank = "bantam";
            }else if(weight > 54.00 && weight <= 57.00){
                rank = "feather";
            }else if(weight > 57.00 && weight <= 60.00){
                rank = "light";
            }else if(weight > 60.00 && weight <= 64.00){
                rank = "light welter";
            }else if(weight > 64.00 && weight <= 69.00){
                rank = "welter";
            }else if(weight > 69.00 && weight <= 75.00){
                rank = "light middle";
            }else if(weight > 75.00 && weight <= 81.00){
                rank = "middle";
            }else if(weight > 81.00 && weight <= 91.00){
                rank = "light heavy";
            }else{
                rank = "heavy";
            }
            System.out.println(rank);
        }
    }
}



Measured memory_bytes: 27916
a,b,q=map(int,input().split())
s=[int(input()) for _ in range(a)]
t=[int(input()) for _ in range(b)]
import bisect
for _ in range(q):
    x=int(input())
    sb=bisect.bisect_left(s,x)
    tb=bisect.bisect_left(t,x)
    ss=[x-s[max(sb-1,0)],x-s[min(sb,a-1)]]
    tt=[x-t[max(tb-1,0)],x-t[min(tb,b-1)]]
    l=[]
    for i in ss:
        for j in tt:
            if i*j>=0:
                l.append(max(abs(i),abs(j)))
            else:
                l.append(max(abs(i),abs(j))+2*min(abs(i),abs(j)))
    print(min(l))


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

#define ll long long int
#define li int64_t

int main()
{
	int n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}	
	ll sum = 0;
	for(int i=1;i<n;i++)
	{
		if(a[i]<a[i-1])
		{
			sum+= a[i-1]-a[i];
			a[i] = a[i-1];
		}

	}
	cout<<sum;
}

Measured memory_bytes: 5192
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {

        static void Main(string[] args)
        {
          //var N = int.Parse(Console.ReadLine());
          //var ABX = Console.ReadLine();.Split(' ').Select(x => long.Parse(x)).ToArray();
          var S = Console.ReadLine().ToCharArray();
          var T = Console.ReadLine().ToCharArray();
          var flag = false;
          for(int i = S.Length-1;i >= T.Length-1 ; i--){
            var Tpoint = T.Length-1;
            var Spoint = i;
            while(Tpoint >= 0 && (S[Spoint] == T[Tpoint] || S[Spoint] == '?')){
              Tpoint--;
              Spoint--;
            }
            if(Tpoint == -1){
              for(int j = i; j >= i-T.Length+1;j--){
                //Console.WriteLine(T.Length-1-i+j);
                S[j] = T[T.Length-1-i+j];
              }
              flag = true;
              break;
            }
          }

          if(flag){
            for(int i = 0; i < S.Length ; i++){
              if(S[i] == '?'){
                S[i] = 'a';
              }
            }
            Console.WriteLine(new string(S));
          }else{
            Console.WriteLine("UNRESTORABLE");
          }
          
        }
  

}







Measured memory_bytes: 13140
/*
 * Author       : YangDavid
 * Created Time : 2019年09月21日 星期六 20时42分27秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 1020000, MOD = 998244353;
int add(int x, int y) { return x+y>=MOD ? x+y-MOD : x+y; }
int sub(int x, int y) { return x-y<0 ? x-y+MOD : x-y; }
int mul(int x, int y) { return 1LL * x * y % MOD; }
int qpow(int x, int y) {
    int ret = 1;
    for(; y; y >>= 1, x= mul(x, x))
        if(y & 1) ret = mul(ret, x);
    return ret;
}
int inv(int x) { return qpow(x, MOD - 2); }
const int inv2 = inv(2), n = 1000000;
int sum(int l, int r) { return mul(mul(l+r, r-l+1), inv2); }

int num, a[maxn], c[maxn], tot, sumD[maxn],  pre[maxn], mu2Id[maxn], prime[maxn], pcnt, vis[maxn];
int muId2[maxn], conv[maxn];

int main() {
    mu2Id[1] = muId2[1] = 1;
    for(int i = 2; i <= n; ++i) {
        if(!vis[i]) prime[++pcnt] = i, mu2Id[i] = i, muId2[i] = mul(sub(0, i), i);
        for(int j = 1; j <= pcnt && i * prime[j] <= n; ++j) {
            vis[i * prime[j]] = true;
            if(i % prime[j] == 0) break;
            else mu2Id[i * prime[j]] = mul(mu2Id[i], mu2Id[prime[j]]), 
                muId2[i * prime[j]] = mul(muId2[i], muId2[prime[j]]);
        }
    }
    for(int i = 1; i <= n; ++i)
        for(int j = 1; i * j <= n; ++j)
            conv[i * j] = add(conv[i * j], mul(i, muId2[j]));

    scanf("%d", &num);
    rep(i, num) scanf("%d", &a[i]), c[a[i]]++, tot = add(tot, a[i]);
    for(int d = 1; d <= n; ++d)
        for(int i = 1; i * d <= n; ++i)
            sumD[d] = add(sumD[d], mul(i, c[i*d]));

    int ans = 0;
    for(int pd = 1; pd <= n; ++pd)
        ans = add(ans, mul(mul(sumD[pd], sumD[pd]), conv[pd]));
    ans = mul(sub(ans, tot), inv2);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 28928
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

// Translate woqja125's code
// 2030742

type Item struct {
	vertex   int
	priority int
}

type PriorityQueue []*Item

// For container/heap
func (pq PriorityQueue) Len() int { return len(pq) }
func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].priority < pq[j].priority
}
func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
func (pq *PriorityQueue) Push(x interface{}) {
	i := x.(Item)
	*pq = append(*pq, &i)
}
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

type edge struct {
	to   int
	cost int
}

const (
	MOD = 1000*1000*1000 + 7
)

var edges [][]edge

func dijkstra(startPos int, distance, count []int) {
	toVisit := make(PriorityQueue, 0, len(distance))

	for i := range distance {
		distance[i] = -1
	}
	count[startPos], distance[startPos] = 1, 0
	toVisit.Push(Item{vertex: startPos, priority: 0})
	heap.Init(&toVisit)
	for toVisit.Len() > 0 {
		point := heap.Pop(&toVisit).(*Item)
		if point.priority != distance[point.vertex] {
			continue
		}
		for _, e := range edges[point.vertex] {
			if distance[e.to] == -1 ||
				distance[e.to] > distance[point.vertex]+e.cost {
				distance[e.to] = distance[point.vertex] + e.cost
				count[e.to] = count[point.vertex]
				heap.Push(&toVisit, Item{vertex: e.to, priority: distance[e.to]})
			} else if distance[e.to] == distance[point.vertex]+e.cost {
				count[e.to] = (count[e.to] + count[point.vertex]) % MOD
			}
		}
	}
	return
}

func main() {
	in := IOInitialize()
	n, m := Int(in), Int(in)
	s, t := Int(in)-1, Int(in)-1
	edges = make([][]edge, n)
	for i := range edges {
		edges[i] = make([]edge, 0, 4)
	}

	for i := 0; i < m; i++ {
		u, v, d := Int(in)-1, Int(in)-1, Int(in)

		edges[u] = append(edges[u], edge{to: v, cost: d})
		edges[v] = append(edges[v], edge{to: u, cost: d})
	}
	distanceFromS := make([]int, n)
	distanceFromT := make([]int, n)
	CountFromS := make([]int, n)
	CountFromT := make([]int, n)

	dijkstra(s, distanceFromS, CountFromS)
	dijkstra(t, distanceFromT, CountFromT)

	c := make([]int, 0, (n/10)+10)
	OptLength, ans, S := distanceFromS[t], 0, 0
	for i := range distanceFromS {
		if distanceFromS[i] == distanceFromT[i] {
			c = append(c, CountFromS[i]*CountFromT[i]%MOD)
		}
		if distanceFromS[i]*2 >= OptLength {
			continue
		}
		for _, e := range edges[i] {
			if distanceFromS[i]+e.cost+distanceFromT[e.to] != OptLength {
				continue
			}
			if distanceFromT[e.to]*2 < OptLength {
				c = append(c, CountFromS[i]*CountFromT[e.to]%MOD)
			}
		}
	}
	for _, x := range c {
		S = (S + x) % MOD
	}
	for _, x := range c {
		ans = (ans + x*(S-x+MOD)) % MOD
	}

	fmt.Println(ans)
}

//////////
func IOInitialize() *bufio.Scanner {
	t := bufio.NewScanner(os.Stdin)
	t.Split(bufio.ScanWords)
	return t
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("\t\tThere is a FALSE not to want.")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("\t\tError:Failed to convert text to int,")
	}
	return value
}


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

int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<bool>> a(n, vector<bool>(n, false));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            char x;
            cin >> x;
            if(x=='#') a.at(i).at(j)=true;
        }
    }
    vector<ll> b(m);
    for(int i = 0; i < m; i++) {
        ll x=0;
        for(int j = 0; j < m; j++) {
            x *= 2;
            char y;cin >> y;
            if(y=='#') x ++;
        }
        b[i]=x;
    }
    
    for(int i = 0; i < n-m+1; i++) {
        for(int j = 0; j < n-m+1; j++) {
            vector<ll> x(m);
            for(int k = 0; k < m; k++) {
                ll y=0;
                for(int l = 0; l < m; l++) {
                    y *= 2;
                    bool z=a.at(i+k).at(j+l);
                    if(z) y++;
                }
                x[k]=y;
            }
            if(x==b){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    

    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
bitset <2002001> dp;
int n,x,maxs;
int main()
{
	scanf("%d",&n);
	dp[0]=1;
	for (int i=1;i<=n;++i) scanf("%d",&x),dp|=dp<<x,maxs+=x;
	for (int i=(maxs+1)/2;i<=maxs;++i) if (dp[i]) return printf("%d",i),0;
}


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

using namespace std;

int main() {
	double a, l, x;
	cout.precision(10);
	while (cin >> a >> l >> x) {
		double area = sqrt(l * l - a * a / 4.0) * a / 2.0 + sqrt((l + x) * (l + x) / 4.0 - l * l / 4.0) * l;
		cout << fixed << area << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> sub(N-1);
  for(int i = 0; i < N-1; i++){
  cin >> sub.at(i);
  }
  vector<int> A(N);
  A.at(0) = sub.at(0);
  for(int j = 1; j < N-1; j++){
  A.at(j) = min(sub.at(j-1),sub.at(j));
  }
  A.at(N-1) = sub.at(N-2);
  int c = 0;
  for(int k = 0; k < N; k++){
    c = c + A.at(k);
  }
  cout << c << endl;
 }

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

using namespace std;

typedef long long int lli;

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

    int n, k;
    cin >> n >> k;

    cout << ((k==1) ? 0 : n-k) << endl;

    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] X = sc.next().toCharArray();
    char[] Y = sc.next().toCharArray();
    char ans;
    if (X[0] < Y[0]) {
      ans = '<';
    } else if (X[0] > Y[0]) {
      ans = '>';
    } else {
      ans = '=';
    }
    System.out.println(ans);
  }
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n % 2) return (a * powmod(a, n - 1, mod)) % mod;
	return powmod((a * a) % mod, n / 2, mod);
}

int mod = 1000000007;
int fact[200000];
int factInv[200000];

void initFact() {
	int i;
	
	fact[0] = 1;
	factInv[0] = 1;
	REP(i, 1, 200000) {
		fact[i] = (i * fact[i - 1]) % mod;
		factInv[i] = powmod(fact[i], mod - 2, mod);
	}
}

int comb(int n, int k) {
	if (k > n) return 0;
	return fact[n] * factInv[n - k] % mod * factInv[k] % mod;
}

typedef pair<int, int> P;
int h, w, n;
P pos[3002];
int dp[3002][2];

int cal(int i, int j) {
	int dy = pos[j].first - pos[i].first;
	int dx = pos[j].second - pos[i].second;
	if (dy < 0 || dx < 0) return 0;
	return comb(dy + dx, dx);
}

signed main() {
	initFact();
	
	int i, j, k;
	
	cin >> h >> w >> n;
	rep(i, n) {
		cin >> pos[i].first >> pos[i].second;
	}
	pos[n] = P(1, 1);
	pos[n + 1] = P(h, w);
	n += 2;
	sort(pos, pos + n);
	
	dp[0][0] = 1;
	rep(i, n) {
		rep(j, 2) {
			REP(k, i + 1, n) {
				dp[k][!j] += cal(i, k) * dp[i][j];
				dp[k][!j] %= mod;
			}
		}
	}
	
	cout << (dp[n - 1][1] - dp[n - 1][0] + mod) % mod << endl;
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

int a[202020];
int le[202020];
int ri[202020];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>a[i];
	}
	vector<pair<int, int> > st;
	st.push_back({0, 0});
	for (int i=1;i<=n;i++){
		while (a[i]<st.back().F) st.pop_back();
		le[i]=i-st.back().S;
		st.push_back({a[i], i});
	}
	st.clear();
	st.push_back({0, n+1});
	for (int i=n;i>=1;i--){
		while (a[i]<st.back().F) st.pop_back();
		ri[i]=st.back().S-i;
		st.push_back({a[i], i});
	}
	ll v=0;
	for (int i=1;i<=n;i++){
		v+=(ll)le[i]*(ll)ri[i]*(ll)a[i];
	}
	cout<<v<<endl;
}

Measured memory_bytes: 4468
import java.util.Scanner;

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

		// 入力値の取得
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		
		while (A > 0) {
			C -= B;
			if (C <= 0) {
				System.out.println("Yes");
				break;
			}
			A -= D;
			if (A <= 0) {
				System.out.println("No");
			}
		}
		
		sc.close();
	}
}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            if (s[0] == s[2])
                Console.WriteLine("=");
            else if (s[0] > s[2])
                Console.WriteLine(">");
            else
                Console.WriteLine("<");
        }
    }
}

Measured memory_bytes: 11092
n_k = list(map(lambda x: int(x), input().split(" ")))
N = n_k[0]
K = n_k[1]
Hs = list(map(lambda x: int(x), input().split(" ")))
Hs = reversed(sorted(Hs))
result = 0
for h in Hs:
    if K > 0:
        K -= 1
        continue
    result += h

print(result)

Measured memory_bytes: 26764
l = map(int, raw_input().split())
x=l[0]
y=l[1]

A=[1,3,5,7,8,10,12]
B=[4,6,9,11]
C=[2]

if x in A and y in A:
    print 'Yes'
elif x in B and y in B:
    print 'Yes'
elif x in C and y in C:
    print 'Yes'
else:
    print 'No'

Measured memory_bytes: 2568
def dijkstra_heap(n,s,edge,k):
    # 始点sから各頂点への最短距離
    d = [float("inf")] * n
    d[s] = 0
    edgelist = [s]
    while edgelist:
        nextedge = []
        for i in edgelist:
            for j in edge[i]:
                next = j[2]
                c = j[k]
                if d[next] > c + d[i]:
                    d[next] = c + d[i]
                    nextedge.append(next)
        edgelist = nextedge
    return d

def examD():
    N, M, s, t = LI()
    edge = defaultdict(list)
#    edge2 = defaultdict(list)
    # edge2 メモリ無駄
    for i in range(M):
        x, y, z1, z2 = map(int, input().split())
        x -=1; y -=1
        edge[x].append((z1,z2,y))
        edge[y].append((z1,z2,x))
    start1 = s-1
    start2 = t-1
    res1 = dijkstra_heap(N,start1, edge,0)
    res2 = dijkstra_heap(N,start2, edge,1)
    ans = []
    snuke = 10**15
    cur = res1[N-1] + res2[N-1]
    ans.append(cur)
    for i in range(N-2,-1,-1):
        if res1[i] + res2[i]<cur:
            cur = res1[i] + res2[i]
            ans.append(cur)
        else:
            ans.append(cur)
    for v in ans[::-1]:
        print(snuke-v)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


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

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

Measured memory_bytes: 4832
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n,q;cin>>n>>q;
    vector<pair<pll,ll> >event(0);
    rep(i,n){
        ll s,t,x;cin>>s>>t>>x;
        event.pb(mp(mp(s-x,x),1));
        event.pb(mp(mp(t-x,x),-1));
    }
    rep(i,q){
        ll d;cin>>d;
        event.pb(mp(mp(d,inf),0));
    }
    sort(all(event));
    set<ll>s;
    rep(i,2*n+q){
        if(event[i].second==0){
            if(s.empty()){
                cout<<-1<<endl;
            }else{
                auto itr=s.begin();
                cout<<*itr<<endl;
            }
        }else if(event[i].second==1){
            s.insert(event[i].first.second);
        }else if(event[i].second==-1){
            s.erase(event[i].first.second);
        }
    }
}

Measured memory_bytes: 26600
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair

#define all(x) (x).begin(),(x).end()
#define FOR(x) for(ll i = 0;i < x;++i)

using namespace std;
typedef long long ll;

int main() {
  int N,M;
  cin>>N>>M;
  int maxNO = 1000000,minNO = 0;
  for(int i = 0;i < N;i++){
    int L,R;
    cin>>L>>R;
    if(L > minNO)minNO = L;
    if(R < maxNO)maxNO = R;
  }
  int ans;
  ans = maxNO - minNO + 1;
  if(ans < 0)ans = 0;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io;

/// 1..nまでの整数のうち、3の倍数および、3が含まれる数字を順番に出力する関数
fn call(n: u32){
    for i in 1..n+1 {
        let mut x = i;
        if x%3==0 {
            print!(" {}", i);
        } else {
            loop {
                if x == 0 {
                    break;
                } else if x%10==3 {
                    print!(" {}", i);
                    break;
                } else {
                    x /= 10;
                }
            }
        }
    }
    println!("");
}

fn main() {
    let sin = io::stdin();
    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let n = buf.trim().parse::<u32>().unwrap();

    call(n);
}



Measured memory_bytes: 5024
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 

using namespace std; 


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

    set<long long> s;
    for(int i=0;i<n;i++){
        long long a;
        cin>>a;
        s.insert(a);
    }

    while(s.size()>1){
        long long a=(*s.begin());
        s.erase(a);
        long long b=(*s.begin());
        s.erase(b);
        //cout<<a<<" "<<b<<endl;

        if(b%a==0) s.insert(a);
        else s.insert(b%a),s.insert(a);
    }

    cout<<(*s.begin())<<endl;

    return 0;
}

Measured memory_bytes: 4992
n, k = map(int, input().split())
a = list(map(int, input().split()))


def ok(min_l):  # k回以内のカットで全てmin_l以下に出来るか？
    cnt = 0
    for L in a:

        # min_lが何本作れる？
        cnt += L // min_l
        # 割り切れない時、余った1本もcntに足す
        if L % min_l != 0:
            cnt += 1

        # 切る回数は、本数-1回
        cnt -= 1
    return cnt <= k

# 最初、leftはFalse, rightはTrue
# FFF...FFFTTT...TTT
# Tの左端の長さが欲しい

left = 0
right = max(a)

while right - left > 1:
    mid = (left + right) // 2
    if ok(mid):
        right = mid
    else:
        left = mid

print(right)


Measured memory_bytes: 30956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  rep(i,n){
    cin>>v.at(i);
  }
  sort(v.begin(), v.end(), greater<int>());
    int a=0,b=0;
    for(int j=0; j<n; j+=2){
      a+=v.at(j);
    }
  for(int k=1; k<n; k+=2){
    b+=v.at(k);
  }
   cout<<a-b<<endl;
}

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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	long A = sc.nextLong();
    long B = sc.nextLong();
    sc.close();

    int ans = -1;
    for (int i = 0; i <= 1000; i++) {
      int t8 = (int) (i * 0.08d);
      int t10 = (int) (i * 0.1d);
      if (t8 == A && t10 == B) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
N, A, B = map(int, input().split())
if bin(A).count("1")%2 == bin(B).count("1")%2:
    print("No")
    exit(0)

print("Yes")

ans = []
def solve(c, A, B, S):
    P = (A ^ B) & S
    b = 1
    if c == 1:
        ans.append(A)
        ans.append(B)
        return
    while not P & b:
        b <<= 1

    S0 = S ^ b
    k = 1
    while not S0 & k:
        k <<= 1
    C = A ^ k
    solve(c-1, A, C, S0)
    solve(c-1, C^b, B, S0)

solve(N, A, B, 2**N-1)
print(*ans)

Measured memory_bytes: 11320
import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


a, b, c, d = map(int, input().split())

c_multiple_last = b // c
d_multiple_last = b // d
cd_multiple_last = b // lcm(c, d)

c_multiple_first = (a-1) // c
d_multiple_first = (a-1) // d
cd_multiple_first = (a-1) // lcm(c, d)

c_count = c_multiple_last - c_multiple_first
d_count = d_multiple_last - d_multiple_first
cd_count = cd_multiple_last - cd_multiple_first

a_to_b_count = b - a + 1
ans = a_to_b_count - (c_count + d_count - cd_count)
print(ans)

Measured memory_bytes: 5048
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		char c[] = S.toCharArray();
		Set<Integer> se = new HashSet<Integer>();

		if (c[0] != 'A') {
			System.out.println("WA");
			return;
		}

		for (int i = 2; i < S.length() - 1; i++) {
			if (c[i] == 'C') {
				if (se.contains(1)) {
					System.out.println("WA");
					return;
				} else {
					se.add(1);
				}
			}
		}
		if(se.isEmpty()) {
			System.out.println("WA");
			return;
		}

		int a = 0;
		for (int i = 0; i < S.length(); i++) {
			if (Character.isUpperCase(c[i])) {
				a++;
			}
		}

		if (a != 2) {
			System.out.println("WA");
		} else {
			System.out.println("AC");
		}
	}
}


Measured memory_bytes: 22868
using DataStructures
f()=map(x->parse(Int,x),split(readline()))
function m()
	N,Q=f()
	P=FenwickTree(f())
	for _=1:Q
		t,l,r=f()
		if t==0
			inc!(P,l+1,r)
		else
			println(prefixsum(P,r)-(l<1 ? 0 : prefixsum(P,l)))
		end
	end
end
m()


Measured memory_bytes: 260564
#include <stdio.h>

int main() {
  int A, B, C;
  scanf("%d%d%d", &A, &B, &C);
  
  
  if(A + B == C)

  printf("Yes");

  else if(A + C == B)

  printf("Yes");

  else if(C + B == A)

  printf("Yes");

  else
  printf("No");
}

Measured memory_bytes: 128
N, K = map(int, input().split())
A, B, a = [0] * N, [0] * N, [''] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())
    a[i] = str(bin(A[i])[2:]).rjust(30, '0')
k = str(bin(K)[2:]).rjust(30, '0')

ans = 0

s = k.index('1') if '1' in k else 30
for r in range(s, 30 + 1):
    tmp = 0
    for i in range(N):
        if r < 30 and k[r] == '0':
            continue
        affordable = True
        for j in range(r):
            if k[j] == '0' and a[i][j] == '1':
                affordable = False
        if r < 30 and a[i][r] == '1':
            affordable = False
        if affordable:
            tmp += B[i]
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 70164