akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define found(m,x) ((m).find(x)!=(m).end())
#define uset unordered_set
#define umap unordered_map
#define a(x) x.begin(),x.end()
#define fo(i,n) for(int i=0;i<(int)n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<=(int)n:i>=(int)n;k<n?i++:i--)
#define input(v,n) fo(i,n)cin>>v[i]
typedef vector<int> vi;
typedef long long ll;
// typedef pair<int,int> pi;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667
const int inf = numeric_limits<int> :: max();
// ===================== MANASH =================== //

void test() {

    
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<int> red(a),green(b),ls(c);
    fo(i,a) cin >> red[i]; 
    fo(i,b) cin >> green[i];
    fo(i,c) cin >> ls[i];

    sort(a(red),greater<int>());
    sort(a(green),greater<int>());
    sort(a(ls),greater<int>());

    while((int)red.size() > x ) red.pop_back();
    while((int)green.size() > y ) green.pop_back();

    vector<int> f(a(red));

    f.insert(f.end(),a(green));
    f.insert(f.end(),a(ls));
    // db(f);
    sort(a(f),greater<int>());
    cout << accumulate(f.begin(),f.begin()+x+y,0LL);
    
}

signed main() {

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

    #ifdef LOCAL
    freopen("input.txt","r",stdin);
    cout<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec.\n";
    #endif

    int T = 1;
    //cin >> T;
    while(T--) {
        test();
        cout << "\n";
    }
    return 0;

}

Measured memory_bytes: 6848
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

class Union:
    def __init__(self, n):
        self.parents = [-1] * n
    
    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            return self.root(self.parents[x])
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

uni = Union(n)
for a, b in ab:
    uni.unite(a-1, b-1)
print(-min(uni.parents))

Measured memory_bytes: 50028
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n =scan.nextInt();
		int l[]=new int[n];
		int r[]=new int[n];
		int sum=0;
		for(int i=0;i<n;i++) {
			l[i]=scan.nextInt();
			r[i]=scan.nextInt();
			sum+=r[i]-l[i]+1;
		}
		scan.close();
		System.out.println(sum);
	}
}

Measured memory_bytes: 25832
A,B,C = map(int, input().split())
K=int(input())
counter = 3**K
ans = False


for i in range(counter):
    tmp = i
    Ad= A
    Bd=B
    Cd=C
    for j in range(K):
        if tmp%3 ==0:
            Ad *=2
        elif tmp%3 ==1:
            Bd*=2
        else:
            Cd*=2
        tmp =tmp//3
    if Ad<Bd and Bd<Cd:
        ans =True



if ans:
    print("Yes")
else:
    print("No")


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

using namespace std;

template <class T>inline T updmax(T &a, T b) { return a = max(a, b); }
template <class T>inline T updmin(T &a, T b) { return a = min(a, b); }

template <unsigned long long mod> class modint {
  public:
	unsigned long long v;
	modint(const long long x = 0) : v(x % mod) {}
	modint operator+(const modint rhs) { return modint(*this) += rhs; }
	modint operator-(const modint rhs) { return modint(*this) -= rhs; }
	modint operator*(const modint rhs) { return modint(*this) *= rhs; }
	modint operator/(const modint rhs) { return modint(*this) /= rhs; }
	modint operator-() { return modint(mod - this->v); }
	modint& operator+=(const modint rhs) {
		v += rhs.v;
		if (v >= mod) v -= mod;
		return *this;
	}
	modint& operator-=(const modint rhs) {
		if (v < rhs.v) v += mod;
		v -= rhs.v;
		return *this;
	}
	modint& operator*=(const modint rhs) {
		v = v * rhs.v % mod;
		return *this;
	}
	modint inverse(modint a) {
		unsigned long long exp = mod - 2;
		modint ret(1ULL);
		while (exp) {
			if (exp % 2) { ret *= a; }
			a *= a;
			exp >>= 1;
		}
		return ret;
	}
	modint& operator/=(modint rhs) {
		(*this) *= inverse(rhs);
		return *this;
	}
	friend ostream& operator<<(ostream& os, modint& u) {
		os << u.v;
		return (os);
	}
	friend istream& operator>>(istream& is, modint& u) {
		is >> u.v;
		return (is);
	}
};

const int MOD = 1000003;
using mint = modint<MOD>;

const int MAX = MOD;
mint fact[MAX], invfact[MAX], inv[MAX];

void facinit() {
	fact[0] = fact[1] = 1;	
	invfact[0] = invfact[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fact[i] = fact[i - 1] * i;
		inv[i] = - inv[MOD%i] * (MOD / i);
		invfact[i] = invfact[i - 1] * inv[i];
	}
}

