akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vll vector<ll>
#define mp make_pair
#define el cout<<"\n";
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);    cout.tie(NULL);
#define foor(i,a,b) for (ll i = (a); i < (b); ++i)
#define foo(i,a,b) for (ll i = (a-1); i >= (b); --i)
#define mem(ar,a)    memset(ar,a,sizeof(ar));

void seive()
{
    int isprime[1000001];
ll spf[1000001];
    spf[1]=1;
    ll n=1000000;
    mem(isprime,1);
    for(ll i=2;i<=n;i++)
    spf[i]=i;
    for(ll i=4;i<=n;i+=2)
    {
        spf[i]=2;
        isprime[i]=0;
    }
    for(ll i=3;i<=n;i+=2)
    {
        if(isprime[i])
        for(ll j=i*i;j<=n;j+=2*i)
        {
            isprime[j]=0;
            if(spf[j]==j)
            spf[j]=i;
        }
    }
}
 bool comp(pii a,pii b)
 {
    
     return a.first>b.first;
    
    }
 ll ex(ll n,ll ans)
{
    if(n==1)
    return ans;
  else  if(n%2)
    return (ans%((1000000007))*ex(n/2,(ans*ans)%(1000000007)))%(1000000007);
    else
    return ex(n/2,(ans*ans)%(1000000007));
}
ll kmp(string x,ll m)
{
      
      vector<ll> pi(m,0);
      pi[0]=0;ll ma=0;ll j=0;
      for(ll i=1;i<m;i++)
        {
        j=pi[i-1];
        while(j>0 && x[i]!=x[j])
        j=pi[j-1];
        if(x[j]==x[i])
        j++;
        pi[i]=j;
        }
        return j;
    }
    void dfs(vll adj[],int arr[],ll i,vector<pii > &h,ll parent[])
    {
    arr[i]=1;
        foor(j,0,adj[i].size())
        { 
            if(arr[adj[i][j]]==0)
            {
                h[adj[i][j]].first=h[i].first+1;
                h[adj[i][j]].second=adj[i][j];
                
                 
                 parent[adj[i][j]]=i;
                 dfs(adj,arr,adj[i][j],h,parent);
                
            }
        }
    }
  
int main()
{
    fast;
  ll t=1;
//cin>>t;string s;int n;
//map<ll,string> m; map<string,ll> k;
while(t--)
   {
       ll n,m;
       cin>>n>>m;
       ll s=0,a;
       foor(i,0,m)
       {
           cin>>a;
           s+=a;
       }
       if(n<s)
       cout<<"-1";
       else
       cout<<n-s;
   }
    
       
       
   }

Measured memory_bytes: 3664
<?php
$n = 0;
$k =0;
# 整数の入力
fscanf(STDIN, "%d %d", $n, $k);
# 文字列の入力
fscanf(STDIN, "%s", $s);

$array = str_split($s);

$array[$k-1] = strtolower($array[$k-1]);

echo implode("",$array);


Measured memory_bytes: 4728
N = gets.to_i
As, Bs = readlines.map{|l| l.split.map(&:to_i)}
B, M = 1007, 10**9 + 7

def mpow(x, n)
  ret = 1
  while n > 0
    if n.even?
      x = x * x % M
      n >>= 1
    else
      ret = ret * x % M
      n -= 1
    end
  end
  ret
end

P, N2 = mpow(B, N), 2*N
as, bs = [As, Bs].map{|a| a.cycle.each_cons(2).take(2*N).map{|x, y| x^y}}
ha, hb = Array.new(N2 + 1, 0), Array.new(N2 + 1, 0)
N2.times do |i|
  ha[i + 1] = (ha[i]*B + as[i]) % M
  hb[i + 1] = (hb[i]*B + bs[i]) % M
end
f = ->(h, i){(h[i + N] - h[i]*P) % M}
(0 ... N).each{|k| puts "#{k} #{As[k]^Bs[0]}" if f[ha, k] == f[hb, 0]}

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

