akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int N, K;
    cin >> N >> K;
    vector<double> pro(N);
    Rep(i, N) {
        int p;
        cin >> p;
        pro[i] = (double)(p + 1) / 2;
    }
    double ans = 0;
    Rep(i, K) {
        ans += pro[i];
    }
    double x = ans;
    for (int i = K; i < N; i++) {
        x += pro[i] - pro[i - K];
        ans = max(ans, x);
    }
    printf("%.6f\n", ans);
    return 0;
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let n: usize = read();
    let v = read_vec::<u32>();

    let mut ans = 1;
    let mut maxi = v[0];
    for i in 1..n {
        if v[i] >= maxi {
            ans += 1;
        }
        maxi = std::cmp::max(maxi, v[i]);
    }
    println!("{}", ans);
}


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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;

ll dp[110][10];

int main()
{
    int h,w,k;
    cin >> h >> w >> k;
    dp[0][0]=(ll)1;
    for (int  i = 0; i < h; i++)
    {
        //高さiの横棒について考えるi->i+1の流れ
        rep(j, 1 << (w-1))
        {
            bool flag = true;
            rep(l, w-1)
            {
                if(l==0)continue;
                if (j & (1 << l))
                {
                    if (j & (1 << (l-1)))
                    {
                        flag = false;
                    }
                }
            }
            if(flag)
            {
                rep(l,w)
                {
                    if(l-1>=0)
                    {
                        if (j & (1 << (l-1)))
                        {
                            dp[i+1][l-1]+= dp[i][l];
                            continue;
                        }
                    }
                    if(l<=w-2)
                    {
                        if (j & (1 << l))
                        {
                            dp[i+1][l+1] += dp[i][l];
                            continue;
                        }
                    }
                    dp[i+1][l]+= dp[i][l];
                }
                
            }

        }
        for (int index = 0; index < w; index++)
        {
            dp[i + 1][index] %= MOD;
        }
    }
    cout << dp[h][k-1] << endl;
    
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  ll x;
  cin>>x;
  ll ans;
  if(x % 11 == 0) {
    ans = x / 11 * 2;
  } else if(x % 11 <= 6) {
    ans = x / 11 * 2 + 1;
  } else {
    ans = x / 11 * 2 + 2;
  }
  cout << ans << endl;

  return 0;
}


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

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

        int N = scanner.nextInt();
        Set<Integer> set = new HashSet<>();
        for (int i = 0 ; i < N ; i++) {
            set.add(scanner.nextInt());
        }

        if (set.size() == N) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }
}


Measured memory_bytes: 69840
import sys
input = sys.stdin.buffer.readline

class UnionFind:
    __slots__ = ["num", "data"]
    
    def __init__(self, n=0):
        self.num = n
        self.data = [-1]*(n+1)
    
    def root(self, x):
        if self.data[x] < 0:
            return x
        self.data[x] = self.root(self.data[x])
        return self.data[x]
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.data[x] < self.data[y]:
                self.data[x] += self.data[y]
                self.data[y] = x
            else:
                self.data[y] += self.data[x]
                self.data[x] = y
    
    def same(self, x, y):
        return self.root(x) == self.root(y)
    
    def size(self, x):
        return -self.data[self.root(x)]
    
    def sizes(self):
        return [-self.data[self.root(i)] for i in range(self.num+1)]
                


def main():
    n, m, k = map(int, input().split())
    fb = [0]*(n+1)
    uf = UnionFind(n)
    for _ in range(m):
        a, b = map(int, input().split())
        fb[a] += 1
        fb[b] += 1
        uf.unite(a, b)
    for _ in range(k):
        c, d = map(int, input().split())
        if uf.same(c, d):
            fb[c] += 1
            fb[d] += 1
    size = uf.sizes()
    ans = [size[i]-1-fb[i] for i in range(1, n+1)]
    print(" ".join(list(map(str, ans))))


if __name__ == "__main__":
    main()

Measured memory_bytes: 19544
#include <bits/stdc++.h>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forv(i,m,n) for (int i=(m); i>=(n); i--)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define R 1000000007
#define DBG 1
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;

#define MAXN 100002
int a[MAXN];

vector< vector<int> > dst;

int dep(int v) {
  if (dst[v].size()==0) return 0;
  vector<int> a;
  for(auto u: dst[v]) a.push_back(dep(u));
  sort(a.begin(),a.end());
  int mx = 0;
  int m = a.size();
  forr(i,0,m-1) mx = max(mx, a[i]+m-i);
  return mx;
}