template<class T>
T fastpow(T a, long long p){
	T tmp = a;
	T ret = 1;
	while(p){
		if(p & 1)ret *= tmp;
		p >>= 1;
		tmp = tmp * tmp;
	}
	return ret;
}

int main()
{
	int q;
	scanf("%d", &q);
	facinit();
	for(int i=0; i < q; i++){
		mint x,d,n;
		cin >> x >> d >> n;
		if(x.v == 0){
			cout << 0 << "\n";
			continue;
		}
		if(d.v == 0){
			cout << fastpow(x, n.v).v << "\n";
			continue;
		}
		mint s = x/d;
		if(s.v + n.v - 1>= MOD){
			cout << 0 << "\n";
			continue;
		}
		cout << (fastpow(d, n.v) * fact[s.v + n.v - 1] * invfact[s.v-1]).v << "\n";
	}
	return 0;
}

Measured memory_bytes: 24320
# -*- coding: utf-8 -*-
import itertools,math,bisect,pprint,sys
s = map(int, raw_input().split())
a = s[0]
b = s[1]
c = s[2]
if a%2==0 or b%2==0 or c%2==0:
    print 0
else:
    s.sort()
    print s[0]*s[1]

Measured memory_bytes: 2812
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

macro_rules! chmin {
    ($ base : expr ,$ cmp : expr ) => {
        $base = std::cmp::min($base, $cmp);
    };
}
#[fastout]
fn main() {
    input! {//
        n:usize,
        mut xyp:[(i64,i64,i64);n],
    }
    let mut xsel = vec![vec![0; n]; 1 << n];
    let mut ysel = vec![vec![0; n]; 1 << n];
    for i in 0..1 << n {
        for j in 0..n {
            xsel[i][j] = xyp[j].0.abs();
            ysel[i][j] = xyp[j].1.abs();
            for k in 0..n {
                if (i >> k) & 1 == 1 {
                    chmin!(xsel[i][j], (xyp[j].0 - xyp[k].0).abs());
                    chmin!(ysel[i][j], (xyp[j].1 - xyp[k].1).abs());
                }
            }
        }
    }
    for i in 0..1 << n {
        for j in 0..n {
            xsel[i][j] *= xyp[j].2;
            ysel[i][j] *= xyp[j].2;
        }
    }
    let mut ans = vec![INF; n + 1];
    for i in 0..1usize << n {
        let cnt = i.count_ones() as usize;
        let mut j = i;
        loop {
            j &= i;
            let mut cost = 0;
            for k in 0..n {
                if i >> k & 1 == 0 {
                    cost += min(xsel[j][k], ysel[i - j][k]);
                }
            }
            chmin!(ans[cnt], cost);
            if j == 0 {
                break;
            }
            j -= 1;
        }
    }
    for &x in ans.iter() {
        println!("{}", x);
    }
}
const INF: i64 = 1 << 60;


Measured memory_bytes: 11748
package main

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

