akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var N int
	var S string

	fmt.Scan(&N)
	fmt.Scan(&S)

	num := make([]int, 10)
	numm := make([]int, 10)

	for i := 0; i < 10; i++ {
		numm[i] = N
	}
	for i := 0; i < N; i++ {
		if numm[S[i]-'0'] == N {
			numm[S[i]-'0'] = i
		}
		num[S[i]-'0'] = i
	}

	ans := make(map[string]struct{})
	for l := 0; l < 10; l++ {
		i := numm[l]
		for j := i + 1; j < N-1; j++ {
			for k := 0; k < 10; k++ {
				if j < num[k] {
					ans[string(S[i])+string(S[j])+string(k+'0')] = struct{}{}
				}
			}
		}
	}
	fmt.Println(len(ans))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 2e5 + 17;

int n, a, b, c, d;

bool read()
{
	if (scanf("%d", &n) != 1)
		return false;

	scanf("%d %d %d %d", &a, &b, &c, &d);

	return true;
}

void solve()
{
	for (int i = 0; i <= n - 1; ++i)
	{
		llong l1 = a + 1ll * i * c;
		llong r1 = a + 1ll * i * d;
		llong l2 = 1ll * (n - 1 - i) * d;
		llong r2 = 1ll * (n - 1 - i) * c;
		llong l = l1 - l2;
		llong r = r1 - r2;

		if (l <= b && b <= r)
		{
			printf("YES\n");
			return ;
		}
	}

	printf("NO\n");
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 256
N = int(input())
t = [0]*N
x = [0]*N
y = [0]*N
for i in range(N):
    t, x, y = map(int, input().split())
    if ((x+y)%2) != (t%2):
        print('No')
        exit()
    if t < x+y:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 5364
#include <stdio.h>
#include <assert.h>
#include <stack>

char buf[128];
int pos;
#define NOW (buf[pos])

bool isdigit(char c) {
	return ('0' <= c && c <= '9');
}

bool isstrong(char c) {
	return (c=='*'||c=='/');
}
bool isweak(char c) {
	return (c=='+'||c=='-');
}

int digit() {
	if ( !isdigit(NOW) ) {
		fprintf(stderr, "%c: ", NOW);
		assert( isdigit(NOW) );
	}
	int ret = NOW - '0';
	pos++;
	
	return ret;
}
int number() {
	int ret = digit();
	while( isdigit(NOW) ) {
		ret = ret*10 + digit();
	}
	return ret;
}

int main(void) {

	int set;
	scanf("%d", &set);
	
	while(set--) {
		scanf("%s", buf);
		pos = 0;
		
		std::stack<char> expr;
		std::stack<int>  num;
		
		expr.push('(');
		
		while(true) {
			if(isdigit(NOW)) {
				num.push( number() );
			} else {
				if ( expr.top() == '(' && (NOW==')'||NOW=='=') ) {
					//対応する括弧が出てきたので、スタック上の括弧を消す
					expr.pop();
					pos++;
					if ( expr.empty() ) {
						break;
					}
				} else if ( expr.top() == '(' ||
				     NOW == '(' ||
					 ( isstrong(NOW)&&isweak(expr.top()) ) ) {
					//強い演算子はスタックに積んでおく。括弧が積んであるなら、無条件に積む
					expr.push(NOW);
					pos++;
				} else {
					//次の演算子は弱いor同じだから、積んでるものを先に計算してしまおう
					char de = expr.top(); expr.pop();

					int b = num.top(); num.pop();
					int a = num.top(); num.pop();
					int ans;
					switch(de) {
						case '+': ans=a+b; break;
						case '-': ans=a-b; break;
						case '*': ans=a*b; break;
						case '/': ans=a/b; break;
					}
					num.push(ans);
				}
			}
			
		}
		
		printf("%d\n", num.top());
	}
	
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int P = 998244353 ; 
const int N = 1e7 + 5 ;
int n, inv[N], fac[N], fp[N], Ans ;
int fpow( int x, int k ) {
	int ans = 1, base = x ;
	while( k ) {
		if( k & 1 ) ans = ans * base % P ;
		base = base * base % P, k >>= 1 ;
	} return ans ; 
}
void inc( int &x, int y ) {
	( ( x += y ) >= P ) && ( x -= P ) ;
}
int C( int x, int y ) {
	if( y > x ) return 0 ;
	return fac[x] * inv[y] % P * inv[x - y] % P ;
}
signed main()
{
	n = gi(), fp[0] = inv[0] = fac[0] = 1 ;
	rep( i, 1, n ) fac[i] = fac[i - 1] * i % P, fp[i] = fp[i - 1] * 2 % P ; 
	inv[n] = fpow( fac[n], P - 2 ) ;
	for( re int i = n; i >= 1; -- i ) inv[i - 1] = inv[i] * i % P ;
	int m = ( n / 2 ) + 1, num = 0 ;
	Ans = fpow( 3, n ) ;
	for( re int i = m; i <= n; ++ i ) {
		int dec = C( n, i ) ;
		dec = dec * fp[n - i] % P ;
		inc( num, dec ) ;
	}
	Ans = ( Ans - num * 2ll % P + P ) % P ;
	printf("%lld\n", Ans ) ;
	return 0 ;
}


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

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

    ll n,m;
    cin >> n;
    vector<ll> d(n);
    for (ll i = 0;i < n;i++){
        cin >> d[i];
    }
    cin >> m;
    vector<ll> t(m);
    for (ll i = 0;i < m;i++){
        cin >> t[i];
    }
    map<ll,ll> mpd;
    for (ll i = 0; i < n; i++){
        mpd[d[i]]++;
    }
    map<ll,ll> mpt;
    for (ll i = 0; i < m; i++){
        mpt[t[i]]++;
    }
    bool ans = true;
    for (ll i = 0; i < m; i++){
        ll x = t[i];
        if (mpd[x] < mpt[x]){
            ans = false;
        }
    }

    if (ans){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 31424
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int W = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        _out.println(Math.max(Math.max(a - b - W, 0), Math.max(b - a - W, 0)));
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 22612
#include <stdio.h>

int main(){
  int n,k,i,j,x,temp,ans=0;
  scanf("%d %d",&n,&k);
  int sunuke[n];
  for(i=0;i<n;i++){
    sunuke[i]=0;
  }
  for(i=0;i<k;i++){
    scanf("%d",&x);
    for(j=0;j<x;j++){
      scanf("%d",&temp);
      sunuke[temp-1]++;
    }
  }
  for(i=0;i<n;i++){
    if(sunuke[i]==0){
      ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}

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

int main() {
  string s;
  cin >> s;

  long long cnt=0,ans=0;
  for(long i=0;i<s.size();i++){
    if(s.at(i)=='W'){
      ans += i-cnt;
      cnt++;
    }
  }

  cout << ans << endl;
}

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

int N;
string S;

map<pair<char,string>, char> mp;

int main() {
	cin >> N >> S;
	S += S[0];
	// s[0]が'S'か'W'かと, S[1], S[N-1]が'S'か'W'かを決めたらあとは一意に定まる
	// 定まったS[N-1]が本来あるべきS[N-1]か確かめればいい
	vector<string>  cs;
	cs.push_back("SS");
	cs.push_back("SW");
	cs.push_back("WS");
	cs.push_back("WW");

	mp[make_pair('o',"SS")] = 'S';
	mp[make_pair('o',"WS")] = 'W';
	mp[make_pair('o',"SW")] = 'W';
	mp[make_pair('o',"WW")] = 'S';

	mp[make_pair('x',"SS")] = 'W';
	mp[make_pair('x',"WS")] = 'S';
	mp[make_pair('x',"SW")] = 'S';
	mp[make_pair('x',"WW")] = 'W';

	for(int i=2;i<=N+1;i++) {
		for(int j=0;j<cs.size();j++) {
			string tmp = "";
			tmp += cs[j][i-2];
			tmp += cs[j][i-1];
			cs[j] += mp[make_pair(S[i-1], tmp)];
		}
	}
	string ans = "-1";
	for(int i=0;i<cs.size();i++) {
		if(cs[i][0] == cs[i][N] and cs[i][1] == cs[i][N+1]) {
			cs[i].pop_back();
			cs[i].pop_back();
			ans = cs[i];
		}
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

int main() {
    double D, T, S;
    cin >> D >> T >> S;

    if (D / S > T) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3716
#include <algorithm>
#include <cstdio>

const int N=100005;

int L[N],R[N],v[N],fst[N],tot,rt;
bool flag=1;
struct Edge{
	int to,nxt;
}e[N*2];

void addedge(int x,int y){
	e[++tot].to=y;e[tot].nxt=fst[x];fst[x]=tot;
}

void dfs(int x,int father){
	for (int i=fst[x];i && flag;i=e[i].nxt){
		int y=e[i].to;
		if (y!=father){
			dfs(y,x);
			L[x]=std::max(L[x],L[y]-1);
			R[x]=std::min(R[x],R[y]+1);
			if (L[x]>R[x]) flag=0;
		}
	}
}

void dfs2(int x,int father){
	for (int i=fst[x];i && flag;i=e[i].nxt){
		int y=e[i].to;
		if (y!=father){
			if (v[x]-1>=L[y] && v[x]-1<=R[y]) v[y]=v[x]-1;
				else if (v[x]+1>=L[y] && v[x]+1<=R[y]) v[y]=v[x]+1;
					else flag=0;
			dfs2(y,x);
		}
	}
}

int main(){
	int n,k;
	scanf("%d\n",&n);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		addedge(x,y);
		addedge(y,x);
	}
	for (int i=1;i<=n;i++) L[i]=-(R[i]=100000000);
	scanf("%d\n",&k);
	for (int i=1;i<=k;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		L[rt=x]=R[x]=y;
	}
	dfs(rt,0);
	v[rt]=L[rt];
	dfs2(rt,0);
	if (flag){
		printf("Yes\n");
		for (int i=1;i<=n;i++) printf("%d\n",v[i]);
	}
	else printf("No\n");
}

Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define all(v) v.begin(),v.end()
#define PB push_back
#define T(val) while(val--)
#define FIN for(i=0;i<n;i++)
#define FIS for(i=0;i<s.length();i++)
#define AIN for(i=0;i<n;i++){cin>>a[i];}
#define F(i,k,n) for(i=k;i<n;i++)
#define FG(i,k,n,x) for(i=k;i<n;i+=x)
#define YES cout<<"YES\n"; 
#define NO cout<<"NO\n"; 
#define ll long long
#define ld long double
#define MOD 1000000007
#define deb(x) cout << #x << "=" << x << endl;
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//sort(arr, arr+n, greater<int>()); For sorting in reverse order 
int solve(){ 
  ll x,k,d;
  cin>>x>>k>>d;
  x=abs(x);
  ll ini=x/d;
  x-=min(k,ini)*d;
  k-=ini;
  k=max((ll)0,k);
  if(k%2==0){
    cout<<x<<"\n";
  }
  
  if(k%2==1){
    cout<<abs(x-d)<<"\n";
  }
  // deb2(x,k);
  return 0;
}
int main(){
fast
        int t=1;
        // cin>>t; 
        T(t){
          solve();
        }
        return 0;
}       

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

int main(){
  int x,t;
  cin>>x>>t;
  cout<<max(x-t,0)<<endl;

  return 0;
}

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

int max(int a,int b){return (a > b ? a : b);}

int main()
{
    char *s;
    s = (char*)malloc(sizeof(char) * 500001);
    int *n;
    n = (int*)malloc(sizeof(int) * 500001);
    memset(n,0,sizeof(n));

    long long ans;

    scanf("%s",s);

    int len = strlen(s);

    int count = 1;
    for (int i = 0; i < len; i++)
    {
        if(s[i] == '<')
        {
            n[i + 1] = count;
            count++;
        }
        else
        {
            count = 1;
        }
    }
    for (int i = len - 1; i >= 0; i--)
    {
        if(s[i] == '>')
        {
            n[i] = max(count,n[i]);
            count++;
        }
        else
        {
            count = 1;
        }
    }
    for (int i = 0; i <= len; i++)
    {
        ans += n[i];
    }
    printf("%lld",ans);
    free(s);
    free(n);
}

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

using namespace std;

using ll = long long;

ll dp[15][2];
int a[15];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    dp[0][1] = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 0) {
            dp[i + 1][0] = dp[i][0] * 3 + dp[i][1];
            dp[i + 1][1] = dp[i][1] * 2;
        } else {
            dp[i + 1][1] = dp[i][1];
            dp[i + 1][0] = (dp[i][0] + dp[i][1]) * 2 + dp[i][0];
        }
        //cout << dp[i + 1][0] << " " << dp[i + 1][1] << endl;
    }
    cout << dp[n][0] << endl;
    return 0;
}

Measured memory_bytes: 256
#[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::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// stones.rs --- Stones
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        k: usize,
        xs: [usize; n],
    };

    let x_min = *xs.iter().min().unwrap();

    let mut dp = vec![false; k + 1];

    for i in 0..(k + 1) {
        dp[i] = xs
            .iter()
            .filter(|&&x| x <= i)
            .map(|x| i - x)
            .any(|j| j < x_min || !dp[j]);
    }

    let ans = dp[k];
    println!("{}", if ans { "First" } else { "Second" });
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

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

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

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,a,b,c,d,e;
	cin >> n >> a >> b >> c >> d >> e;
	ll tmp=min({a,b,c,d,e});
	cout << (n+(tmp-1))/tmp+4 << endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,m,l=1,r=1; cin>>n>>m;
    vector<int> num(n,0),s(m,0),c(m,0);
    rep(i,m) cin>>s[i]>>c[i];
    if(n==1) l=0;
    else rep(i,n-1) l*=10;
    rep(i,n) r*=10; r--;
    for(int i=l;i<=r;i++){
        int N=i,J=1;
        rep(j,n){
            num[n-j-1]=N%10; N/=10;
        }
        rep(j,m)if(num[s[j]-1]!=c[j]) J=0;
        if(J){
            cout<<i<<endl; return 0;
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 3480
#include <stdio.h>

#define MAX_N 10000
#define MAX_Q 500


void trace(int* x, int n) {
  for(int i=0; i<n; i++) {
    printf("%d", x[i]);
    if(i != n-1) {
      printf(" ");
    }
  }
  printf("\n");
}

int linear_search(int* arr, int n, int v) {
  for(int i=0; i<n; i++) {
    if(arr[i] == v) {
      return i;
    }
  }
  return -1;
}

int main() {
  int n, q;
  int s[MAX_N], t[MAX_Q];

  scanf("%d", &n);
  for(int i=0; i<n; i++) {
    scanf("%d", &s[i]);
  }

  scanf("%d", &q);
  for(int i=0; i<q; i++) {
    scanf("%d", &t[i]);
  }

  int c = 0;
  for(int i=0; i<q; i++) {
    if(linear_search(s, n, t[i]) != -1) {
      c++;
    }
  }
  printf("%d\n", c);

  return 0;
}

Measured memory_bytes: 2736
#include <iostream>
using namespace std;
	
int main() {
	int n; cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	if(n==0) {
	    cout<<0<<endl;
	    return 0;
	}
	if(n==1) {
	    cout<<a[0]<<endl;
	    return 0;
	}
	int dp[n];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
	    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 3964
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int betu = (a * x) + (b * y);
		int sepa = c * Math.max(x, y) * 2;
		int midd;
		if (x > y) {
			midd = (c * y * 2) + a * (x - y);
		} else if (x < y) {
			midd = (c * x * 2) + b * (y - x);
		} else {
			midd = sepa;
		}
		System.out.println(Math.min(Math.min(betu, sepa), midd));
	}
}

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

int  main()
{
	int  a[100+1]={0},i,n,x;
	
    cin>>n;

    for(i=1; i<=n; i++)
    {
    	cin>>x;
    	a[x]=1;
    }
    
    int  s=0;
    
    for(i=1; i<=100; i++)
    {
    	if(a[i]==1)
    	   s++;
    }
    
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int const m=1000000007;
int main(){
 
int n;
cin>>n;
vector<int> a(3,0);
cin>>a[0]>>a[1]>>a[2];
vector<int> new_dp(3,0);
new_dp=a;

for(int i=0;i<n-1;i++){
cin>>a[0]>>a[1]>>a[2];
vector<int> dp(3,0);
for(int i=0;i<3;i++){
	for(int j=0;j<3;j++){
	if(i!=j){
		dp[i]=max(dp[i],new_dp[j]+a[i]);
		}
	}
}
//cout<<dp[0]<<" "<<dp[1]<<" "<<dp[2]<<"\n";
new_dp=dp;
}
cout<<*max_element(new_dp.begin(),new_dp.end());
cout<<"\n";
return 0;
}

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

int main(){
    int a,b,c,i,j;
    char op;
    j=0;
    while (true){
        cin>>a>>op>>b;
        if (op=='?') break;
        else{ 
            switch (op){
                case '+':
                    cout<<a+b<<endl;
                    break;
                case '-':
                    cout<<a-b<<endl;
                    break;
                case '*':
                    cout<<a*b<<endl;
                    break;
                case '/':
                    cout<<a/b<<endl;
                    break;
                default:
                    break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int a[]=new int[N];
		for(int i=0;i<N;i++) {
			a[i]=sc.nextInt();
		}
		int t;
		int j=1;
		for(int i=0;i<N;i++) {
			for(int k=0;k<N;k++) {
				if(a[i]>a[k]) {
					t=a[i];
					a[i]=a[k];
					a[k]=t;
				}
			}
		}
		int max=a[0];
		for(int i=0;i<N;i++) {
			if(max>a[i]) {
				j++;
				max=a[i];
			}
		}
		System.out.println(j);
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
typedef pair<int,int> P;
P a[100000];
int t[100001];
int N,L;
int main(){
  cin>>N>>L;
  REP(i,N){
    int tmp;
    cin>>tmp;
    a[i] = P(L-tmp, i);
  }
  sort(a, a + N);
  int ans = 0;
  REP(i,N){
    int ti = a[i].second;
    t[ti+1] = max(t[ti], t[ti+2]) + a[i].first;
    ans = max(ans, t[ti+1]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1612
#include <bits/stdc++.h>
#define ll   long long int
using namespace std;
#define fr(i,n) for(ll i=0;i<n;i++)
#define pii pair <ll ,ll>
#define ppi pair < pii , int > 
#define x first
#define y second
ll BITree[10000000];
ll query(int index) 
{ 
    ll ma = -1 ;
    index = index + 1; 
    while (index>0) 
    { 
        // sum += BITree[index]; 
        ma = max ( ma, BITree[index]);
        index -= index & (-index); 
    } 
    return ma; 
} 
void update(ll n, ll index, ll val) 
{ 
    index = index + 1; 
    while (index <= n) {
    // BITree[index] += val;
    BITree[index] = max (BITree[index],val); 
    index += index & (-index); 
    } 
} 
int main()
{
  ll n;
  cin>>n;
  ll h[n],v[n];
  fr(i,n)cin>>h[i];
  fr(i,n)cin>>v[i];
  ll ma = 0;
  for(int i=0;i<n;i++)
  { 
    ma = max ( ma ,  v[i] + query(h[i]));
    update(n+10,h[i], v[i] + query(h[i]) );
  }

 cout<<ma<<endl;
 return 0;
}

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

int main(){
  int h,w; cin >> h >> w;
  std::vector<vector<char>> s(h+2,vector<char>(w+2,'.'));
  for (int i = 1; i < h+1; i++) {
    for (int j = 1; j < w+1; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 1; i < h+1; i++) {
    for (int j = 1; j < w+1; j++) {
      if (s[i][j] == '#') {
        std::cout << s[i][j];
      }
      else{
        int count = 0;
        for (int a = -1; a < 2; a++) {
          for (int b = -1; b < 2; b++) {
            if (s[i+a][j+b] == '#') {
              count++;
            }
          }
        }
        std::cout << count;
      }
    }
    std::cout << '\n';
  }

}


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

char s[105];

inline bool isp(int l, int r) {
    for (int i = l; i < r; ++i)
        if (s[i] != s[l + r - i - 1]) return 0;
    return 1;
}

int main() {
    scanf("%s", s);
    int n = strlen(s);
    if (isp(0, n) && isp(0, (n - 1) >> 1) && isp((n + 1) >> 1, n)) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(int i=(l);i<(r);i++)
int main(){
    int n;
    cin>>n;
    int a,ans=0;
    rep(i,0,n){
        cin>>a;
        while (~a&1) {
            a>>=1;
            ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
# input
X = input()

ss = []
ans = len(X)

for c in X:
    if ss == []:
        if c == 'T':
            continue
        else:
            ss.append(c)
    else:
        if c == 'T':
            ans -= 2
            ss.pop()
        else:
            ss.append(c)

print(ans)


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

using int_ = int;
#define int int_least64_t

int_ main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);

  array<int, 3> a;
  cin >> a[0]  >> a[1]  >> a[2];
  sort(a.begin(), a.end());
  cout << a[2]-a[1] + a[1]-a[0] << '\n';
}

/*
 * Local variables:
 * compile-command:"g++ -D_GLIBCXX_DEBUG -g3 -ggdb3 -O0 -Wall -Wextra -std=c++14 a.cc -o a && for f in *.in; do echo \"--- $f -------------\"; ./a <$f; done"
 * end:
 */


Measured memory_bytes: 256
s = input()
al = set(list(s))    
ans = 100

for c in al:
    L = list(s.split(c))
    tmp = 0
    for st in L:
        tmp = max(tmp, len(st))
    #tmp = max(tmp, len(L[0]))
    #tmp = max(tmp, len(L[-1]))
    ans = min(tmp, ans)
    #print(ans)
print(ans)

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

sp = []
for i in range(n):
    s, p = input().split()
    sp.append([s, int(p), i+1])
sp.sort(key=lambda x: x[1], reverse=True)
sp.sort(key=lambda x: x[0])
for i in range(n):
    print(sp[i][2])


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

int main(){
	int N;
	cin >> N;
	vector<int> p(N);
	int count = 0;
	for (int i = 0;i < N && count <= 2;++i) {
		cin >> p.at(i);
		if (p.at(i) != i + 1) {
			count++;
		}
	}
	cout << (count == 0 || count == 2 ? "YES" : "NO") << endl;
	return 0;
}

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

int main() {

  string N;
  int I_N = 0;
  cin >> N;

  int X = 0;
  for (int i = 0 ; i < (int)(N.length ()) ; i++) {
    char c = N[i];
    X += atoi (&c);
  }

  I_N = atoi (N.c_str ());

  if (I_N % X == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}



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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int k,x;
    cin >> k >> x;
    for(int i = x-(k-1);i <= x+(k-1);i++){
        if(i == x-(k-1)) cout << i;
        else cout << ' ' << i;
    }   
    cout << '\n';
    return 0;   
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
      Scanner sc =new Scanner(System.in);
      int s = sc.nextInt();
      int m =0;
      int[] a = new int[10000];
      a[0] = s;
      for (int i=1; i<10000; i++) {
        if(s % 2 == 0) {
          s /= 2;
          a[i] = s;
        } else {
          s = s * 3 + 1;
          a[i] = s;
        }
        for (int j=0; j<i; j++) {
          if(a[i] == a[j]) {
            m = i+1;
            break;
          }
        }
        if (m != 0) break;
      }
      System.out.println(m); 
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define sizep 100010
int isPrime[sizep];
void sieve()
{
    for(int i=1; i<=sizep; i++)
        isPrime[i]=0;
    isPrime[1]=1;
    for(int i = 2; i * i <=sizep; ++i)
    {
        if(isPrime[i] == 0)
        {
            for(int j = i*i ; j <=sizep; j += i)
            {
                isPrime[j] = 1;
            }
        }
    }
//  for(int i=1; i<=sizep; i++)
//  {
//      if(isPrime[i]==0)
//        cout<<i<<endl;
//  }
}
int main()
{
    int n;
    cin>>n;
    sieve();
//    if(isPrime[n]==0)
//        cout<<n<<endl;
//    else
//    {
        for(int i=n;i<=sizep;i++)
        {
            if(isPrime[i]==0){
                cout<<i<<endl;
                break;
        }
    }

    return 0;
}


Measured memory_bytes: 640
N, T = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort()
dp = [0] * T
#print("AB:", AB)

answer = 0
for a, b in AB:
  for t in range(T-1, -1, -1):
    if dp[t]:
      if  a + t < T:
        dp[a + t] = max(dp[a + t], dp[t] + b)
        answer = max(answer, dp[a + t])
      else:
        answer = max(answer, dp[t] + b)
  if a < T:
    dp[a] = max(dp[a], b)
  answer = max(answer, b)
  #print("dp:", dp)
print(answer)

Measured memory_bytes: 46824
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define inf 1e9
#define pi 3.1415926536
#define mod 1000000007
#define fr(i,a,b,in) for(int i=a;i<b;i+=in)
#define frn(i,a,b,dc) for(int i=a;i>=b;i-=dc)
#define test(t) int t; cin>>t; while(t--)
int main()
{
	fastio();
	int n;
	cin>>n;
	ll c=0;
	fr(i,2,n,1){
		// cout<<sqrt(i)+1<<endl;
		fr(j,1,sqrt(i),1){
			if(i%j==0) c+=2;
			// cout<<c<<endl;
		}
		int q=sqrt(i);
		if(q*q == i) c++;
	}
	cout<<c+1<<endl;
}

Measured memory_bytes: 3692
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int S, W;
    cin >> S >> W;
    if (W >= S) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
ll dp[100001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>n>>k;
    	ll ar[n];
    	for(int i=0;i<n;i++)
    	{
    		cin>>ar[i];
    	}
    	dp[0] = 0;
        for(int j=1;j<=k;j++)
        {
            set <int> s;
            int fl = 0;
            for(int i=0;i<n;i++)
            {
                if(j>=ar[i])
                {
                    if(!dp[j-ar[i]])
                        dp[j] = 1;
                }
                else
                    break;
            }
        }
        if(dp[k])
            cout<<"First"<<endl;
        else
            cout<<"Second"<<endl;
    }
    return 0;
}

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

int h, w;
int dy[4] = {0, 0, 1, 1}, dx[4] = {0, 1, 0, 1};
int dy1[4] = {-1, -1, 0, 0}, dx1[4] = {-1, 0, -1, 0};
char a[1006][1006], str[1006][1006], base[3][3];
int solve(int y, int x){
	int f = 1;
	for(int i = 0;i < 4;i++){
		int yy = dy[i], xx = dx[i];
		if(a[y+yy][x+xx] != base[yy][xx])f = 0;
	}
	return f;
}

int calc(){
	int ans = 0;
	rrep(y,h)rrep(x,w)ans += solve(y, x);
	return ans;
}

int dis(){
	int ans = 0;
	rrep(y,h)rrep(x,w){
		int d1 = 0,d2 = 0;
		char tmp = a[y][x];
		rep(i,4)d1 += solve(y+dy1[i], x+dx1[i]);
		rep(j,4){
			a[y][x] = base[dy[j]][dx[j]];
			int t = 0;
			rep(i,4)t += solve(y+dy1[i], x+dx1[i]);
			d2 = max(d2, t);
		}
		ans = max(ans, d2-d1);
		a[y][x] = tmp;
	}
	return ans;
}

int main(){
	fill((char*)a, (char*)(a+1006), '.');
	scanf("%d%d", &h, &w);
	rep(i,h)scanf("%s", str[i]);
	rrep(i,h)rrep(j,w)a[i][j] = str[i-1][j-1];
	rep(i,2)scanf("%s", base[i]);
	int sum = calc();
	int d = dis();
	int ans = max(sum, sum+d);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 5192
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i, N) { cin >> A[i] >> B[i]; }

    ll ans = 0;
    repr(i, N - 1) {
        A[i] += ans;
        ans += (B[i] - A[i] % B[i]) % B[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4752
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double
 
int mod=1e9+7;
int cache[3005];
int dp(int left)
{
    if(left==0)
        return 1;
    if(left<0)
        return 0;
    int &ans=cache[left];
    if(ans!=-1)
        return ans;
    ans=0;
    for(int i=3;i<=left;i++)
        ans=(ans+dp(left-i))%mod;
    return ans;
}
int32_t main()
{
    IOS;
    int s;
    cin>>s;
    memset(cache,-1,sizeof(cache));
    print(dp(s));
}

Measured memory_bytes: 3688
#include "iostream"
using namespace std;
int main(void)
{
	int n;
	while (cin>>n,n) {
		int a=0,b=0;
		int aa,bb;
		while (n--) {
			cin>>aa>>bb;
			if(aa<bb) b+=aa+bb;
			else if(aa>bb) a+=aa+bb;
			else {
				a+=aa; b+=bb;
			}
		}
		cout<<a<<" "<<b<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
using namespace std;

int main() {
	int k, x;
	cin >> k;
	cin >> x;

	for (int i = x - k + 1; i <= x+k-1;i++) {
		cout << i ;
		cout << " ";
	}
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i).sort
b = gets.split.map(&:to_i).sort
c = gets.split.map(&:to_i).sort
ans = 0

b.each do |be|
  a_tmp = a.bsearch_index {|ae| be <= ae }
  c_tmp = c.bsearch_index {|ce| be < ce }

  if a_tmp.nil?
    if !c_tmp.nil?
      ans += n * (n - c_tmp)
    end
  else
    if !c_tmp.nil?
      ans += a_tmp * (n - c_tmp)
    end
  end
end

puts ans

Measured memory_bytes: 24688
def gcd(a, b):
    r = a % b
    if r == 0:
        return b
    return gcd(b, r)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    L = [A[0]]
    R = [A[-1]]
    for i in range(1, N - 1):
        L.append(gcd(L[-1], A[i]))
    for j in range(N - 2, 0, -1):
        R.append(gcd(R[-1], A[j]))
    ans = R[-1]
    for k in range(1, N - 1):
        ans = max(ans, gcd(L[k - 1], R[N - 2 - k]))
    print(max(ans, L[-1]))
    
main()


Measured memory_bytes: 14436
#include <iostream>
#include <queue>
#include <set>

using namespace std;
using pii = pair<int, int>;

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

using Events = pair<int, pii>;

int main() {
  int N, Q; cin >> N >> Q;

  priority_queue<Events, vector<Events>, greater<Events>> q;
  rep(i, N) {
    int s,t,x;
    cin >> s >> t >> x;
    q.emplace(s-x, pii(1, x));
    q.emplace(t-x, pii(-1, x));
  }

  set<int> s;
  rep(i, Q) {
    int d; cin >> d;
    while (!q.empty() && q.top().first <= d) {
      Events e = q.top(); q.pop();
      if (e.second.first == 1)
        s.insert(e.second.second);
      else
        s.erase(e.second.second);
    }
    if (s.empty())
      cout << -1 << endl;
    else
      cout << *s.begin() << endl;
  }

  return 0;
}


Measured memory_bytes: 15724
def therefore():
    hon = [2, 4, 5, 7, 9]
    pon = [0, 1, 6, 8]
    bon = [3]
    N = input()
    n = int(N[-1])
    if n in hon:
        print("hon")
    elif n in pon:
        print("pon")
    elif n in bon:
        print("bon")

therefore()

Measured memory_bytes: 9120
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846

void solve()
{
    int n;cin>>n;
    string s;cin>>s;
    vector<int> r,g,b;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
            r.push_back(i);
        else if(s[i]=='G')
            g.push_back(i);
        else
            b.push_back(i);
    }
    sort(r.begin(),r.end());
    sort(g.begin(),g.end());
    sort(b.begin(),b.end());
    int ans=0;
    for(int i=0;i<r.size();i++)
    {
        for(int j=0;j<g.size();j++)
        {
            if(g[j]>r[i])
            {
                int it1=b.end()-upper_bound(b.begin(),b.end(),g[j]);
                ans+=it1;
                if(binary_search(b.begin(),b.end(),2*g[j]-r[i]))
                    ans--;
            }
        }
        for(int j=0;j<b.size();j++)
        {
            if(b[j]>r[i])
            {
                int it1=g.end()-upper_bound(g.begin(),g.end(),b[j]);
                ans+=it1;
                if(binary_search(g.begin(),g.end(),2*b[j]-r[i]))
                    ans--;
            }
        }
    }
    for(int i=0;i<g.size();i++)
    {
        for(int j=0;j<r.size();j++)
        {
            if(r[j]>g[i])
            {
                int it1=b.end()-upper_bound(b.begin(),b.end(),r[j]);
                ans+=it1;
                if(binary_search(b.begin(),b.end(),2*r[j]-g[i]))
                    ans--;
            }
        }
        for(int j=0;j<b.size();j++)
        {
            if(b[j]>g[i])
            {
                int it1=r.end()-upper_bound(r.begin(),r.end(),b[j]);
                ans+=it1;
                if(binary_search(r.begin(),r.end(),2*b[j]-g[i]))
                    ans--;
            }
        }
    }
    for(int i=0;i<b.size();i++)
    {
        for(int j=0;j<r.size();j++)
        {
            if(r[j]>b[i])
            {
                int it1=g.end()-upper_bound(g.begin(),g.end(),r[j]);
                ans+=it1;
                if(binary_search(g.begin(),g.end(),2*r[j]-b[i]))
                    ans--;
            }
        }
        for(int j=0;j<g.size();j++)
        {
            if(g[j]>b[i])
            {
                int it1=r.end()-upper_bound(r.begin(),r.end(),g[j]);
                ans+=it1;
                if(binary_search(r.begin(),r.end(),2*g[j]-b[i]))
                    ans--;
            }
        }
    }
    cout<<ans<<nl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3716
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<long long>> vvl;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define xrep(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define all(A) A.begin(), A.end()
//入力
ll llin() {ll x; cin >> x; return x;}
string stin() {string s; cin >> s; return s;}
vl vlin(ll n) {vl a(n); rep(i,n){cin >> a[i];} return a;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}


//main関数
int main() {
  ll n = llin();
  vl lucas(n + 1);
  lucas[0] = 2; lucas[1] = 1;

  xrep(i,2,n + 1){
    lucas[i] = lucas[i - 1] + lucas[i - 2];
  }

  cout << lucas[n] << endl;
}



Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define BUF_SIZE 20
#define DIVISOR 1000000007

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

int main(void) {
    int n, k;
    get_int2(&n, &k);
    uint64_t ans = 1;
    if(n>k) { ans = 0; goto finish; }

    int i;
    for(i = k; i > k-n; i--) {
        ans = (ans * i)%DIVISOR;
    }
finish:
    printf("%d\n", (int)ans);
    return 0;
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(ll &a,ll b){
	a = min(a,b);
}

int main(){
	ll a; cin >> a;
	
	ll ans = a-1;
	for(ll i=2; i*i <= a ; i++){
		if(a%i == 0){
			self_min(ans,(i+ a/i -2 ));
		}
	}
	
	cout << ans << endl;
		
	
	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>


int main(int argc, const char * argv[]) {
    char ch;
    int num;
    int sum[26] = {0};
    int i;

    while ( scanf("%c", &ch) != EOF){
        //どの文字に当たるかチェック
        if (ch>='a' && ch<='z') {//アルファベットかどうか判定
            num = ch - 'a';
            sum[num] ++;
            //printf("%c : %d\n", ch, sum[ch-'a']);
        }else if (ch>='A' && ch<='Z'){
            num = ch - 'A';
            sum[num] ++;
        }
    }

    for (i=0; i<26; i++) {
        printf("%c : %d\n", i+'a', sum[i]);
    }

    return 0;
}


Measured memory_bytes: 2104
import itertools

n=int(input())
a=list(map(int,input().split()))

m=int(input())
b=list(map(int,input().split()))

l=list()

for i in range(n):
    for j in itertools.combinations(a,i):
        #print(sum(j))
        l.append(sum(j))

for i in b:
    for j in l:
        if i in l:
            print("yes")
            break
        else:
            print("no")
            break


Measured memory_bytes: 43096
#include <bits/stdc++.h>
#include <atcoder/dsu.hpp>
using namespace std;
using namespace atcoder;

void solve(long long N, long long Q, std::vector<long long> t, std::vector<long long> u, std::vector<long long> v){
    dsu d(N);
    for (int i = 0; i < Q; i++) {
        if (t[i] == 0) {
            d.merge(u[i], v[i]);
        } else {
            cout << d.same(u[i], v[i]) << endl;
        }
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> t(Q);
    std::vector<long long> u(Q);
    std::vector<long long> v(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&t[i]);
        scanf("%lld",&u[i]);
        scanf("%lld",&v[i]);
    }
    solve(N, Q, std::move(t), std::move(u), std::move(v));
    return 0;
}


Measured memory_bytes: 8164
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var ABCDE = new List<long>();
            ABCDE.Add(Sarray()[0]);
            ABCDE.Add(Sarray()[0]);
            ABCDE.Add(Sarray()[0]);
            ABCDE.Add(Sarray()[0]);
            ABCDE.Add(Sarray()[0]);
            var ans = 0L;
            var min = 10L;
            foreach(var m in ABCDE)
            {
                ans += (long)(Ceiling(m / 10.0) * 10);
                if (m % 10 != 0)
                    min = Min(min, m % 10);
            }
            if (min != 10)
                ans -= 10 - min;
            WriteLine(ans);

            //Out.Flush();
        }
    }
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a >= b + 1)
        cout << a * 2 - 1 << endl;
    else if(b >= a + 1)
        cout << b * 2 - 1 << endl;
    else
        cout << a * 2 << endl;
}

Measured memory_bytes: 256