int main()
{
	int n;
	cin >> n;
	bool suc = false;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (n == i * j) {
				suc = true;
			}
		}
	}
	cout << (suc ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#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=gets.to_i
A=get_nsp
B=get_nsp
C=get_nsp
ans=0
N.times do|i|
  m={}
  m[A[i]]=1
  m[B[i]]=1
  m[C[i]]=1
  ans+=m.size-1
end
puts ans

Measured memory_bytes: 3836
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

res = [0]*(n+1)
for i in range(n+1):
  res[i] = abs(a[i]-a[i+1])
  
t = sum(res)
for i in range(1, n+1):
  ans = t - (res[i-1]+res[i]) + abs(a[i-1]-a[i+1])
  print(ans)

Measured memory_bytes: 20572
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int const none = 999999;


bool aaa(
    int const margin,
    size_t const bef_pos,
    string const& old,
    string::const_iterator c,
    string::const_iterator end
    )
{
    for( size_t i=0; i<old.size(); ++i ) {
        if ( old[i] == *c ) {
            int const m = i - bef_pos;
            if ( m < 0 )
                continue;

            string::const_iterator const c_next = c + 1;

            if ( ( margin == none ) || ( margin == m ) ) {
                if ( c_next == end ) {
                    return true;
                } else {
                    if ( aaa( m, i, old, c_next, end ) ) {
                        return true;
                    }
                }
            }
        }
    }

    return false;
}


bool aaa(
    string const& old,
    string::const_iterator c,
    string::const_iterator end
    )
{
    for( size_t i=0; i<old.size(); ++i ) {
        if ( old[i] == *c ) {
            if ( aaa( none, i, old, c + 1, end ) ) {
                return true;
            }
        }
    }

    return false;
}



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

    string name;
    cin >> name;

    int num = 0;
    for( int i=0; i<n; ++i ) {
        string s;
        cin >> s;

        if ( aaa( s, name.begin(), name.end() ) ) {
            ++num;
        }
    }

    cout << num << endl;
}

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

int N,K;
vector<int>d;
vector<vector<int>>A;

void input(){
  cin>>N>>K;
  d.resize(K);
  A.resize(K, vector<int>());
  for (int i=0; i<K; i++){
    cin>>d[i];
    A[i].resize(d[i]);
    for (int j=0; j<d[i]; j++){
      cin>>A[i][j];
    }
  }
}
void solve(){
  int ans=0;
  for(int i=1;i<=N;i++){
    bool have=false;
    for(auto v:A){
      for(auto p:v){
        if (p==i)have=true;
      }
    }
    if(!have) ans++;
  }
  cout<<ans<<endl;
}
int main(){
  input();
  solve();
  return 0;
}

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

int main(){
	int a,b,i;
    char op;

	while(1){
		cin>>a>>op>>b;
		if(op=='+'){
			i=a+b;
		    cout<<i<<endl;
		}
		else if(op=='-'){
			i=a-b;
			cout<<i<<endl;
		}
		else if(op=='*'){
			i=a*b;
			cout<<i<<endl;
		}
		else if(op=='/'){
			i=a/b;
			cout<<i<<endl;
		}
		if(op=='?'){
			break;
		}

	}

	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int N;
	static int x[100010];
	static int L;
	static int Q;
	static int a[100010],b[100010];
	scanf("%d",&N);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%d",&x[i]);
	}
	scanf("%d%d",&L,&Q);
	for(int i = 1 ; i <= Q ; i ++){
		scanf("%d%d",&a[i],&b[i]);
		if(a[i] > b[i])swap(a[i],b[i]);
	}
	
	x[N+1] = x[N]+1;
	
	static int nex[100010][20];
	for(int i = 1 ; i <= N+1 ; i ++){
		nex[i][0] = ( upper_bound(x+i,x+N+2,x[i]+L) - x ) - 1;
	}
	for(int j = 1 ; j <= 19 ; j ++){
		for(int i = 1 ; i <= N+1 ; i ++){
			nex[i][j] = nex[nex[i][j-1]][j-1];
		}
	}
	
	for(int loop = 1 ; loop <= Q ; loop ++){
		int loc = a[loop];
		int ret = 0;
		for(int j = 19 ; j >= 0 ; j --){
			if(nex[loc][j] <= b[loop]){
				loc = nex[loc][j];
				ret += 1 << j;
			}
		}
		if(loc < b[loop])ret ++;
		printf("%d\n",ret);
	}
}



Measured memory_bytes: 9856
#include<bits/stdc++.h>
#define N 3009
using namespace std;

int n,tot,a[N],fst[N],pnt[N],nxt[N],q[N]; bool ok[N];
void add(int x,int y){
	pnt[++tot]=y; nxt[tot]=fst[x]; fst[x]=tot;
}
bool cmp(int x,int y){ return a[x]<a[y]; }
int main(){
	scanf("%d",&n);
	int i,j,x,y;
	for (i=1; i<=n; i++) scanf("%d",&a[i]);
	for (i=1; i<n; i++){
		scanf("%d%d",&x,&y);
		if (a[x]<a[y]) swap(x,y);
		if (a[x]>a[y]) add(x,y);
	}
	for (i=1; i<=n; i++) q[i]=i;
	sort(q+1,q+n+1,cmp);
	for (i=1; i<=n; i++){
		x=q[i];
		for (j=fst[x]; j; j=nxt[j]) if (!ok[pnt[j]]) break;
		ok[x]=(j>0);
	}
	for (i=1; i<=n; i++)
		if (ok[i]) printf("%d ",i);
	puts("");
	return 0;
}