func main() {
	S := ReadString()
	cnt := 0
	for i, c := range S {
		cnt += (i % 2) ^ int(c-'0')
	}
	cnt2 := len(S) - cnt
	if cnt < cnt2 {
		fmt.Println(cnt)
	} else {
		fmt.Println(cnt2)
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }


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

int main()
{
	int N; cin >> N;
	vector<ll> A(N + 1);

	A[0] = 0;
	for (int i = 1; i <= N; i++)
	{
		cin >> A[i];
	}

	ll ans = 0;
	for (int i = 1; i <= N; i++)
	{
		if (A[i - 1] > A[i])
		{
			ans += (A[i - 1] - A[i]);
			A[i] = A[i - 1];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4784
#include <iostream>
using namespace std;
using ll = long long;

int main() {
    ll x; cin >> x;
    int gohyaku = x / 500;
    x -= 500 * gohyaku;
    int go =  x / 5;
    cout << gohyaku * 1000 + go * 5 << endl;
}


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

using namespace std;

template <typename T>
struct edge {
	int from, to;
	T cost;

	edge(int from, int to, T cost) :from(from), to(to), cost(cost) {}
};

template <typename T>
vector<T> bellman_ford(int s, int V, vector<edge<T> >& G) {
	const T INF = numeric_limits<T>::max();
	vector<T> cost(V, INF);
	cost[s] = 0;
	for (int i = 0; i < V; ++i) {
		for (edge<T> e : G) {
			if (cost[e.from] == INF) continue;
			if (cost[e.to] > cost[e.from] + e.cost) {
				cost[e.to] = cost[e.from] + e.cost;
				if (i == V - 1 && e.to == V - 1) return vector<T>();
			}
		}
	}
	return cost;
}

int main() {
	int n,m; cin >> n >> m;
	vector<edge<long long> > G;
	for(int i=0;i<m;++i) {
		int a,b,c; cin >> a >> b >> c;
		--a, --b;
		G.push_back({a,b,-c});
	}
	auto ans=bellman_ford(0,n,G);
	if(ans.empty()) cout << "inf" << endl;
	else cout << -ans[n-1] << endl;
	
	return 0;
}


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

int main()
{
  int a, b, c;
  
  cin >> a >> b;
  
  if(a == 1){
    if(b == 2)
      cout << 3;
    else
      cout << 2;
  }
  else if (a == 2){
    if(b == 1)
      cout << 3;
    else
      cout << 1;
  }
  else{
    if(b == 2)
      cout << 1;
    else
      cout << 2;
  }
  
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n, m, x, i;
	cin >> n >> m;
	if(n == 1){
		cin >> x;
		while(m--)
		x /= 2;
		cout << x;
		return 0;
	}
	priority_queue <int> q;
	fo(i, 0, n){
		cin >> x;
		q.push(x);
	}
	while(!q.empty() && m > 0){
		int p = q.top();
		q.pop();
		int p2 = q.top();
		while(p >= p2 && m > 0){
			p /= 2;
			m--;
		}
		q.push(p);
	}
	ll ans = 0;
	while(!q.empty()){
		ans += q.top();
		q.pop();
	}
	cout << ans;
}


Measured memory_bytes: 892
#include <stdio.h>
#include <string.h>

int main()
{
	int X, Y;
	scanf("%d%d", &X, &Y);

	int b = (Y - 2 * X) / 2;
	int a = X - b;
	if (a >= 0 && b >= 0 && a + b == X && 2 * a + 4 * b == Y) {
		puts("Yes");
	}
	else {
		puts("No");
	}

	return 0;
}


Measured memory_bytes: 1648
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

using namespace std;

struct edge {
    int to, from, cost, id;
};

const int MAX_N = 100;
const int MAX_M = 1000;
const int INF = 100000;

int N, M;
int d[MAX_N][MAX_N];
int traced[MAX_N][MAX_N];

vector<edge> G[MAX_N];

bool used[MAX_M];

void tracePath(int i, int j, int& res);

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

    cin >> N >> M;

    fill(d[0], d[MAX_N], INF);

    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        d[a - 1][b - 1] = c;
        d[b - 1][a - 1] = c;
        edge et = { a - 1, b - 1, c, i };
        G[b - 1].push_back(et);
        edge es = { b - 1, a - 1, c, i };
        G[a - 1].push_back(es);
    }

    for (int i = 0; i < N; i++) {
        d[i][i] = 0;
    }

    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
        }
    }

    int res = 0;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            tracePath(i, j, res);
        }
    }

    cout << M - res << "\n";

    return 0;
}

void tracePath(int i, int j, int& res)
{
    if (traced[i][j]) {
        return;
    }
    if (i == j) {
        return;
    }
    vector<edge> v = G[i];
    for (int k = 0; k < v.size(); k++) {
        edge e = v[k];
        if (d[i][j] == e.cost + d[e.to][j]) {
            tracePath(e.to, j, res);
            if (!used[e.id]) {
                res++;
                used[e.id] = true;
            }
        }
    }
    traced[i][j] = 1;
}

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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;

int main ()
{
  prep();
  int n;
  cin >> n;
  int b[n-1];
  for (int i=0; i<n-1; i++){
      cin >> b[i];
  }
  int a[n] = {0};
  a[0] = b[0];
  for (int i=0; i<n-1; i++){
      if (b[i] < a[i]){
          a[i] = b[i];
          a[i+1] = b[i];
      }else{
          a[i+1] = b[i];
      }
  }
  int sum = 0;
  for (int i=0; i<n; i++){
      sum += a[i];
      //cout << a[i] << " ";
  }
  cout << sum;
  return 0; 
}

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

const long long MOD = 1000000007;

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

void solve(long long N, long long K){
    long long notZero=0;
    long long ans =0;
    long long dp[K] = {};
    for(int i=K;i>0;i--){
        int num = K/i;
        long long temp =0;
        temp += myPow(num,N);
        temp %= MOD;
        for(int j=2;j<=num;j++){
            temp =temp-  dp[i*j-1] +MOD;
            temp%=MOD;
        }
        dp[i-1] = temp;
        ans += temp *i;
        ans %= MOD;
        // cerr << "i=" << i << "val =" << dp[i-1] << endl;
    }
    cout << ans << endl;

}

// Generated by 1.1.6 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 K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 4540
#include <iostream>
#include <cstdio>
#define N 200005
using namespace std;