int main() {
  int n,x;
  cin >> n;
  dst.resize(n+1);
  forr(i,2,n) {
    cin >> x;
    dst[x].push_back(i);
  }
  cout << dep(1) << endl;
}


Measured memory_bytes: 13568
#include <iostream>

using namespace std;

int main()
{
   int i, h, m, s;     
   cin >> i;
   h = i / 3600;
   m= i /60 - h * 60  ;
   s=i % 60;
   cout << h <<":"<< m <<":"<< s << endl;
   
   
   return 0;
}



Measured memory_bytes: 3076
from sys import stdin
from math import ceil
readline = stdin.readline


def nl():
    """
    空白区切り行入力を`int iter`に変換
    """
    return map(int, readline().split())


def main():
    n, d = nl()
    res = ceil(n / (d * 2 + 1))
    print(res)


if __name__ == "__main__":
    main()


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

int main(){
    string s;
    int count = 0;
    cin >> s;

    for(int i = 0; i < 4; i++){
        if(s.at(i) == '+'){
            count += 1;
        }else if(s.at(i) == '-'){
            count -= 1;
        }
    }
    cout << count << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

ll N, x;

ll gcd(ll x, ll y) {
  if(y == 0) return x;

  return gcd(y, x % y);
}

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

  cout << 3 * (N - gcd(N,x)) << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int solveit(int n){
  int z = 0;
  while (n%2==0){
    n /= 2;
    z += 1;
  }
  return z;
}
int main(){
  int k,i,a,ans;
  cin >> k;
  for(i=0;i<k;i++){
    cin >> a;
    ans += solveit(a);
  }
  cout << ans << endl;
}
 

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

m= int(input())
dc=[]
s=0
for i in range(m):
    dc.append(list(map(int,input().split())))
    s+=dc[i][0]*dc[i][1]


ans=s//9

for i in range(m):
    ans+=dc[i][1]

if s%9==0:
    ans-=1

print(ans-1)


Measured memory_bytes: 45440
#include <iostream>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	int ans = 0;

	if (a == b && b == c) {
		if (a % 2 == 0) {
			cout << -1;
		} else {
			cout << 0;
		}
		return 0;
	}

	int a1, b1, c1;

	for (;;) {
		ans++;
		a1 = a;
		b1 = b;
		c1 = c;

		if (a1 % 2 == 1 || b1 % 2 == 1 || c1 % 2 == 1) {
            break;
		}
			a = b1 / 2 + c1 / 2;
			b = a1 / 2 + c1 / 2;
			c = a1 / 2 + b1 / 2;
	}

	cout << ans - 1;

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int p[250000];
void init(void){
    int i,j;
    rep(i,250000)p[i]=1;
    p[0]=p[1]=0;
    for(i=2;i*i<250000;i++){
        if(p[i]){
            for(j=i+i;j<250000;j+=i)p[j]=0;
        }
    }
}

int main(void){
    int n,i,ans;
    init();
    while(1){
        n=in();
        if(!n)break;
        ans=0;
        for(i=n+1;i<=2*n;i++)ans+=p[i];
        print(ans);
    }
    return 0;
}



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

int main(){
  int a[12];
  for(int i=0;i<12;i++)cin>>a[i];
  sort(a,a+12);
  if(a[0]==a[3]&&a[4]==a[7]&&a[8]==a[11])cout<<"yes"<<endl;
  else cout<<"no"<<endl;
  return 0;
}

Measured memory_bytes: 3144
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    s = input()
    t = input()
    print("Yes" if s == t[:-1] else "No")
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 9712
//
//AtCoder Beginner Contest 165
//B - 1%
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define reAll(x) (x).rbegin(),(x).rend()

using ll = long long;

const double PI = 3.14159265358979323846;
const int MOD = 1000000007;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
    ll x;

    cin >> x;

    ll ans = 0;
    ll now = 100;


    while(x > now) {
        ans ++;
        now = now + (now * 0.01);
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
n,m,k = map(int,input().split())
arr1 = list(map(int,input().split()))
arr2 = list(map(int,input().split()))

acum1 = [0]
for i in range(n):
    acum1.append( acum1[-1] + arr1[i])

acum2 = [0]
for i in range(m):
    acum2.append(acum2[-1] + arr2[i])

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

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

// TYPEDEFS
typedef long long int li;
typedef unsigned long long int uli;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;
typedef pair<int, int> ii;
typedef pair<li, li> ll;
typedef pair<int, char> ic;
typedef pair<char, int> ci;
typedef pair<li, char> lc;
typedef pair<char, li> cl;
typedef vector<ic> vic;
typedef vector<ci> vci;
typedef vector<lc> vlc;
typedef vector<cl> vcl;
typedef map<int, int> mii;
typedef map<li, li> mll;
typedef map<char, int> mci;
typedef map<int, char> mic;
typedef map<li, char> mlc;
typedef map<char, li> mcl;
typedef map<char, bool> mcb;
typedef map<int, bool> mib;
typedef map<li, bool> mlb;
typedef set<int> si;
typedef set<li> sl;
typedef set<char> sc;
typedef priority_queue<int> pqi;
typedef priority_queue<li> pql;

// DEFINITIONS
#define fi(i, a, b, jump) \
    for (int i = int(a); i <= int(b); i += jump)
#define fir(i, a, b, jump) \
    for (int i = int(b); i >= int(a); i -= jump)
#define fl(i, a, b, jump) \
    for (li i = li(a); i <= li(b); i += jump)
#define flr(i, a, b, jump) \
    for (li = li(b); i >= li(a); i -= jump)
#define fv(v) \
    for (int i = 0; i < v.size(); ++i)
#define fvr(v) \
    for (int i = v.size()-1; i >= 0; --i)
#define fm(mp) \
    for (it = mp.begin(); it != mp.end(); ++it)
#define mem(arr, val) \
    memset(arr, val, sizeof(arr))

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

    string s;
    cin >> s;
    bool possible = true;
    for(int i = 0 ; i < s.length(); ++i){
        if(s[i] == 'R' && i%2 == 1) possible = false;
        if(s[i] == 'L' && i%2 == 0) possible = false;
    }
    cout << (possible?"Yes":"No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    int ans1 = 0;
    int ans2 = 0;
    for(int i = 0; i <= F; i+=A*100) {
        for(int j = 0; i+j <= F; j+=B*100) {
            for(int k = 0; k <= (i+j)/100*E; k+=C) {
                for(int l = 0; k+l <= (i+j)/100*E; l+=D) {
                    if(i+j+k+l <= F) {
                        if(ans2 == 0) {
                            ans1 = k+l;
                            ans2 = i+j+k+l;
                        }
                        else if((double)ans1/ans2 < (double)(k+l)/(i+j+k+l)) {
                            ans1 = k+l;
                            ans2 = i+j+k+l;
                        }
                    }
                }
            }
        }
    }
    cout << ans2 << " " << ans1 << endl;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ss string
#define ll long long int
#define Endl endl
#define u_b upper_bound
#define rep(i,n)         for(int i=0;i<n;i++)
#define ld long double
#define tc long long t;cin>>t;while(t--)
#define fr(i,a,b)        for(long long int i=a;i<=b;i++)
#define E endl
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define V vector<ll>v;
#define aaste long long int n;cin>>n;long long int a[n];for(long long int i=0;i<n;i++)cin>>a[i];
const ll   mod=            1000000007;
const ll   MOD1=           (int)1e9 + 9;
const ll   MOD2=           998244353;
const ld    pi=             atan2(0, -1);
const ld    eps=            1e-9;
const int   N=                   1e6+7;

const int MAXR = 1000005;
ll         tests=          1;

using namespace std;
ll binarySearch(ll l, ll r,ll k)
{
	if (r >= l) {
		ll mid = l + (r - l) / 2;
		if (mid*(mid+1)==k)
			return 1;
		if (mid*(mid+1)>k)
			return binarySearch( l, mid - 1,k);
		return binarySearch(mid + 1, r, k);
	}
	return 0;
}
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
void swap(ll *p1, ll *p2)
{
   ll temp=*p1;
   *p1=*p2;
   *p2=temp;
}
ll cbratt(ll x)
{
    ll l = 0, r = MAXR;
    while (l != r) {
        ll m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}
int MaxSubArraySumReturn(int a[], int  n) //negative thakle o kaaj korbe in O(n)
{
 
    int sum = 0, best = 0;
   for(ll i=0;i<n;i++)
    {
        sum = max(a[i], a[i] + sum);
        best = max(best, sum);
    }
    return best;
 
}
ll totalDigits(ll n) 
{ 

    ll number_of_digits = 0; 
    for (ll i = 1; i <= n; i *= 10) 
        number_of_digits += (n - i + 1); 
  
    return number_of_digits; 
} 

int main()
{
 
    #ifndef ONLINE_JUDGE
	{
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	}
  #endif
ld x,y;
cin>>x>>y;
ll sum=x*y;
cout<<sum;
}


    




Measured memory_bytes: 3712
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
void oi(ll x){ cout << x << " "; }
void od(ld x){ cout << fixed << setprecision(10) << x << " "; }
void os(string x){ cout << x; }
void oie(ll x){ cout << x << endl; }
void ode(ld x){ cout << fixed << setprecision(10) << x << endl; }
void ose(string x){ cout << x << endl; }
void oe(){ cout << endl; }

int main(){
    ll N=ii(), X=ii()-1, Y=ii()-1;
    ll ret[N]={0};
    REP(i,0,N){
        REP(j,i+1,N){
            ll d=j-i;
            d=min(d, abs(X-i)+1+abs(Y-j));
            d=min(d, abs(X-j)+1+abs(Y-i));
            ret[d]++;
        }
    }
    REP(i,1,N){
        oie(ret[i]);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef double ld;
using namespace std;
static const int INF = 0x3f3f3f3f;

int n;

int main(void)
{
    cin >> n;
    int maxn = -INF, minn = INF;
    int t;
    cin >> minn;
    for (int i = 1; i < n; i++) {
        cin >> t;
        //if (t < minn) minn = t;
        maxn = max(maxn, t - minn);
        if (t < minn) minn = t;
    }
    cout << maxn << endl;
    return 0;
}


Measured memory_bytes: 3096
/*
___mennat khoday ra azz o va jall ke taatash mojebe ghorbat ast o be shokr andarash mazide nemat.
___har nafasi ke foro miravad momedde hayatast o chon bar miayad mofarrahe zat.
___pas dar har nafasi 2 nemat mojod ast o bar har nematy shokry vajeb.

___az dast o zabane ke barayad ?
___kaz ohdeye shokrash be dar ayad !


___man be to dami gharar natvanam kard
___va ehsane to ra shomar natvanam kard
####################
___gar bar tane man zaban shavad har moyee
___yek shokre to az hezar natvanam kard

*/

#include <bits/stdc++.h>

#define pb push_back
#define SALI main
#define left(x) ((x)*2)
#define right(x) (((x)*2)+1)
#define fuck(x) cout << #x << " : " << x << endl;
#define findLowVec(v,x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define findUpVec(v,x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define findLowArr(a,n,x) (lower_bound(a, a+n, x) - a)
#define findUpArr(a,n,x) (upper_bound(a, a+n, x) - a)
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;

template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p)
{return out << "(" << p.first << ", " << p.second << ")";}

template<class A> ostream& operator <<(ostream& out, const vector<A> &v)
{out << "[";for(int i = 0; i < v.size(); i++) {if(i) out << ", ";out << v[i];}return out << "]";}

template<class A,class B> ostream& operator <<(ostream& out, const set<A,B> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

template<class A> ostream& operator <<(ostream& out, const set<A> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}


const int inf = 1e9 + 7;

int32_t SALI()
{

    int n,k;
    cin >> n >> k;
    int h[n];
    for(int i = 0; i < n; i++) cin >> h[i];
    vector<int> dp(n, inf);
    dp[0] = 0;
    for(int i = 1; i < n; ++i) {
        for(int j = 1; j <= min(i,k); j++){
            dp[i] = min(dp[i],dp[i-j] + abs(h[i] - h[i-j]));
        }
    }

    cout << dp[n-1] << endl;
}


/**< WRITEN BY ALI ADELKHAH */



Measured memory_bytes: 4804
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int N;

int main(){
    cin>>N;

    cout<<N*N*N<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////


int main() {
	int N; cin >> N;
	int B[110]; 
	for (int i = 0; i < N-1; ++i)cin >> B[i];
	int ans[110];
	ans[N-1] = B[N - 2];
	for (int i = N - 2; i >= 1; i--) {
		ans[i] = min(B[i], B[i-1]);
	}
	ans[0] = B[0];
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		sum += ans[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,k,x,y;
int main()
{
	char a[1001];
	scanf("%s",a);
	int x;
	x=strlen(a);
	cout<<a[0]<<x-2<<a[x-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

template <class T>
inline void read(T &x)
{
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

int n, k, ans;

int main()
{
    read(n), read(k);
    while (n)
    {
        n /= k;
        ++ans;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
ll solve(vector <int> a){
    ll p0=0,p1=0;
    for (auto u : a){
        if (u%2==1) p1++;
        else p0++;
    }
    if (p0%2==1) return 1;
    if (p1!=1) return 0;
    for (int i=0;i<a.size();i++){
            if (a[i]%2==1)
                a[i]--;
            if (a[i]==0) return 0;
    }
    ll w=0;
    for (auto u : a) w=__gcd(w,u);
    for (int i=0;i<a.size();i++) a[i]/=w;
    return 1-solve(a);
}
int32_t main(){
    ll n;
    cin >> n;
    vector <int> a;
    for (int i=0;i<n;i++){
        ll x;
        cin >> x;
        a.pb(x);
    }
    ll ans=solve(a);
    if (ans) kill("First");
    kill("Second");
}

Measured memory_bytes: 22928
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	int n;
	cin>>n;
	int N=1<<n;
	vi in(N);
	rep(i,N)cin>>in[i];
	
	vi out(N);
	vvp dp(N);
	dp[0].pb({in[0],0});
	loop(i,1,N){
		vp ma={{in[i],i}};
		rep(j,n)if(i&1<<j)rep(k,dp[i-(1<<j)].size())
			ma.pb(dp[i-(1<<j)][k]);

		sort(all(ma));
		ma.erase(unique(all(ma)),ma.end());

		dp[i]={ma[ma.size()-2],ma[ma.size()-1]};
		out[i]=dp[i][0].first+dp[i][1].first;
	}
	rep(i,N-1)cmax(out[i+1],out[i]);
	rep(i,N-1)cout<<out[i+1]<<endl;
}







Measured memory_bytes: 25620
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int field[3005][3005];
ll dp[3005][3005][4];
int main() {
  int R, C, n;
  cin >> R >> C >> n;
  REP(i, n) {
    int r, c, v;
    cin >> r >> c >> v, r--, c--;
    field[r][c] = v;
  }
  REP(i, R) REP(j, C) {
    for (int k = 2; k >= 0; k--) {
      chmax(dp[i][j][k + 1], dp[i][j][k] + field[i][j]);  //拾ったことの遷移
    }
    REP(k, 4) {
      chmax(dp[i + 1][j][0], dp[i][j][k]);
      chmax(dp[i][j + 1][k], dp[i][j][k]);
    }
  }
  ll ans = 0;
  REP(k, 4) chmax(ans, dp[R - 1][C - 1][k]);
  cout << ans << endl;
}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    int T = 0;
    for (int i = 1; i <= N; i++)
    {
        int j = 0;
        int k = i;

        while (true)
        {
            if (k != 0)
            {
                j += k % 10;
                k /= 10; 
            }
            else
            {
                break;
            }
        }
        
        if (j >= A && j <= B)
        {
            T += i;
        }
    }
    
    cout << T << endl;
}

Measured memory_bytes: 256
x1,x2,x3,x4,x5 = map(int,input().split())

if x1 == 0:
    print(1)
elif x2 == 0:
    print(2)
elif x3 == 0:
    print(3)
elif x4 == 0:
    print(4)
else:
    print(5)

Measured memory_bytes: 9172
n=int(input())
b=[0]*n
w=[0]*n
for i in range(2*n):
  c,a=input().split()
  if c=="B":b[int(a)-1]=i
  else:w[int(a)-1]=i
bit=[0]*2*n
dp=[(n+1)*[10**10]for _ in range(n+1)]
dp[0][0]=0
for i in range(n+1):
  bitt=bit[:]
  for j in range(n):
    a=0
    k=2*n
    while k:
      a+=bitt[k-1]
      k-=k&-k
    if w[j]!=0:
      k=w[j]
      while k:
        a-=bitt[k-1]
        k-=k&-k
    dp[i][j+1]=min(dp[i][j+1],dp[i][j]+a+w[j]-(i+j))
    k=w[j]+1
    while k<=2*n:
      bitt[k-1]+=1
      k+=k&-k
    if i!=n:
      a=0
      k=2*n
      while k:
        a+=bitt[k-1]
        k-=k&-k
      if b[i]!=0:
        k=b[i]
        while k:
          a-=bitt[k-1]
          k-=k&-k
      dp[i+1][j+1]=dp[i][j+1]+a+b[i]-(i+j+1)
  if i!=n:
    a=b[i]-i
    k=2*n
    while k:
      a+=bit[k-1]
      k-=k&-k
    if b[i]!=0:
      k=b[i]
      while k:
        a-=bit[k-1]
        k-=k&-k
    dp[i+1][0]=dp[i][0]+a
    k=b[i]+1
    while k<=2*n:
      bit[k-1]+=1
      k+=k&-k
print(dp[n][n])

Measured memory_bytes: 99288
#include <iostream>
#include <vector>
#include <string>

using namespace std;

vector<string> A;
vector<string> B;
vector<vector<bool> > seen;
int N, M;

bool dfs(int i, int j, int si, int sj) {
    seen[i][j] = true;
    
    if(A[i][j]==B[i-si][j-sj]) {
        if(i+1<M+si) {
            if(!dfs(i+1, j, si, sj)) return false;
        }
        if(j+1<M+sj) {
            if(!dfs(i, j+1, si, sj)) return false;
        }
        return true;
    } else {
        return false;
    }
}

int main() {
    cin >> N >> M;
    A.resize(N);
    B.resize(M);
    
    for(int n=0; n<N; n++) {
        cin >> A[n];
    }
    for(int m=0; m<M; m++) {
        cin >> B[m];
    }
    
    bool flag=false;
    for(int i=0; i<N-M+1; i++) {
        for(int j=0; j<N-M+1; j++) {
            seen.assign(N, vector<bool>(N, false));
            if(dfs(i, j, i, j)) flag=true;
        }
    }
    
    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>

#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<template<class...> class ContT, class ValueT, size_t Dim>
struct vec_type
{
    using type = ContT<typename vec_type<ContT, ValueT, Dim-1>::type>;
};

template<template<class...> class ContT, class ValueT>
struct vec_type<ContT, ValueT, 0>
{
    using type = ValueT;
};

template<class ValueT, size_t Dim>
using vec_t = typename vec_type<std::vector, ValueT, Dim>::type;


template<class ValueT, size_t Dim, class = typename std::enable_if<Dim == 0>::type>
auto make_vec(ValueT value = ValueT()) -> ValueT
{
    return value;
}

template<class ValueT, size_t Dim, class... Rest>
auto make_vec(size_t size0, Rest... rest)
{
    auto vec = make_vec<ValueT, Dim-1>(rest...);
    return std::vector(size0, vec);
}


int diffabs(int l, int r)
{
    if (l < r) return r-l;
    else return l-r;    
}


void update(const vector<bool> &prev, vector<bool> &cur, int d)
{
    for (size_t i = 0; i < prev.size(); ++i)
    {
        if (prev[i])
        {
            cur[i+d] = true;
            cur[diffabs(i,d)] = true;
        }
    }
}

int main()
{
    int H, W;
    cin >> H >> W;

    vec_t<int,2> A = make_vec<int,2>(H, W);
    vec_t<int,2> B = make_vec<int,2>(H, W);

    for (int h = 0; h < H; ++h)
        for (int w = 0; w < W; ++w)
            cin >> A[h][w];

    for (int h = 0; h < H; ++h)
        for (int w = 0; w < W; ++w)
            cin >> B[h][w];
   

    vec_t<bool,3> dp = make_vec<bool,3>(H, W, (H+W)*80, false);

    for (int h = 0; h < H; ++h)
    {
        for (int w = 0; w < W; ++w)
        {
            int d = diffabs(A[h][w], B[h][w]);
            if (h == 0 && w == 0) dp[h][w][d] = true;  
            if (w > 0) update(dp[h][w-1], dp[h][w], d);
            if (h > 0) update(dp[h-1][w], dp[h][w], d);
        }
    }

    const auto &hw = dp[H-1][W-1];
    auto it = find(begin(hw), end(hw), true);
    int ans = std::distance(begin(hw), it);
    cout << ans << endl;
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
 
int main(){
    int N, M;
    cin >> N >> M;
    int L[100000], R[100000];
    for(int i=0;i<M;i++)
        cin >> L[i] >> R[i];

    int left = 1, right = N;
    // M個のゲート
    for(int i=0;i<M;i++){
        if(left < L[i])
            left = L[i];
        if(R[i] < right)
            right = R[i];
    }

    int ans;
    if(left > right){
        ans = 0;
    }else{
        ans = right - left + 1;
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FORE(x,c) for(auto &x:c)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is>>*i; return is; }
//------------------------------------------------------------------------------

signed main() {
    int n;
    cin>>n;
    vector<vi> a(n);
    REP(i,n) {
        int m;
        cin>>m>>m;
        REP(j,m) {
            int v;
            cin>>v;
            a[i].push_back(v-1);
        }
    }

    REP(i,n) {
        REP(j,n) {
            cout<<(find(ALL(a[i]),j)!=end(a[i]));
            if(j!=n-1) cout<<" ";
            else cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3116
import java.util.*;
class Main{
 static public void main(String args[]){
  Scanner sc=new Scanner(System.in); 
   boolean flag;
   int a,b,c,d;
   a=sc.nextInt();
   b=sc.nextInt();//kougeki
   c=sc.nextInt();
   d=sc.nextInt();//kougeki
   
   while(true){
  	
     c-=b;
	 
	 	if(c<=0){
	 	flag=true;break;
		}

	 a-=d;
	    if(a<=0){
	 	flag=false;break;
		}
		
	 else continue;
   }
   
   if(flag)System.out.println("Yes");
   else System.out.println("No");
 }
}

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

int main()
{
  long long k,s;cin>>k>>s;
  long long cnt =0;
  for (size_t x = 0; x <= k; x++)
  {
    for (size_t y = 0; y <= k; y++)
    {
      long long z = s - (x+y);
      if (0 <= z && z <= k)
      {
        cnt++;
      }
      
    }
    
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3572
N, Y = map(int, input().split())

for i in range(0, N+1):
    for j in range(0, N+1-i):
        k = N-i-j
        if 1000*i+5000*j+10000*k == Y:
            print(k, j, i)
            exit(0)
print(-1, -1, -1)


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

/*
転倒数を求める
O(NlogN)
*/
int inversion_number(vector<int>dat){
    //座標圧縮
    vector<int>vs;
    for(int i=0;i<dat.size();i++)vs.push_back(dat[i]);
    sort(vs.begin(),vs.end());
    vs.erase(unique(vs.begin(),vs.end()),vs.end());
    for(int i=0;i<dat.size();i++)
        dat[i]=lower_bound(vs.begin(),vs.end(),dat[i])-vs.begin();
    /*
    BIT
    0-indexedで扱う
    点kにxを加算するクエリ、区間[0,x]の和を求めるクエリがO(logN)でできる
    */
    struct binary_indexed_tree{
        vector<int>dat;
        void init(int n){dat=vector<int>(n+1);}
        binary_indexed_tree(int n):dat(n+1){}
        binary_indexed_tree(){}

        void add(int k,int x){
            for(k++;k<dat.size();k+=k&-k)dat[k]+=x;
        }
        int sum(int k){
            int ret=0;
            for(k++;k;k-=k&-k)ret+=dat[k];
            return ret;
        }
    }bit(vs.size());

    int ret=0;
    for(int i=0;i<dat.size();i++){
        ret+=i-bit.sum(dat[i]);
        bit.add(dat[i],1);
    }
    return ret;
}

int N;
int A[100000][3];

signed main(){
    scanf("%lld",&N);
    rep(j,3)rep(i,N)scanf("%lld",&A[i][j]),A[i][j]--;

    vector<int>X[2];
    int x[2]={};
    rep(i,N){
        if(A[i][0]%3)reverse(A[i],A[i]+3),x[i&1]++;
        if(A[i][0]+1!=A[i][1]||A[i][1]+1!=A[i][2]||((A[i][0]/3)&1)!=(i&1)){
            puts("No");
            return 0;
        }
        X[i&1].pb(A[i][0]/3);
    }

    rep(i,2)x[i^1]+=inversion_number(X[i]);
    puts((x[0]%2||x[1]%2)?"No":"Yes");
    return 0;
}


Measured memory_bytes: 4724
N=int(input())
red=[]
blue=[]
for i in range(N):
    a,b=map(int,input().split())
    red.append((a,b,i))
for i in range(N):
    a,b=map(int,input().split())
    blue.append((a,b,N+i))
from collections import defaultdict
branch=defaultdict(set)
for x in red:
    for y in blue:
        if x[0]<y[0] and x[1]<y[1]:
            branch[x[2]]|={y[2]}
            branch[y[2]]|={x[2]}
def main(i):
    global used
    global branch
    global match
    if i in used:
        return False
    for nex in branch[i]:
        if nex in used:
            continue
        elif match[nex]==-1:
            match[nex]=i
            match[i]=nex
            return True
        else:
            used|={i}
            if main(match[nex]):
                match[i]=nex
                match[nex]=i
                return True
    return False
match=[-1]*(2*N)
for i in range(2*N):
    used=set()
    if match[i]==-1:
        main(i)
print(sum([1 for i in range(2*N) if match[i]>=0])//2)

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

struct Construction {
  ll s, t, x;
  bool operator<(const Construction& c) const { return s < c.s; }
};

struct Person {
  ll d, index;
  bool operator<(const Person& p) const { return d < p.d; }
};

int main() {
  in(ll, n, q);
  vector<Construction> c(n);
  rep(i, n) {
    cin >> c[i].s >> c[i].t >> c[i].x;
    c[i].s -= c[i].x;
    c[i].t -= c[i].x;
  }
  sort(all(c));
  vector<Person> p(q);
  rep(i, q) {
    cin >> p[i].d;
    p[i].index = i;
  }
  sort(all(p));

  multiset<ll> active;
  priority_queue<pair<ll, ll>> que;
  auto cit = c.begin();
  vector<ll> ans(q);
  for (const auto& pi : p) {
    dbg(pi.d, pi.index);
    while (cit != c.end() && cit->s <= pi.d) {
      dbg(cit->s, cit->t, cit->x);
      que.push({-cit->t, cit->x});
      active.insert(cit->x);
      ++cit;
    }
    while (!que.empty() && -que.top().first <= pi.d) {
      dbg(-que.top().first, que.top().second);
      active.erase(active.find(que.top().second));
      que.pop();
    }
    if (active.empty()) {
      ans[pi.index] = -1;
    } else {
      ans[pi.index] = *active.begin();
    }
  }
  rep(i, q) out(ans[i]);
}


Measured memory_bytes: 25100
#include <cstdio>

int n;
int h[100010];

int main() {
	int i;
	
	scanf("%d", &n);
	for(i=1; i<=n; i++) scanf("%d", &h[i]);
	for(i=1; i<=n; i++) {
		if(h[i-1]>h[i]) {
			printf("No\n");
			return 0;
		}
		else if(h[i-1]<h[i]) h[i]--;
	}
	printf("Yes\n");
	return 0;
}

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

struct Data{
    int pos;
    long long val;

    bool operator<(const Data& right) const {
        return val == right.val ? pos < right.pos : val < right.val;
    }
};

void solve(long long N, std::vector<long long> A){
    vector<Data> data(N);
    for(int i = 0; i < N; ++i){
        data[i].pos = i+1;
        data[i].val = A[i];
    }
    sort(data.begin(), data.end());
    for(int i = 0; i < N-1; ++i){
        cout << data[i].pos << " ";
    }
    cout << data[N-1].pos << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

int main(){
    long long n;
    cin >> n;
    long long  ans = 0;
    if ( 1 <= n && n < 10 ) {
        ans = n;
    }
    else if ( 10 <= n && n < 100 ) {
        ans = 9;
    }
    else if ( 100 <= n && n < 1000 ) {
        ans += 9 + n - 100 + 1;
    }
    else if ( 1000 <= n && n < 10000 ) {
        ans += 9 + 900;
    }
    else if ( 10000 <= n && n < 100000 ) {
        ans += 9 + 900 + n - 10000 + 1;
    }
    else {
        ans += 90909;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
main(){float e;int d[4][2]={0},i;for(i=0;~scanf("%f",&e);i^=1)e>1.0?d[0][i]++:e>0.5?d[1][i]++:e>0.2?d[2][i]++:d[3][i]++;for(i=0;i<4;i++)printf("%d %d\n",d[i][0],d[i][1]);exit(0);}

Measured memory_bytes: 624
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    vl A(N), B(N);
    REP(i, N) cin >> A[i] >> B[i];
    ll ans = 0;
    for (ll i = N-1; i >= 0; i--) {
        ll rem = (A[i] + ans) % B[i];
        if(rem != 0) ans += B[i] - rem;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1920
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	string s, t;
	cin >> s >> t;
	reverse(s.begin(), s.end());
	if(s == t)puts("YES");
	else puts("NO");
 	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

bool fc(vector<int> &a, int m, int v, int p, int mid){
  int n = a.size();
  if(mid < p) return true;
  vector<int> tr;
  rep(i, n){
    if(i == mid) continue;
    tr.push_back(a.at(i));
  }

  ll top = a.at(mid) + m;
  if(top < tr.at(p-1)) return false;
  ll ex = (ll)(v-1)*m;
  rep(i, n-1){
    if(i < p-1) ex -= m;
    else ex -= min((ll)m, top - tr.at(i));
  }
  return ex <= 0;
}

int main(){
  int n, m;
  cin >> n >> m;
  int v, p;
  cin >> v >> p;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  sort(ALL(a), greater<int>());
  int ng = n, ok = 0;
  while(ng - ok > 1){
    int mid = (ok + ng)/2;
    if(fc(a, m, v, p, mid) == true) ok = mid;
    else ng = mid;
  }
  int ans = ok+1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4428