Measured memory_bytes: 256
n,k = map(int, input().split())
l = [0] + list(map(int, input().split()))
a = list()
for i in range(n):
  l[i+1] += l[i]
a = [l[j]-l[i] for i in range(n) for j in range(i+1,n+1)]
x = 0
for i in range(40,-1,-1):
  t = 2**i
  b = list(filter(lambda y: y&(t+x) == (t+x),a))
  if len(b) >= k:
    a = b
    x += t
print(x)

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

const int maxn = 2e5+5;
int N, K, P[maxn];
int a[maxn];

int inc[maxn];

int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    inc[0] = 1;
    for (int i = 1; i < N; i++) {
        if (P[i] > P[i-1]) {
            inc[i] = inc[i-1] + 1;
        }
        else inc[i] = 1;
        //cout << i << ": " << inc[i] << '\n';
    }
    set<int> s;
    int ans = 0;
    int numSorted = 0;

    if (inc[K-1] >= K) numSorted++;
    else ans++;

    for (int i = 0; i < K; i++) {
        s.insert(P[i]);
    }
    for (int i = 0; i + K < N; i++) {
        if (inc[i+K] >= K) {
            numSorted++;
        }
        else {
            /*
            cout << "set: ";
            for (int j: s) {
                cout << j << ' ';
            }
            cout << '\n';
            printf("P[i] = %d, min = %d, max = %d, P[i+K] = %d\n",P[i],*s.begin(),P[i+K],*s.rbegin());
            */
            if (P[i] <= *s.begin() && P[i+K] > *s.rbegin()) {

            }
            else {
                ans++;
            }
        }
        s.erase(P[i]);
        s.insert(P[i+K]);
        //cout << i << ": " << ans << ' ' << numSorted << '\n';
    }
    if (numSorted > 0) ans++;
    cout << ans << '\n';
    /*
    for (int i = 0; i + K <= N; i++) {
        for (int j = 0; j < N; j++) {
            a[j] = P[j];
        }
        sort(a+i,a+i+K);
        for (int j = 0; j < N; j++) {
            cout << a[j] << ' ';
        }
        cout << '\n';
    }
    */
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int ret = 0;
    x -= z;
    ret = x / (y + z);
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int M;
	cin >> M;
	printf("%d\n", 24 + (24 - M));
	return 0;
}

Measured memory_bytes: 3772
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;
mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;
#[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
#[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where
        <T as FromStr>::Err: Debug,
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse().unwrap())
                .collect()
        }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { println ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }

fn main() {
    let (n, y) = get!(usize, usize);

    let y = y / 1000;

    for a in 0..n+1 {
        if 10 * a > y {
            break;
        }

        let rest = y - 10 * a;

        for b in 0..n+1-a {
            if 10 * a + 5 * b > y {
                break;
            }

            let c = n - a - b;

            if 10*a + 5 * b + c == y {
                println!("{} {} {}", a, b, c);
                return;
            }

        }
    }

    println!("-1 -1 -1");
}


Measured memory_bytes: 4352
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define repd(i,x,y) for(int i=x; i>=y; --i)

using namespace std;
const int N=1<<18,mod=998244353;
typedef long long LL;
const LL inv2=(mod+1)/2;
int n;
LL tot,p[N],f[N],_f[N];
LL L[N],R[N],_L[N],_R[N],ans[N];

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

LL getmi(LL a,LL x)
{
    LL rt=1;
    while(x)
    {
        if(x&1) rt=rt*a%mod;
        a=a*a%mod,x>>=1;
    }
    return rt;
}

void FWT(LL a[],LL n)
{
    for(LL i=1; i<n; i<<=1)
        for(LL j=0; j<n; j+=i<<1)
            rep(k,0,i-1)
            {
                LL x=a[j+k],y=a[i+j+k];
                a[j+k]=(x+y)%mod,a[i+j+k]=(x-y)%mod;
            }
}