int n, m;
bool a[N];
int main()
{
	int i, t1, t2;
	cin >> n >> m;
	while (m--) {
		scanf("%d %d", &t1, &t2);
		if (t1 == 1 || t1 == n) {
			if (a[t2]) {cout << "POSSIBLE" << endl; return 0;}
			a[t2] = 1;
		}
		if (t2 == 1 || t2 == n) {
			if (a[t1]) {cout << "POSSIBLE" << endl; return 0;}
			a[t1] = 1;
		}
	}
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000000

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

    ll a, b;

    cin >> a >> b;

    cout << (a*b)/__gcd(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const  int maxn = 1e6 + 5;
typedef long long ll;
int a[maxn], h[maxn];
const  ll inf = 1e18;
ll dp[maxn];
int main() {

    int n, k;
//freopen("in.in", "r", stdin);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) dp[i] = inf;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    dp[1] =0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }
//    for (int i = 1; i <=n; i++) cout << dp[i] << " "; cout << endl;
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 5120
// In god we trust

#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>

#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000
#define LINF 1000000000000000
#define int long long
using namespace std;
using namespace std::chrono;



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

  float l;
  cin >> l;
  cout << fixed << l * l * l / 27 << endl;
    
  
}  






Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class AStrings {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s, t;
        in >> s >> t;

        string u = t + s;
        out << u << endl;
	}
};


int main() {
	AStrings solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;


int main(){
  int N,M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  for(int i=0;i<M;i++){
    cin >> L[i] >> R[i];
  }

  int tl = 0;
  int tr = 100000;
  for(int i=0;i<M;i++){
    if(tl < L[i] ){
      tl = L[i];
    }
    if(tr > R[i]){
      tr = R[i];
    }
  }
  if ( tl <= tr ){
    cout << tr - tl + 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
  return 0;

}



Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a % 2 && b % 2 ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
// B.

#include <iostream>
#include <sstream>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
	string a, b;
	cin >> a >> b;
	string s = a + b;
	stringstream ss(s);
	int x;
	ss >> x;
	int r = sqrt(x);
	bool ans = r * r == x;
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
<?php

list($num,$time)=explode(" ",trim(fgets(STDIN)));
$cost =PHP_INT_MAX;

for($i=0;$i<$num;$i++){
    $path=explode(" ",trim(fgets(STDIN)));
    
    if($time>=$path[1]){
    $cost=min($cost,$path[0]);
    }
 
}

if($cost==PHP_INT_MAX){
    echo "TLE";
}else{
   echo $cost;    
}
?>

Measured memory_bytes: 4604
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
from collections import deque
INF = 10**20 

n, m = map(int, input().split())
xseen = set()
xseen.add(INF); xseen.add(-INF)
yseen = set()
yseen.add(INF); yseen.add(-INF)
a_b_c = []
for _ in range(n):
    a, b, c = map(int, input().split())
    xseen.add(a)
    xseen.add(b)
    yseen.add(c)
    a_b_c.append((a, b, c))
d_e_f = []
for _ in range(m):
    d, e, f = map(int, input().split())
    xseen.add(d)
    yseen.add(e)
    yseen.add(f)
    d_e_f.append((d, e, f))

xlen = len(xseen) * 2 - 1
ylen = len(yseen) * 2 - 1

xseen = sorted(list(xseen))
xcomp = {val:i for i, val in enumerate(xseen)}
yseen = sorted(list(yseen))
ycomp = {val:i for i, val in enumerate(yseen)}

field = [[0] * ylen for _ in range(xlen)]
x_range = [0] * xlen
y_range = [0] * ylen
x_range[0] = x_range[-1] = INF
y_range[0] = y_range[-1] = INF
for i, (x1, x2) in enumerate(zip(xseen, xseen[1:])):
    x_range[i * 2 + 1] = x2 - x1
    if x1 <= 0 <= x2:
        sx = i * 2 + 1
for i, (y1, y2) in enumerate(zip(yseen, yseen[1:])):
    y_range[i * 2 + 1] = y2 - y1
    if y1 <= 0 <= y2:
        sy = i * 2 + 1
# print(sx, sy)

for a, b, c in a_b_c:
    y = ycomp[c] * 2
    for x in range(xcomp[a] * 2 + 1, xcomp[b] * 2 + 1, 2):
        field[x][y] = 1 

for d, e, f in d_e_f:
    x = xcomp[d] * 2
    for y in range(ycomp[e] * 2 + 1, ycomp[f] * 2 + 1, 2):
        field[x][y] = 1 

# for line in field:
#     print("".join([item for item in line]))

diff = ((0, 1), (1, 0), (-1, 0), (0, -1))
ans = 0

dq = deque([(sx, sy)])
field[sx][sy] = 1 
ans += x_range[sx] * y_range[sy]
while dq:
    x, y = dq.popleft()
    for dx, dy in diff:
        nx, ny = dx + x, dy + y
        if field[nx][ny]:
            continue
        nx += dx; ny += dy
        if field[nx][ny]:
            continue
        field[nx][ny] = 1 
        dq.append((nx, ny))
        ans += x_range[nx] * y_range[ny] 
        if ans >= INF:
            print("INF")
            exit()

print(ans)

Measured memory_bytes: 433160
#include <iostream>
#include <vector>
#include <sstream>
#include <string>
using namespace std;

vector<int> split(const string &str, char sep) {
    vector<int> v;
    stringstream ss(str);
    string buffer;
    while (getline(ss, buffer, sep)) {
        v.push_back(stoi(buffer));
    }
    return v;
}

int main() {
    string input, output;
    int i;
    vector<int>::iterator begin, end;

    getline(cin, input);
    output = "NO";

    vector<int> vkey = split(input, ' ');

    for (i = 0; i < 3; i++) {
        if (vkey[i] == 7) {
            vkey.erase(vkey.begin() + i);
            if ((vkey[0] == vkey[1]) && (vkey[0] == 5)) {
                output = "YES";
                break;
            }
            break;
        }
    }

    cout << output << endl;
    return 0;
}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){
return a<b?a:b;
}
template <typename T> 

T Max(T a,T b){
return a>b?a:b;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	vl dp(n,0);
	dp[1]=dp[0]+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]));
	db(dp[n-1]); 
	
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

ll memo[100]={};

ll beki(ll i){
    if(memo[i]!=0) return memo[i];
    if(i==0)return 1;
    return 10*beki(i-1);
}

int main() {
    ll n;cin>>n;
    ll v[n];
    ll count[2][100100]={};
    for(ll i=0;i<n;i++){
        cin>>v[i];
        if(i%2==0){
            count[0][v[i]]++;
        }else{
            count[1][v[i]]++;
        }
    }
    ll max[2][2]={};
    ll maxnum[2][2];
    ll j=1;
    for(ll i=0;i<n;i++){
        if(j==1){
            j=0;
        }else{
            j=1;
        }
        if(count[j][v[i]]>max[j][0] && v[i]!=maxnum[j][0] && v[i]!=maxnum[j][1]){
            max[j][1]=max[j][0];
            maxnum[j][1]=maxnum[j][0];
            max[j][0]=count[j][v[i]];
            maxnum[j][0]=v[i];
        }else if(count[j][v[i]]>max[j][1] && v[i]!=maxnum[j][0] && v[i]!=maxnum[j][1]){
            max[j][1]=count[j][v[i]];
            maxnum[j][1]=v[i];
        }
    }
    ll ans;
    if(maxnum[0][0]==maxnum[1][0]){
        if(max[0][0]+max[1][1]>max[0][1]+max[1][0]){
            ans=n-(max[0][0]+max[1][1]);
        }else{
            ans=n-(max[0][1]+max[1][0]);
        }
    }else{
        ans=n-(max[0][0]+max[1][0]);
    }
    
    cout<<ans<<endl;
    
    
    return 0;
}



Measured memory_bytes: 2560
//Power
#include <iostream>

using namespace std;

static const long long MOD = 1000000007;

long long  power(long long m, long long n) {
    if(n == 0) return 1;
    if(n == 1) return m;
    long long res = power(m, n / 2);
    res = res * res % MOD;
    if(n % 2 == 1) res *= m;
    return res % MOD;
}

int main() {
    long long m, n;
    cin >> m >> n;
    cout << power(m, n) << endl;
}


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

using namespace std;

#define int long long
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const int mxn = 2e5+10;

int Mod(int a) {
	return a%mod;
}
int Mul(int a, int b) {
	return Mod(Mod(a) * Mod(b));
}
int Add(int a, int b) {
	return Mod(Mod(a) + Mod(b));
}
//ll fact[mxn];
//ll in_fact[mxn];
//fact[0] = 1;
//for(ll i = 1; i < mxn; i++) {
	//fact[i] = (i*fact[i-1])%mod;
//}
//in_fact[mxn-1] = bigmod(fact[mxn-1],mod-2);
//for(ll i = mxn-2; i >= 0; i--) {
	//in_fact[i] = (in_fact[i+1] * (i+1))%mod;
//}
//ll c(ll n,ll r) {
	//ll ans = (fact[n] * (in_fact[r] * in_fact[n-r]%mod))%mod;
	//return ans;
//}


signed main(){
    fast;
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<max({b*d,a*c,a*d,b*c})<<endl;
			
        
        
    }