void IFWT(LL a[],LL n)
{
    for(LL i=1; i<n; i<<=1)
        for(LL j=0; j<n; j+=i<<1)
            rep(k,0,i-1)
            {
                LL x=a[j+k],y=a[i+j+k];
                a[j+k]=inv2*(x+y)%mod;
                a[i+j+k]=inv2*(x-y)%mod;
            }
}

int main()
{
	n=getint();
	rep(i,0,(1<<n)-1) tot+=(p[i]=getint());
	tot=getmi(tot,mod-2);
	rep(i,0,(1<<n)-1) p[i]=p[i]*tot%mod;
	FWT(p,1<<n);

	rep(i,0,(1<<n)-1) L[i]=R[i]=1-p[i];
	rep(i,1,(1<<n)-1) L[i]=L[i]*L[i-1]%mod;
	repd(i,(1<<n)-2,0) R[i]=R[i]*R[i+1]%mod;

	rep(i,0,(1<<n)-1)
	{
		LL x=1;
		if(i>0) x=L[i-1],_L[i]=_L[i-1]*(1-p[i])%mod;
		_L[i]=(_L[i]+x*(-p[i]))%mod;
	}

	repd(i,(1<<n)-1,0)
	{
		LL x=1;
		if(i<(1<<n)-1) x=R[i+1],_R[i]=_R[i+1]*(1-p[i])%mod;
		_R[i]=(_R[i]+x*(-p[i]))%mod;
	}

	rep(i,0,(1<<n)-1)
	{
		LL l=i>0?L[i-1]:1;
		LL _l=i>0?_L[i-1]:0;
		LL r=i<(1<<n)-1?R[i+1]:1;
		LL _r=i<(1<<n)-1?_R[i+1]:0;
		f[i]=l*r%mod,_f[i]=(l*_r+_l*r)%mod;
	}
	
	IFWT(f,1<<n),IFWT(_f,1<<n);
	rep(i,0,(1<<n)-1)
	{
		LL x=(_f[i]*f[0]-f[i]*_f[0])%mod;
		LL y=getmi(f[0]*f[0]%mod,mod-2);
		ans[i]=(x*y%mod+mod)%mod;
		printf("%lld\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 19072
import sys
import math


def main():
    a, b, x = [int(s) for s in sys.stdin.readline().strip().split()]
    # a, b, x = 2, 2, 4
    # a, b, x = 12, 21, 10
    # a, b, x = 3, 1, 8

    half = a * b / 2
    xs = x / a

    def b_search(target, amax, hen):
        amin = 0.0
        t = amax
        s = hen * t / 2
        while abs(s - target) > 0.0000000001:
            if s > target:
                amax = t
                t = (t + amin) / 2
            else:
                amin = t
                t = (t + amax) / 2
            s = hen * t / 2
        return t

    if half < xs:
        should_removed = a * b - xs
        t = b_search(should_removed, b, a)
        cos2r = a * a / (t * t + a * a)
    else:
        t = b_search(xs, a, b)
        cos2r = t * t / (t * t + b * b)
    cosr = math.sqrt(cos2r)
    ans = math.degrees(math.acos(cosr))
    print(ans)


main()



Measured memory_bytes: 38256
#include <queue>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    priority_queue<pair<int, int> > pq;
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        if (a[i] > b[i]) { cout << "-1\n"; return 0; }
        if (a[i] < b[i]) pq.push({b[i], i});
    }
    long long ans = 0;
    while (!pq.empty()) {
        int i = pq.top().second;
        pq.pop();
        int l = (i+n-1)%n, r = (i+1)%n;
        if (b[l] + b[r] > b[i] - a[i]) { cout << "-1\n"; return 0; }
        int k = (b[i] - a[i]) / (b[l] + b[r]);
        ans += k;
        b[i] -= k * (b[l] + b[r]);
        if (a[i] < b[i]) pq.push({b[i], i});
    }
    cout << ans << endl;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main()
{

long long a,b,c,d,e,i,j,k=0,l=0;
map<long long,long long>p;
vector<long long>v;
cin>>a;
for(i=1;i<=a;i++)
{
 cin>>c;p[c]++;
if(p[c]==1)v.push_back(c);

}
for(i=0;i<v.size();i++)
{
k=v[i];
 l=max(l,(p[k]+p[k-1]+p[k+1]));
}


cout<<l<<endl;
}

Measured memory_bytes: 6648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*d,max(a*c,max(b*c,b*d)))<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#define MAX 102

int main(){
  int n,i,j;
  int M[MAX][MAX];
  int num1,x,num2;
  
  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ )
      M[i][j] = 0;
  }
  
  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d",&num1,&x);
    for( j = 0 ; j < x ; j++ )
      {
	scanf("%d",&num2);
	M[num1-1][num2-1] = 1;
      }
  }

    for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n-1 ; j++ )
      printf("%d ",M[i][j]);
    printf("%d\n",M[i][j]);
  }
  
  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, res = 0;
	cin >> n;
	vector<int> a(n), b(n), c(n - 1);
	rep (i, n) cin >> a[i];
	rep (i, n) {
	  int b;
	  cin >> b;
	  res += b;
	}
	rep (i, n - 1) cin >> c[i];
	rep (i, n - 1) {
	  if (a[i + 1] - a[i] == 1) res += c[a[i] - 1];
	}
	cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3584