return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const { //値をt乗する
    if (!t) return 1; // t == 0
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this; //*thisは元の値(t乗する対象)
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
	ll N,K; cin >> N >> K;
    mint ans = 0;
    ll rui1 = 0,rui2 = 0;
    REP(i,K-1){ rui1 += i; rui2 += N-i;}
    REP2(i,K,N+2){
      rui1 += i-1; rui2 += N-i+1;
      ans += mint(rui2 - rui1 + 1);
    }
    cout << ans.x << endl;

  	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
long long ans=0;
for(long long i=0;i<s.size()/2;i++){
    if(s[i]!=s[s.size()-1-i]){
        break;
    }
    if(i==s.size()/2-1){
        ans=1;
    }
}
if(ans==0){
    cout<<"No"<<endl;
}
else{
for(long long i=0;i<(s.size()-1)/2;i++){
    if(s[i]!=s[(s.size()-1)/2-1-i]){
        break;
    }
    if(i==(s.size()-1)/2-1){
        ans=2;
    }
}
if(ans==1){
    cout<<"No"<<endl;
}
else{
for(long long i=(s.size()+3)/2-1;i<s.size();i++){
    if(s[i]!=s[s.size()-1-i]){
        break;
    }
    if(i==s.size()-1){
        ans=3;
    }
}
if(ans==2){
    cout<<"No"<<endl;
}
else if(ans==3){
    cout<<"Yes"<<endl;
}
}
}
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())

R = S.count("R")
G = S.count("G")
B = S.count("B")

def f(S):
  N = len(S)
  ret = 0
  for i in range(N):
    for j in range(i+1, N):
      k = j + j -i
      if k >= N:
        break
      if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
        ret += 1
  return ret

ans = R * B * G - f(S)
print(ans)

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

using namespace std;

int a, b;
long long ans;

int main() {
  scanf("%d %d", &a, &b);

  if (a > b) swap(a, b);

  for (int i = 1; i <= b; i++) {
    printf("%d", a);
  }
}


Measured memory_bytes: 128
a1, a2, a3 = map(int, input().split())
ans = []
#1 2 3
mini = 0
mini += abs(a2-a1)
mini += abs(a3-a2)
ans.append(mini)

#1 3 2
mini = 0
mini += abs(a3-a1)
mini += abs(a2-a3)
ans.append(mini)

#2 1 3
mini = 0
mini += abs(a1-a2)
mini += abs(a3-a1)
ans.append(mini)

print(min(ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=1000001 ;
ll  power(ll  i,ll  j)
{
    if(j==0)
    return 1 ;
    ll t=power(i,j/2)%maa ;
    if(j%2==0)
    return (t%maa*t%maa)%maa ;
    else
    return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
}
int main()
{
   fast ;
   ll n ;
   cin>>n ;
   ll g=1 ;
   vector<ll>v(n) ;
   for(ll i=0;i<n;i++)
    cin>>v[i] ;

   ll spf[N] ;
   for(ll i=0;i<N;i++)
   {
       spf[i]=i ;
   }
   for(ll i=2;i<N;i++)
   {
       if(spf[i]==i)
       {
           for(ll j=2*i;j<N;j+=i)
           {
               if(spf[j]==j)
               {
                   spf[j]=i ;
               }
           }
       }
   }

   ll ar[N] ;
   memset(ar,0,sizeof(ar)) ;
   for(ll i=1;i<n;i++)
   {
       ll n=v[0] ;
       ll d=v[i] ;
       ll o=__gcd(n,d) ;
       n/=o ;
       d/=o ;
       unordered_map<ll,ll>mm ;
       while(d!=1)
       {
           ll x=spf[d] ;
           d/=x ;
           mm[x]++ ;
       }
       
       for(auto it=mm.begin();it!=mm.end();it++)
       {
           ll x=it->ff ;
           ll y=it->ss ;
           ar[x]=max(ar[x],y) ;
       }
       
   }

   for(ll i=1;i<N;i++)
   {
       g=(g*power(i,ar[i]))%maa ;
   }
   ///cout<<g<<endl ;
   ll ans=g ;
   for(ll i=1;i<n;i++)
   {
       ll x=(g*v[0])%maa ;
       x=(x*power(v[i],maa-2))%maa ;
       ans=(ans+x)%maa ;
   }
   cout<<ans ;


}


Measured memory_bytes: 16000
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


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

	if (b.length() != a.length())cout << (b.length()<a.length() ? "GREATER" : "LESS") << endl;
	else {
		for (int i = 0; i < a.length(); i++) {
			if (a[i] > b[i])return cout << "GREATER" << endl, 0;
			else if (a[i] < b[i])return cout << "LESS" << endl,0;
		}
		cout << "EQUAL" << endl;
	}
}

Measured memory_bytes: 256
s=list(input())

def judge(s):
    if s[0] != 'A': return 'WA'
    elif s[2:-1].count('C') != 1: return 'WA'
    del s[s[2:-1].index('C')+2]
    del s[0]
    s=''.join(s)
    if s.lower()==s: return 'AC'
    else: return 'WA'
        
print(judge(s))

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
 
 #define ab(a) ((a)>=0?(a):-(a))
 
int main(void){
	int n; cin >> n;
	lli a[n], b[n];
	rep(i, n) cin >> a[i] >> b[i];
	
	lli add = 0;
	
	irep(i, n) add += (b[i]-((a[i]+add)%b[i]))%b[i];
	
	cout << add << endl;
	
	return 0;
}

Measured memory_bytes: 1792
import math

N = int(input(""))
A = list(map(int,input().split()))

m = {}
for i in A:
    if i in m:
        m[i] = m[i] + 1
    else:
        m[i] = 1


for i in range(1,N+1):
    
    if i in m:
        print(m[i])
    else:
        print(0)



Measured memory_bytes: 33608
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ul>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x)
{
    return x*x;
}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << fixed;
    cout.precision(13);
    int n,k;
    cin>>n>>k;
    double ans = 0 ;
    int i = 0;
    for( i =1;i<=n;i++)
    {
        double x = 1.0/n;
        int c = i;
        while(c < k)
        {
            c = c<<1;
            x /= 2;
        }
        ans += x;
    }
    cout << ans;
    

       
    return 0;
}
    


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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static const int MOD = 1000000007;
static const int INF = ((1<<30)-1);
static const s64 LINF = ((1LL << 62)-1);

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    string s,t;
	cin >> s >> t;
	
	map<char,char> ma, rev;
	bool res = true;
	FOR(i,s.size()) {
		if (ma.count(s[i]) && ma[s[i]] != t[i]) {
			res = false;
			break;
		} else ma[s[i]] = t[i];
		if (rev.count(t[i]) && rev[t[i]] != s[i]) {
			res = false;
			break;
		} else rev[t[i]] = s[i];
	}
	cout << (res ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 776
function main(input){
  const lines = input.split('\n')
  const N = lines[0].split(' ').map(x => parseInt(x))[0];
  const X = lines[0].split(' ').map(x => parseInt(x))[1];
  const L = lines[1].split(' ').map(x => parseInt(x));

  var result = 1;
  var len = 0;
  for(var i=0;i<N;i++){
    len+=L[i];
    if(len > X){
      break;
    }
    result++;
  }

  console.log(result);

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 21064
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include<climits>
#include<set>
#include<bitset>
#include<random>
using namespace std;

typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define maxs(a,b) a = max(a,b)
#define mins(a,b) a = min(a,b)
#define rep(i,n) for(int i = 0;i < n;i++)


ll n,k;
vector<pair<ll,ll>> a(200020);
int main(void){
   scanf("%lld %lld",&n,&k);
   for(ll i = 0;i < n;i++){
      ll x,y;scanf("%lld %lld",&x,&y);
      a[i] = mp(x,y);
   }
   
   ll ans = 0;
   ll Q = k;
   ll tmp = 0;
   for(ll i = 0;i < n;i++){
      if(Q == (Q | a[i].first)) tmp += a[i].second;
   }
   maxs(ans,tmp);
   for(ll r = 30;r >= 0;r--){
      ll tmp = 0;
      if((k >> r) & 1){
         
         ll Q = 0;
         for(ll i = 31;i > r;i--){
            Q += ((k >> i) & 1) << i;
         }
         for(ll i = r - 1;i >= 0;i--){
            Q += (1 << i);
         }
         
         for(ll i = 0;i < n;i++){
            if(Q == (Q | a[i].first)) tmp += a[i].second;
         }
         maxs(ans,tmp);
      }
   }
   
   
   printf("%lld\n",ans);
   return 0;
}

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

long func(long x){
	return x*x;
}

int main(){
	int d;
	while ( scanf(" %d", &d) != EOF ){
		long area=0;
		for(int i=0; i<600/d; ++i)
			area += d*func(i*d);
	
		printf("%ld\n", area);
	}

	return 0;
}

Measured memory_bytes: 1184
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
#include <iostream>
using namespace std;



int main()
{
  int n;  cin >> n;
  int a0 = 0;
  int a2 = 0;
  for(int i=0;i<n;i++){
    int tmp;
    cin >> tmp;
    if(tmp%4 == 0){
      a2++;
    }
    else if(tmp%2 == 1){
      a0++;
    }
  }

  if(a0 <= a2)
    cout << "Yes" << endl;
  else if(n%2 == 1 && a0 - 1 == a2 && a0 + a2 == n)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,x;
	cin>>a>>b>>x;
	if(a>x)
	{
		cout<<"NO";
		return 0;
	}
	if(a==x || a+b>x)
	{
		cout<<"YES";
		return 0;
	}
	if(a+b<x)
	{
		cout<<"NO";
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
//import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int W=sc.nextInt();
        int A[]=new int[W];
        for(int i=0;i<W;i++) A[i]=i+1;
        int N=sc.nextInt();
        for(int i=0;i<N;i++){
            String S=sc.next();
            int l=S.length();
            char C[]=S.toCharArray();
            int a=0;
            int b=0;
            int now=0;
            while(C[now]!=','){
                a=a*10+C[now]-'0';
                now++;
            }
            now++;
            for(int j=now;j<l;j++) b=b*10+C[j]-'0';
            a--;
            b--;
            int tmp=A[a];
            A[a]=A[b];
            A[b]=tmp;
        }
        for(int i=0;i<W;i++) System.out.println(A[i]);
    }
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N;
    cin >> N;

    vi x(N), y(N); vector<char> dir(N);

    vvi xg(4), yg(4);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> dir[i];
    }

    auto check = [&](double tr) {
        vector<double> dims = { INT_MAX, INT_MIN, INT_MAX, INT_MIN };
        for (int i = 0; i < N; i++) {
            double xx = x[i], yy = y[i];
            if (dir[i] == 'U') yy += tr;
            if (dir[i] == 'D') yy -= tr;
            if (dir[i] == 'L') xx -= tr;
            if (dir[i] == 'R') xx += tr;

            dims[0] = min(dims[0], xx);
            dims[1] = max(dims[1], xx);
            dims[2] = min(dims[2], yy);
            dims[3] = max(dims[3], yy);
        }
        return (dims[1] - dims[0]) * (dims[3] - dims[2]);
    };

    double ans = DBL_MAX, lo = 0, hi = 1e9;

    for (int iter = 0; iter < 100; iter++) {
        double p1 = (2 * lo + hi) / 3, c1 = check(p1);
        double p2 = (lo + 2 * hi) / 3, c2 = check(p2);

        ans = min({ ans, c1, c2 });
        if (c1 < c2) hi = p2;
        else lo = p1;
    }

    cout << setprecision(15);
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <set>

using namespace std;
using ll = long long;
using ld = long double;

const string YES = "YES";
const string NO = "NO";

void solve(ll, vector<ll> A) {
  bool pred = true;

  set<int> s;
  for (auto e: A) {
    if (s.count(e)) {
      pred = false;
      break;
    }
    s.insert(e);
  }
  
  cout << (pred ? YES : NO) << endl;
}

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  solve(N, move(A));
  return 0;
}


Measured memory_bytes: 11136
#include <cstdio>
#include <algorithm>
int N, K;
long long a[100001], s[100001], f[100001], O;
int main()
{
	scanf("%d%d", &N, &K);
	for (int i = 1; i <= N; i++)
		scanf("%lld", a + i);
	for (int i = 1; i <= N; i++)
	{
		s[i] = s[i - 1] + a[i];
		f[i] = f[i - 1] + std::max(a[i], 0LL);
	}
	for (int i = K; i <= N; i++)
		O = std::max(O, std::max(s[i] - s[i - K], 0LL) + f[i - K] + f[N] - f[i]);
	printf("%lld\n", O);
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  ll a,b;
  cin>>a>>b;
  repeat(x,1,10000) {
    if((8*x)/100==a && (10*x)/100==b) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define name(x) #x
using namespace std;


const int INF = INT_MAX;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int H, W;
    cin >> H >> W;
    VV(char) A(H+1,vector<char>(W+1,'.'));
    for(auto i = 1; i<=H; i++){
        for(auto j = 1; j<=W; j++){
            cin >> A[i][j];
        }
    }
    
    VV(ll) path(H+1,vector<ll>(W+1,0));
    int w = 1;
    int h = 1;
    while(w <=W && A[1][w]!= '#'){
        path[1][w] = 1;
        w++;
    }

    
    while(h<=H &&A[h][1]!= '#'){
        path[h][1] = 1;
        h++;
    }
    
    for(auto h = 2; h<=H; h++){
        for(auto w = 2; w <=W; w++){
            path[h][w] = (path[h][w-1] + path[h-1][w]) %MOD;
            if (A[h][w] == '#') path[h][w] = 0;
        }
    }
    
    
    cout << path[H][W] << endl;
    
    return 0;
}




Measured memory_bytes: 9088
#include <stdio.h>
#include <string.h>

int main(){

    int i,lenp;
    char moji_s[202],moji_p[202],moji_x[202],moji_y[202],*sp,*p;
    
    scanf("%s",moji_s);
    scanf("%s",moji_p);
     
    i=0;
     
    lenp=strlen(moji_s); 

    sp=moji_s;
   
	for (i=0;i<lenp;++i){ 
          
    strcpy(moji_x,sp+1); 
     
    strncat(moji_x,sp,1);
    
    //printf("moji_x %s\n",moji_x);
    
    p=strstr(moji_x,moji_p);
   
    if (p!= NULL) {
		printf ("Yes\n");
		return 0;
	}
       
    strcpy(moji_y,moji_x);
    
    sp=moji_y;
       
    }

    printf("No\n");
  
    return 0;
}

Measured memory_bytes: 540