use proconio::input;

fn prime_factorization(n: usize) -> Vec<(usize, usize)> {
    let mut p = vec![];
    if n < 2 {
        return p;
    }
    let mut n = n; // shadowing
    for i in 2.. {
        if i * i > n {
            break;
        }
        let mut c = 0;
        while n % i == 0 {
            c += 1;
            n /= i;
        }
        if c > 0 {
            p.push((i, c));
        }
    }
    if n != 1 {
        p.push((n, 1));
    }
    p
}

fn main() {
    input! {
        n: u64,
    };
    let pq = prime_factorization(n as usize);
    let mut count = 0;
    for &(_, q_i) in pq.iter() {
        let mut c = 0;
        for i in 1.. {
            c += i;
            if c > q_i {
                break;
            }
            count += 1;
        }
    }
    let ans = count;
    println!("{}", ans);
}


Measured memory_bytes: 2096
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,0,n){
        cin >> a[i];
    }
    vector<map<ll,ll>> dp(n+1);
    dp[0][0] = 1000;
    rep(i,0,n){
        for(auto x: dp[i]){
            ll j = x.first;
            ll m = x.second;
            ll p = m/a[i];
            chmax(dp[i+1][j+p],m-p*a[i]);
            chmax(dp[i+1][0],m+j*a[i]);
            chmax(dp[i+1][j],m);
        }
    }
    cout << dp[n][0] << endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;
#define debug(x) cerr << #x << ": " << (x) << "\n";

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

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

  string s;
  cin >> s;
  string ans = "";
  rep(i, 0, s.size()) {
    if (i % 2 == 0) {
      ans += s[i];
    }
  }

  cout << ans << endl;

  return 0;
};


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

int main(){
    int n; string s; cin >> n >> s;
    int x = 0;
    int m = 0;
    rep(i,n){
        if(s[i] == 'D'){
            x--;
        }else{
            x++;
        }

        m = max(m,x);
    }
    cout << m;
}


Measured memory_bytes: 256
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll k, n, s = 0;
    cin >> n >> k;
    vector<ll> p(n);
    for (ll &e : p)
        cin >> e;
    sort(p.begin(), p.end());
    for (ll i = 0; i < k; i++)
        s += p[i];
    cout << s;
}

Measured memory_bytes: 3660
class UnionFind:
    def __init__(self, data):
        self.parent = {}
        self.rank = {}
        for i in range(1, data+1):
            self.parent[i] = i
            self.rank[i] = 0

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)


    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.find(x) == self.find(y):
            return
        if self.rank[x] > self.rank[y]:
            self.parent[y] = x
            return
        else:
            self.parent[x] = y
            if self.rank[x] == self.rank[y]: self.rank[y] += 1
            return


N, M = map(int, input().split())
P = list(map(int, input().split()))
L = []
for i in range(M):
    L.append([int(x) for x in input().split()])

tree = UnionFind(N)
for i in range(M):
    tree.unite(P[L[i][0]-1], P[L[i][1]-1])

ans = 0
for i in range(N):
    if tree.same(P[i], i+1):
        ans += 1

print(ans)

Measured memory_bytes: 45988
h,w,k=map(int,input().split())
S=[]
for i in range(h):
    s=int(input(),2)
    S.append(s)
ans=h+w-2
for i in range(2**(h-1)):
    flag=False
    now=0 #区切った数
    cnt=0 #1の数
    y=0
    for j in range(h-1):
        if (i>>j)&1:
            y+=1
    C=[0]*(y+1) #1の数保存配列
    for x in range(w):
        T=[] #現在の列での1の数保存配列
        for j in range(h):      
            cnt+=(S[j]>>x)&1
            if cnt>k:
                flag=True
                break
            if (i>>j)&1: #横の区切り判定
                T.append(cnt)
                cnt=0
            if j==h-1: #最後の列
                T.append(cnt)
                cnt=0
        if flag:
            break
        for j in range(len(C)): #それぞれのブロックに対して
            if C[j]+T[j]>k:
                now+=1
                C=T
                break
            else:
                C[j]+=T[j]
    if flag:
        continue
    ans=min(ans,now+y)
print(ans)

Measured memory_bytes: 47196
#include <cstdio>
#include <iostream>
#include <stdlib.h>

using namespace std;

namespace {

struct Node {
  char suit; // S, H, C, D
  int value;
};

// SelectionSort sorts the array |a| in ascending order, and then returns
// the number of swap operations.
int SelectionSort(Node* a, int n) {
  int nswap = 0;

  for (int i = 0; i < n; ++i) {
    int minj = i;
    for (int j = i + 1; j < n; ++j) {
      if (a[j].value < a[minj].value) {
        minj = j;
      }
    }
    if (i != minj) {
      ++nswap;
      const Node t = a[i];
      a[i] = a[minj];
      a[minj] = t;
    }
  }

  return nswap;
}

// BubbleSort sorts the array |a| in ascending order, and then returns
// the number of swap operations.
int BubbleSort(Node* a, int n) {
  int nswap = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = n - 1; j >= 1; --j) {
      if (a[j].value < a[j - 1].value) {
        const Node t = a[j - 1];
        a[j - 1] = a[j];
        a[j] = t;
        ++nswap;
      }
    }
  }
  return nswap;
}

void Print(const Node* a, int n) {
  for (int i = 0; i < n; ++i) {
    if (i > 0) printf(" ");
    printf("%c%d", a[i].suit, a[i].value);
  }
  printf("\n");
}

bool IsStable(const Node* a, const Node* b, int n) {
  for (int i = 0; i < n; ++i) {
    if (a[i].value == b[i].value && a[i].suit != b[i].suit) {
      return false;
    }
  }
  return true;
}

} // namespace

int main() {
  int n;
  cin >> n;
  Node in[36];
  Node a[36];
  Node b[36];

  char buf[4];
  for (int i = 0; i < n; ++i) {
    cin >> buf;
    in[i].suit = buf[0];
    in[i].value = atoi(&buf[1]);
    a[i] = in[i];
    b[i] = in[i];
  }

  BubbleSort(a, n);
  Print(a, n);
  printf("Stable\n");

  SelectionSort(b, n);
  Print(b, n);
  if (IsStable(a, b, n)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }
  return 0;
}

Measured memory_bytes: 1164
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int N;
	vector<int> l;
	cin >> N;
	for(int i=0;i<2*N;i++){
		int v;
		cin >> v;
		l.push_back(v);
	}
	sort(l.begin(),l.end());
	int ret=0;
	for(int i=0;i<2*N;i+=2){
		ret+=l[i];
	}
	cout << ret << endl;
}


Measured memory_bytes: 256
#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>;

ll lcm(ll x, ll y){
    return x / __gcd(x, y) * y;
}

int main() {
    int n;
    cin >> n;
    ll pre = 1;
    rep(i,n) {
        ll x;
        cin >> x;
        pre = lcm(pre, x);
    }
    cout << pre << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,x,m[110],ans = 0,count = 0;
    cin >> n >> x;
    for(int i = 0;i < n;i++)
    {
        cin >> m[i];
        ans += m[i];
        count++;
    }
    sort(m,m + n);

    for(;;)
    {
        if(ans + m[0]  <= x){ans += m[0]; count++;}
        else{break;}
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
   ios::sync_with_stdio(false);
   string S, T;
   cin >> S >> T;
   cout << T << S << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+100;
#define ll long long

vector<int> a;

void solve(){
    int n,k;
    scanf("%d%d",&n,&k);
    int maxn=0;
    for(int i=0;i<k;i++){
        int m;
        scanf("%d",&m);
        a.push_back(m);
        if(i)maxn=max(maxn,m-a[i-1]);
    }
    maxn=max(maxn,n-a[k-1]+a[0]);
    sort(a.begin(),a.end());
    cout<<min(a[k-1]-a[0],n-maxn)<<endl;
}

int main(){
    solve();
}


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

using namespace std;

#define ll long long

signed main(void) {
    ll n;
    cin >> n;
    ll div5 = 0LL;
    if(n%2LL==1LL){
        cout << 0LL << endl;
        return 0;
    }
    for(ll i=1LL;;i++){
        // ll temp = pow(5LL,i);
        long double temp = n/pow((long double)5,i);

        // if(temp>n) break;
        if(temp<(long double)1) break;

        // div5 += n/temp/2LL;
        div5 += floor(temp/2LL);
    }
    cout << div5 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define ll long long
    using namespace std;
    int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    ll d = abs(b + c) / 2;
    ll e = abs(a - c);
    ll f = abs(b - 1);
    ll g = min(e, f);
    if(b % 2 != 0 && c % 2 != 0 || b % 2 == 0 && c % 2 == 0){
        cout << c - d;
    }
    else{
        cout << g + (c - d);
    }





    return 0;
    }


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
const int N=200000+10;
bool sw(int a,int b){
    return a>b;
}
int main()
{
    long long sum=0;
    long long a[N];
    int n,m;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n,sw);
    sum=a[0];
    for(int i=2;i<n;i++){
            m=i/2;
    sum+=a[m];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4780
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    Ans = 1000000000000000000000
    for i in range(1, N + 1):
        if i ** 2 > N: break
        if N % i == 0:
            di, dj = i, N // i
            Ans = min(Ans, di + dj - 2)
    print(Ans)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 10005
#define MAX_E 30005
#define NIL -1
#define WHITE 0
#define BLACK 1
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

class Edge {
    ll t, w;
    Edge(ll t, ll w): t(t), w(w) {}
};

int main(void) {
    ll N, i;
    string s;
    cin >> N;
    cin >> s;
    ll cntl=0, cntr=0;
    stack<char> stk;
    for(i=0; i<N; i++) {
        if(s[i]==')' && stk.size()==0) {
            cntl++;
        }else if(s[i]==')' && stk.size()!=0) {
            stk.pop();
        }else if(s[i]=='(') {
            stk.push(s[i]);
        }
    }
    cntr=stk.size();
    
    for(i=0; i<cntl; i++) {
        s='('+s;
    }
    for(i=0; i<cntr; i++) {
        s+=')';
    }
    
    cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=102,MAX_W=100002;

ll dp[MAX_N][MAX_W];
int N; ll W;
ll w[MAX_N],v[MAX_N];

void calc(){
  fill(dp[0],dp[N+1],0);
  rep(i,N){
    rep(j,W+1){
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
      if(j+w[i]<=W){
        dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
      }
    }
  }
  return;
}

int main(){
  cin >> N >> W ;
  ll temp=0;
  int N2=0;
  rep(i,N){
    ll a,b;
    scanf("%lld%lld",&a,&b);
    if(a<=W){
      N2++;
      w[i]=a; v[i]=b;
      temp=max(temp,a);
    }
  }
  if(N2==0){
    cout << "0" << endl;
    return 0;
  }
  N=N2;
  if(W<MAX_W-2){
    calc();
    printf("%lld\n",dp[N][W]);
  }else{
    W=W/10000+W%100;
    //cout << W << endl;
    rep(i,N){
      w[i]=w[i]/10000+w[i]%100;
      //cout << w[i] << endl;
    }
    if(W<MAX_W-2){
      calc();
      printf("%lld\n",dp[N][W]);
    }else{
      ll S=0;
      rep(i,N) S+=v[i];
      printf("%lld\n",S);
    }
    // sort(v,v+N);
    // reverse(v,v+N);
    // ll S=0;
    // rep(i,min(W,(ll)N)){
    //   S+=v[i];
    // }
    // printf("%lld\n",S);
  }

  return 0;
}


Measured memory_bytes: 79104
n = gets.to_i
people = n.times.map do
  a = gets.to_i
  a.times.map do
    x, y = gets.split.map &:to_i
    [x-1, y]
  end
end

max = 0
(1 << n).times do |c|
  test = [nil] * n
  if n.times.all? { |i|
    next true if c[i] == 0
    people[i].all? { |(x, y)|
      next false if test[x] and test[x] != y or c[x] != y
      test[x] = y
      true
      }
    }
    #p c.to_s(2).rjust n
    cnt = n.times.count { |i| c[i] == 1 }
    max = [max, cnt].max
  end
end

p max

Measured memory_bytes: 14208
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    N = int(input().rstrip())
    ANS = INF
    for i in range(1,N):
        ANS = min(ANS,sum(list(map(int, str(i)))) + sum(list(map(int, str(N - i)))))
    print(ANS)    

if __name__ == '__main__':
    solve()


Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  using T = tuple<int, int, int>;
  using P = pair<int, int>;

  int n, q;
  cin >> n >> q;

  vector<T> a(n);
  rep(i, n) {
    int s, t, x;
    cin >> s >> t >> x;
    s -= x;
    t -= x;
    a[i] = tie(s, t, x);
  }
  vector<int> d(q);
  set<P> se;
  rep(i, q) {
    cin >> d[i];
    se.insert({d[i], i});
  }

  sort(all(a), [](const T& l, const T& r) { return get<2>(l) < get<2>(r); });

  vector<int> ans(q, -1);

  rep(i, n) {
    int l, r, x;
    tie(l, r, x) = a[i];
    cerr << l << " " << r << " " << x << endl;

    auto it = se.lower_bound({l, 0});
    while (it != se.end() && it->first < r) {
      ans[it->second] = x;
      se.erase(it++);
    }
  }

  rep(i, q) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 16000
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
int C;
int D[30][30];
int cost[3][30];
int main(){
  int c, i, j, k, res=1073709056, x, y;
  rd(N);
  rd(C);
  for(i=0;i<(C);i++){
    {
      int Lj4PdHRW;
      for(Lj4PdHRW=0;Lj4PdHRW<(C);Lj4PdHRW++){
        rd(D[i][Lj4PdHRW]);
      }
    }
  }
  for(x=0;x<(N);x++){
    for(y=0;y<(N);y++){
      rd(c);c += (-1);
      k = (x+y)%3;
      for(i=0;i<(C);i++){
        cost[k][i] += D[c][i];
      }
    }
  }
  for(i=0;i<(C);i++){
    for(j=0;j<(C);j++){
      for(k=0;k<(C);k++){
        if(i==j || i==k || j==k){
          continue;
        }
        chmin(res, cost[0][i] + cost[1][j] + cost[2][k]);
      }
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190902-1

// --- original code ---
// int N, C;
// int D[30][30];
// int cost[3][30];
// {
//   int i, j, k, c, x, y;
//   int res = int_inf;
//   rd(N,C);
//   rep(i,C) rd(D[i](C));
//   rep(x,N) rep(y,N){
//     rd(c--);
//     k = (x+y)%3;
//     rep(i,C) cost[k][i] += D[c][i];
//   }
// 
//   rep(i,C) rep(j,C) rep(k,C){
//     if(i==j || i==k || j==k) continue;
//     res <?= cost[0][i] + cost[1][j] + cost[2][k];
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

n,m = l_in()
A = l_in()
s = sum(A)

if len(list(filter(lambda a: 4*m*a >= s, A))) >= m:
    print('Yes')
else:
    print('No')


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

int main(){
	int N, numRemainingBrick = 1, answer = 0;
	cin >> N;
	for(int i = 0; i < N; i++){
		int a;
		cin >> a;
		if(numRemainingBrick == a){
			numRemainingBrick++;
			continue;
		}
		answer++;
	}
	if(answer == N)	answer = -1;
	cout << answer << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  string s[2];
  cin >> s[0] >> s[1];
  reverse(ALL(s[0]));
  if(s[0] == s[1])cout << "YES" << endl;
  else cout << "NO" << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m;
    cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);
    for(int i = 0;i < n;i++) {
        cin >> a.at(i);
    }
    for(int i = 0;i < m;i++) {
        cin >> b.at(i);
    }
    bool exist = false;
    for(int i_a = 0;i_a < n;i_a++){
        for(int j_a = 0;j_a < n;j_a++){
            if(i_a + m - 1 >= n || j_a + m - 1 >= n) {
                continue;
            }
            bool match = true;
            for(int i_b = 0;i_b < m;i_b++){
                for(int j_b = 0;j_b < m;j_b++){
                    if(a.at(i_a + i_b).at(j_a + j_b) != b.at(i_b).at(j_b)) {
                        match = false;
                    }
                }
            }
            if(match) {
                exist = true;
            }
        }
    }
    if(exist)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])

ans = 0 
for i in range(n + 1):
    if a[i] > k:
        break
    while  a[i] + b[m] > k:
        m -= 1
    ans = max(ans, i + m)
print(ans)

Measured memory_bytes: 47508
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int table[26];

signed main()
{
    string s,t; cin>>s>>t;

    REP(i,26) table[i]=-1;

    bool ok=true;
    REP(i,s.size()){
        if(table[s[i]-'a']==-1){
            table[s[i]-'a']=t[i]-'a';
        }
        else if(table[s[i]-'a']!=t[i]-'a'){
            ok=false;
        }
    }
/*
    REP(i,26){
        cout<<(char)('a'+i)<<"->"<<(char)('a'+table[i])<<endl;
    }
*/
    REP(i,26){
        if(count(table,table+26,i)>1) 
            ok=false;
    }
    cout<<(ok? "Yes":"No")<<endl;
    
}


Measured memory_bytes: 776