akhauriyash/Code-Regression huggingface dataset:
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N, A, B;
	std::cin >> N >> A >> B;
	std::cout << std::min(A*N, B) << "\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

#define ll long long

using namespace std;

int main() {
    bool ans[101];
    int n, m, d, a, num = 0;
    cin >> n >> m;
    for (int i = 0; i <= n; i ++){
        ans[i] = false;
    }
    for(int j = 0; j < m; j++){
        cin >> d;
        for(int k = 0; k < d; k++){
            cin >> a;
            ans[a] = true;
        }
    }
    for (int i = 1; i <= n; i ++){
        if(!ans[i]){
            num++;
        }
    }
    cout << num << endl;
}

Measured memory_bytes: 3624
// F.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int n, k;
vector<double> x, y, c;

struct Point {
	double x;
	double y;
	double dist(const Point& p) {
		double dx = x - p.x, dy = y - p.y;
		return sqrt(dx * dx + dy * dy);
	}
};

struct Circle {
	Point p;
	double c;
	double r;
	vector<Point> cross(const Circle& c) {
		vector<Point> pp;
		double dist = p.dist(c.p);
		if (dist <= r + c.r && r <= dist + c.r && r + dist >= c.r) {
			double dx = c.p.x - p.x, dy = c.p.y - p.y;
			double a = (dx * dx + dy * dy + r * r - c.r * c.r) / 2, dd = dx * dx + dy * dy;
			pp.push_back({
				(a * dx + dy * sqrt(dd * r * r - a * a)) / dd + p.x,
				(a * dy - dx * sqrt(dd * r * r - a * a)) / dd + p.y
			});
			pp.push_back({
				(a * dx - dy * sqrt(dd * r * r - a * a)) / dd + p.x,
				(a * dy + dx * sqrt(dd * r * r - a * a)) / dd + p.y
			});
		}
		return pp;
	}
};

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		n = -1;
		cin >> n >> k;
		if (n < 0) return 0;
		x.resize(n);
		y.resize(n);
		c.resize(n);
		vector<Circle> cc(n);
		for (int i = 0; i < n; ++i) {
			cin >> x[i] >> y[i] >> c[i];
			cc[i].p.x = x[i];
			cc[i].p.y = y[i];
			cc[i].c = c[i];
		}
		double left = 0, right = 1e9;
		for (int t = 0; t < 100; ++t) {
			double mid = (left + right) / 2;
			for (int i = 0; i < n; ++i) {
				cc[i].r = mid / cc[i].c;
			}
			vector<Point> pp;
			for (int i = 0; i < n; ++i) {
				pp.push_back(cc[i].p);
				for (int j = i + 1; j < n; ++j) {
					for (auto p : cc[i].cross(cc[j])) {
						pp.push_back(p);
					}
				}
			}
			int mc = 0;
			for (auto p : pp) {
				int cnt = 0;
				for (auto c : cc) {
					cnt += p.dist(c.p) <= c.r + 1e-12;
				}
				mc = max(mc, cnt);
			}
			if (mc >= k) {
				right = mid;
			} else {
				left = mid;
			}
		}
		cout << right << endl;
	}
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

import java.lang.Math;

public class Main {
  private static final int MAX_A = 1000000000;

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

    int num_neg = 0;
    long sum_abs = 0;
    int min_abs = MAX_A;
    for (int i = 0; i < N; i++) {
      int A = scanner.nextInt();
      num_neg += A < 0 ? 1 : 0;
      sum_abs += Math.abs(A);
      min_abs = Math.min(min_abs, Math.abs(A));
    }

    long ans;
    if (num_neg % 2 == 0)
      ans = sum_abs;
    else
      ans = sum_abs - min_abs * 2;
    System.out.println(ans);
  }
}


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

int main()
{
  float h,w,n;
  int ans;
  cin >> h >> w >> n;
  if(h > w){
    ans = (int) (n+h-1)/h;
  }else{
    ans = (int) (n+w-1)/w;
  }
  cout << ans << endl;
  return 0;
}


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

const int INF = 0x3f3f3f3f;
const int MOD = (int) 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector< vector<char> > a(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }
  vector< vector<int> > dp(h, vector<int>(w, 0));
  dp[0][0] = 1;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == '#') {
        continue;
      }
      if (i + 1 < h) {
        dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
      }
      if (j + 1 < w) {
        dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % MOD;
      }
    }
  }
  cout << dp[h - 1][w - 1] << '\n';
  return 0;
}

Measured memory_bytes: 5248
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(A: int, B: int, C: int):
    five_a_seven = {5, 7}
    abc = {A, B, C}
    if(five_a_seven & abc == five_a_seven and A+B+C == 17):
        print(YES)
        return YES
    else:
        print(NO)
        return NO


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        s: Chars,
    }

    for i in 0..s.len() {
        if i%2==0 {
            print!("{}", s[i]);
        }
    }
    print!("\n");
}


Measured memory_bytes: 2512
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

std::string make_code(int i_p, int i_c) {
	char buf[100];
	sprintf(buf, "%06d%06d", i_p + 1, i_c + 1);
	return std::string(buf);
}

int main(void) {
	// input
	int n, m;
	std::cin >> n >> m;
	std::vector<int> p(m);
	std::vector<long long> y(m);
	for(int i = 0; i < m; ++i) std::cin >> p[i] >> y[i];

	// pref list
	std::vector<std::vector<std::pair<int, long long>>> p_list(n);
	for(int i = 0; i < m; ++i) {
		p_list[p[i] - 1].push_back(std::make_pair(i, y[i]));
	}
	for(int i = 0; i < n; ++i) {
		std::sort(p_list[i].begin(), p_list[i].end(), [](std::pair<int, long long> &lhs, std::pair<int, long long> &rhs){ return lhs.second < rhs.second; });
	}

	// city list
	std::vector<std::pair<int, std::string>> c_list;
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < p_list[i].size(); ++j) {
			std::string code = make_code(i, j);
			c_list.push_back(std::make_pair(p_list[i][j].first, code));
		}
	}
	std::sort(c_list.begin(), c_list.end(), [](std::pair<int, std::string> &lhs, std::pair<int, std::string> &rhs){ return lhs.first < rhs.first; });

	for(int i = 0; i < m; ++i) {
		std::cout << c_list[i].second << std::endl;
	}

	return 0;
}


Measured memory_bytes: 14320
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N, K;
    vector<int> A;
    cin >> N >> K;
    REP(i, N) {
        A.push_back(i+1);
    }
    REP(i, K) {
        int d;
        cin >> d;
        REP(j, d) {
            int a;
            cin >> a;
            A.erase(remove(A.begin(), A.end(), a), A.end());
        }
    }
    cout << A.size() << endl;
    return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

struct UnionFind {
  vi parent, rank, count;
  UnionFind(const int nodeSize)
    : parent(nodeSize), rank(nodeSize, 1), count(nodeSize) {
    rep(i, nodeSize) parent[i] = i, count[i] = 1;
  }
  int find(int x) {
    if (parent[x] == x) return x;
    return parent[x] = find(parent[x]);
  }
  void unite(int x, int y) {
    int rx = find(x);
    int ry = find(y);
    if (rx == ry) return;
    if (rank[rx] < rank[ry]) swap(rx, ry);
    parent[ry] = rx;
    count[rx] += count[ry];
    if (rank[rx] == rank[ry]) ++rank[rx];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int num(int x) {
    return count[find(x)];
  }
};

int n, m, q;
int ans;
vi vec, a, b, c, d;
void check() {
  int tmp = 0;
  rep(i, q) {
    if (vec[b[i]] - vec[a[i]] == c[i])
      tmp += d[i];
  }
  chmax(ans, tmp);
}
void dfs(int d) {
  if (d == n) {
    check();
    return;
  }
  int start = (d == 0 ? 1 : vec[d-1]);
  srep(x, start, m+1) {
    vec[d] = x;
    dfs(d+1);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  std::cin >> n >> m >> q;
  vec.resize(n);
  a.resize(q), b.resize(q), c.resize(q), d.resize(q);
  rep(i, q) {
    std::cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--, b[i]--;
  }
  dfs(0);
  std::cout << ans << "\n";
}


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  string s;
  cin >> n >> s;

  int ret = 0;
  REP(i, n) {
    vector<bool> flag1(n, false), flag2(n, false);
    REP(j, i) flag1[s[j]-'a'] = true;
    FOR(j, i, n) flag2[s[j]-'a'] = true;

    int tmp = 0;
    REP(j, 26) if(flag1[j] && flag2[j]) tmp++;
    chmax(ret, tmp);
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in();
    ll a = n / 1000, b = n / 100 % 10, c = n / 10 % 10, d = n % 10;
    ll foo[2] = { 1,-1 };
    REP(j, 2) {
        REP(k, 2) {
            REP(l, 2) {
                if (a + b * foo[j] + c * foo[k] + d * foo[l] == 7) {
                    char bar[2] = { '+','-' };
                    printf("%d%c%d%c%d%c%d=7", a, bar[j], b, bar[k], c, bar[l], d);
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256
//use itertools::Itertools;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        k: usize,
        s: chars
    }

    if k >= s.len() {
        for i in 0..s.len() {
            print!("{}", s[i]);
        }
        println!("");
    } else {
        for i in 0..k {
            print!("{}", s[i]);
        }
        println!("...");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2232
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;
int f_stamp[103];
int e_stamp[103];
vector<vector<int> > edge;
int t;
void dfs(int v){
	f_stamp[v] = ++t;
	REP(i,edge[v].size()){
		if(not f_stamp[edge[v][i]]){
			dfs(edge[v][i]);
		}
	}
	e_stamp[v] = ++t;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;
	cin>>n;
	edge.resize(n,vector<int>());
	REP(i,n){
		int v;cin>>v;v--;int t;cin>>t;
		while(t--){
			int u;cin>>u;u--;
			edge[v].push_back(u);
		}
	}
	REP(i,n){
		if(not f_stamp[i]){
			dfs(i);
		}
	}
	REP(i,n){
		cout << i+1 << ' ' << f_stamp[i] << ' ' << e_stamp[i] << endl;
	}
  return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int a,b,c,d,e;
	cin >> a >> b >>c >>d >>e;

	cout << 15 - (a+b+c+d+e);
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;


int main() {
	long long int a[2],b[2];
	cin >> a[0] >> a[1] >> b[0] >> b[1];
	long long int maxi = -1000000000000000000;
	for (long long int i = 0; i <= 1; i++) {
		for (long long int j = 0; j <= 1; j++) {
			maxi = max(a[i] * b[j], maxi);
		}
	}
	cout << maxi;


	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    ll n; cin >> n;
    ll mi = INF, ma = -1;
    vector<ll> v1(n), v2(n);
    rep(i, n){
        ll x, y; cin >> x >> y;
        v1[i] = x-y, v2[i] = x+y;
    }
    sort(all(v1));
    sort(all(v2));
    cout << lmax(v1[n-1]-v1[0], v2[n-1]-v2[0]) << endl;
}


Measured memory_bytes: 6416
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=1;;i++){
    int c=0;
    for(int j=1;j<=i;j++){
      if(i%j==0)c++;
    }
    if(c==n){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 3096
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<pii,int> ppiii ;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
int main(){
	int n;
	string s,t;
	cin>>n;
	cin>>s>>t;
	for(int i=0;i<n;i++){
		bool flag=true;
		for(int j=0;j<n-i;j++){
			if(s[i+j]!=t[j])flag=false;
		}
		if(flag){
			cout<<n+i<<endl;
			return 0;
		}
	}
	cout<<2*n<<endl;
}


Measured memory_bytes: 256
#入力に1~4が現れる回数
counter = [0,0,0,0]

#入力をリストに格納していく
ip = []
a1, b1 = map(int,input().split())
ip.append(a1)
ip.append(b1)
a2, b2 = map(int,input().split())
ip.append(a2)
ip.append(b2)
a3, b3 = map(int,input().split())
ip.append(a3)
ip.append(b3)

#数字ごとの出現回数をカウント
for city in ip:
    counter[city - 1] += 1

#3回現れる数字があればX
counter.sort()
if counter[3] == 3:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3064
local abs = math.abs
local X, K, D = io.read("n", "n", "n")

local abs_X = abs(X)

local K_of_carrent_X = abs_X // D
local carrent_X = abs_X % D
if K <= K_of_carrent_X then
	print(abs(abs_X - K * D))
elseif (K - K_of_carrent_X) % 2 == 0 then
	print(abs(carrent_X))
else
	print(abs(carrent_X - D))
end


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

int main()
{
    long X, Y;
    cin >> X >> Y;

    long Z = (Y / X);
    long ans = 1;
    while (Z > 1)
    {
        ans++;
        Z /= 2;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string.h>
using namespace std;

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

    for(int i=0; i<s.length(); i++){
        if(i % 2 == 0){
            cout << s[i];
        }
    }   
    cout << '\n';
    return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
#include <numeric>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back


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

    int K, A, B;
    cin >> K >> A >> B;
    
    int i = 1;
    string ret;

    while(true){
        int KK = K*i;
        if(A<=KK && KK<=B){
            ret = "OK";
            break;
        }else if(B<KK){
            ret = "NG";
            break;
        }
        i++;
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 3612
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto U = readln.chomp;
    auto A = readln.split.map!(to!long).array;

    auto STB = M.iota.map!(_ => readln.split.map!(to!int).array).array;
    auto mp = new long[][](N, N);

    foreach (stb; STB) {
        int S = stb[0] - 1;
        int T = stb[1] - 1;
        long B = stb[2];
        if (S > T) swap(S, T);
        mp[S][T] += B;
    }

    auto source = N;
    auto sink = N + 1;
    auto FF = new FordFulkerson(N+2, source, sink);

    foreach (i; 0..N) {
        FF.add_edge(source, i, U[i] == 'L' ? A[i] : 0);
        FF.add_edge(i, sink, U[i] == 'L' ? 0 : A[i]);
    }


    foreach (i; 0..N) {
        foreach (j; i+1..N) {
            if (mp[i][j] == 0) continue;
            FF.add_edge(j, i, mp[i][j]);
        }
    }

    FF.run.writeln;
}


class FordFulkerson {
    int N, source, sink;
    int[][] adj;
    long[][] flow;
    bool[] used;

    this(int n, int s, int t) {
        N = n;
        source = s;
        sink = t;
        assert (s >= 0 && s < N && t >= 0 && t < N);
        adj = new int[][](N);
        flow = new long[][](N, N);
        used = new bool[](N);
    }

    void add_edge(int from, int to, long cap) {
        adj[from] ~= to;
        adj[to] ~= from;
        flow[from][to] = cap;
    }

    long dfs(int v, long min_cap) {
        if (v == sink)
            return min_cap;
        if (used[v])
            return 0;
        used[v] = true;
        foreach (to; adj[v]) {
            if (!used[to] && flow[v][to] > 0) {
                auto bottleneck = dfs(to, min(min_cap, flow[v][to]));
                if (bottleneck == 0) continue;
                flow[v][to] -= bottleneck;
                flow[to][v] += bottleneck;
                return bottleneck;
            }
        }
        return 0;
    }

    long run() {
        long ret = 0;
        while (true) {
            foreach (i; 0..N) used[i] = false;
            long f = dfs(source, long.max);
            if (f > 0)
                ret += f;
            else
                return ret;
        }
    }
}



Measured memory_bytes: 6352
#include <iostream>
#include <vector>

using namespace std;

int cnt;

void insertion_sort(vector<int>& a, int g) {
	int val,ind;
	int size = a.size();
	for (int i = g; i < size; ++i) {
		val = a[i];
		ind = i-g;
		while (ind >= 0 && a[ind] > val) {
			a[ind+g] = a[ind];
			ind -= g;
			++cnt;
		}
		a[ind+g] = val;	
	}
	return;
}

void shell_sort(vector<int>& a) {
	cnt = 0;
	int m = 0;
	int now = 1;
	while (now < a.size()) {
		now = 3*now + 1;
		++m;
	}
	if (m == 0) {
		m = 1;
	}
	else {
		now = (now-1)/3;
	}
	vector<int> G(m);
	for (int i = 0; i < m; ++i) {
		G[i] = now;
		now = (now-1)/3;
	}
	cout << m << endl;
	for (int i = 0; i < m; ++i) {
		cout << G[i];
		insertion_sort(a,G[i]);
		if (i < m-1) {
			cout << " ";
		}
	}
	cout << endl;
	cout << cnt << endl;
	for (int i = 0; i < a.size(); ++i) {
		cout << a[i] << endl;
	}
	return;
}

int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	shell_sort(a);
	return 0;
}



Measured memory_bytes: 6792
using System;

class Program
{
  static void Main(string[] args)
  {
    int N = int.Parse(Console.ReadLine());
    bool flag = false;
    for (int i = 0; i <= N / 4; i++)
    {
      for (int j = 0; j <= N / 7; j++)
      {
        if (4 * i + 7 * j == N)
        {
          flag = true;
          break;
        }
      }
    }
    if (flag == true)
    {
      Console.WriteLine("Yes");
    }
    else
    {
      Console.WriteLine("No");
    }
  }
}


Measured memory_bytes: 27400
#include <stdio.h>
long long max(long long x, long long y){
    if(x <= y) return y;
    else return x;
}
long long min(long long x, long long y){
    if(x <= y) return x;
    else return y;
}
int main(){
    long long A, B, C, X, Y;
    scanf("%lld %lld %lld %lld %lld", &A, &B, &C, &X, &Y);
    long long res = max(X, Y)*(2*C);
    long long ans = 0;
    if(A + B >= 2*C){
        ans += min(X, Y) * (2 * C);
        ans += (X - min(X, Y)) * A + (Y -  min(X, Y)) * B;
    }
    else ans += A*X + B*Y;
    printf("%lld\n", min(res, ans));
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;


int main(){
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.size();i++){
        if(s[0]==t[i]){
            bool flag=true;
            for(int j=0;i+j<s.size();j++){
                if(s[j]!=t[i+j]){
                    flag=false;
                    break;
                }
            }
            if(flag){
                for(int k=0;k<i;k++){
                    if(t[k]!=s[s.size()-i+k]){
                        flag=false;
                        break;
                    }
                }
            }
            if(flag){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int             long long
#define ld              long double
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int, int>
#define mk(arr,n,type)  type *arr=new type[n];
#define vi              vector<int>
#define si              set<int>
#define usi             unordered_set<int>
#define mii             map<int, int>
#define umii            unordered_map<int, int>
#define pqmax           priority_queue<int>
#define pqmin           priority_queue<int, vi, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define trailzrobits(x) __builtin_ctzll(x)
#define leadzrobits(x)  __builtin_clzll(x)
#define paritybits(x)   __builtin_parityll(x)
#define gcd             __gcd
#define lcm(x, y)       (x * y) / gcd(x, y)
#define mod             1000000007
#define endl            '\n'
#define PI              3.14159265358979323846
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x

void __print(int x) {cout<<x;}
void __print(float x){cout<<x;}
void __print(double x){cout<<x;}
void __print(ld x) {cout<<x;}
void __print(char x){cout <<'\''<<x<<'\'';}
void __print(const char *x){cout <<'\"' <<x<<'\"';}
void __print(const string &x) {cout<<'\"'<<x<<'\"';}
void __print(bool x) {cout<<(x?"true":"false");}
template<typename T,typename V>     void __print(const pair<T,V> &x) {cout<<'{';__print(x.first);cout<<',';__print(x.second);cout<<'}';}
template<typename T>                void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}void _print() {cout << "]\n";}
template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)
#else 
#define dbg(x...)
#endif

int power(int x, int y, int p = mod){
    int res = 1;
    x %= p;
    while(y > 0){
        if(y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res; 
}

int inv(int x, int p = mod){
    return power(x, p - 2) % p;
}

const int N = 1e6 + 6;
 
int32_t main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1;
    // cin >> t;
    while(t--){
       
        int n, m; cin>>n>>m;

        char a[n+1][m+1];
        for(int i=1; i<=n; i++)
            for(int j=1; j<=m; j++)
                cin>>a[i][j];
        
        int dp[n+1][m+1];
        memset(dp, 0, sizeof(dp));
        for(int i=1; i<=n; i++)
            if(a[i][1] != '#')
                dp[i][1] = 1;
            else
                break;
        for(int j=1; j<=m; j++)
            if(a[1][j] != '#')
                dp[1][j] = 1;
            else
                break;
        
        for(int i=2; i<=n; i++){
            for(int j=2; j<=m; j++){
                if(a[i][j] != '#')
                    dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
            }
        }

        int ans = dp[n][m] % mod;
        cout<<ans;
        
    }

    return 0;

}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,n;
	scanf("%d%d",&n,&a);
	while(a--){
		int x;
		scanf("%d",&x);
		n-=x;
	}
	if(n>=0)printf("%d",n);
	else printf("-1");
	return 0;
 } 

Measured memory_bytes: 3864
#include<bits/stdc++.h>
#define rep(xx,yy) for(j=xx;j;j--)\
for(pos=yy-1;~pos;pos--)\
for(l=1;(r=l+pos)<=yy;l++)
const int N=190;
using namespace std;
int n,m,f[N][N][N],g[N][N][N],
i,j,l,r,pos;
char mp[N][N],tr;
bool fl;
int main(){
	scanf("%d%d",&n,&m);
	for(i=1,l,r;i<=n;i++){
		scanf("%s",mp[i]+1);
		for(l=1;l<=m;l++){
			fl=1,tr=mp[i][l];
			for(r=l;r<=m;r++){
				fl&=mp[i][r]==tr;
				if(fl)
				f[i][l][r]=mp[i-1][l]==tr?f[i-1][l][r]:i-1;
				else f[i][l][r]=i;
			}
		}
	}
	for(i=1;i<=m;i++)
	for(l=1;l<=n;l++){
		fl=1,tr=mp[l][i];
		for(r=l;r<=n;r++){
			fl&=mp[r][i]==tr;
			if(fl)
			g[i][l][r]=mp[l][i-1]==tr?g[i-1][l][r]:i-1;
			else g[i][l][r]=i;
		}
	}
	for(i=0;f[n][1][m];i++){
		rep(n,m)
		f[j][l][r]=f[f[j][l][r]][l][r];
		rep(m,n)
		g[j][l][r]=g[g[j][l][r]][l][r];
		rep(n,m)
		g[r][f[j][l][r]+1][j]=min(g[r][f[j][l][r]+1][j],l-1);
		rep(m,n){
			if(l>1)g[j][l][r]=min(g[j][l][r],g[j][l-1][r]);
			if(r<n)g[j][l][r]=min(g[j][l][r],g[j][l][r+1]);
			f[r][g[j][l][r]+1][j]=
			min(f[r][g[j][l][r]+1][j],l-1);
		}
		rep(n,m){
			if(l>1)f[j][l][r]=min(f[j][l][r],f[j][l-1][r]);
			if(r<m)f[j][l][r]=min(f[j][l][r],f[j][l][r+1]);
		}
	}
	printf("%d",i);
}

Measured memory_bytes: 53376
word = input()

while True:
    if(word[0]==word[1]):
        if((word[2]==word[3])and(word[0]!=word[2])):
            print("Yes")
            break
    if(word[0]==word[2]):
        if(word[1]==word[3])and(word[0]!=word[1]):
            print("Yes")
            break    
    if(word[0]==word[3]):
        if((word[1]==word[2])and(word[0]!=word[1])):
            print("Yes")
            break
    if((word[1]==word[2])and(word[0]==word[1])):
        print("No")
        break
    if((word[1]==word[3])and(word[0]==word[1])):
        print("No")
        break
    if((word[1]==word[3])and(word[2]==word[1])):
        print("No")
        break
    else:      
        print("No")
        break

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

void finish(){
	show("No");
	exit(0);
}

int32_t main(){
    fast_io;
    int n;
    cin>>n;
    n = 1<<n;
    multiset<int>s;
    for (int i = 0; i < n; ++i)
    {
    	int x;
    	cin>>x;
    	s.insert(x);
    }
    vi v;
    v.emplace_back(*s.rbegin());
    s.erase(s.find(v.back()));
    while(!s.empty()){
    	sort(v.rbegin(), v.rend());
    	vi temp;
    	for(const auto &it:v){
    		if(it <= *(s.begin())) finish();
    		auto j = s.lower_bound(it);
    		j--;
    		temp.emplace_back(*j);
    		s.erase(j);
    	}
    	for(const auto &it:temp) v.emplace_back(it);
    }
	
	show("Yes");
    return 0;
}

Measured memory_bytes: 17104
/**
 *      ABC 66 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-04 23:30:57
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c; cin >> a >> b >> c;
    cout << min(min(a + b, b + c), a + c) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int main(){
    ll n;
    cin >> n;
    ll m;
    cin >> m;
    ll count=m*1900+(n-m)*100;
    ll a=1;
    rep(i,m) a*=2;
    cout<<count*a<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define foritr(itr, A) for(set<ll>::iterator itr = A.begin(); itr != A.end(); itr++)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define cr(x) cerr << #x << " = " << x << "\n";
#define crA(x, A) cerr << #x << " = " << A[x] << "\n";
#define spacing if(db)cout << " ";
#define space " "
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, d, A[MAXN],l[MAXN],r[MAXN];
struct _ufds
{
	ll p[MAXN];
	_ufds() { for(ll i = 1; i <= n; i++) p[i] = i; }
	ll find(ll x) { return (p[x] == x) ? x : p[x]=find(p[x]); }
	void merge(ll x, ll y) { p[find(x)] = find(y); }
	bool same(ll x, ll y) { return find(x) == find(y); }
} ufds;
struct node{
	ll s,e,m; pi v;
	node*l,*r;
	node(ll _s,ll _e){ s = _s, e = _e, m = (s+e)/2; v = pi(LLINF,LLINF); if(s!=e) { l = new node(s, m); r = new node(m+1, e); }else v.s=s; }
	void update(ll x, ll nv)
	{
		if(s==e) { v.f = nv;  return ; }
		if(x > m) r->update(x, nv);
		else l->update(x, nv);
		v = min(l->v, r->v);
	}
	pi rmq(ll x, ll y)
	{
		if(x>y)return pi(LLINF,LLINF);
		if(s==x&&e==y)
		{
			return v;
		}
		if(x > m) return r->rmq(x, y);
		else if( y<=m) return l->rmq(x, y);
		else return min(l->rmq(x, m), r->rmq(m+1, y));
	}
} *segL, *segR;
ll ans, o[MAXN];
vector <spi> edges;
int main()
{
	cin>>n>>d;
	FOR(i,1,n+1){cin>>A[i];o[i]=i;}
	FOR(i,1,n+1) { l[i] = -i*d+A[i]; }
	FOR(i,1,n+1) { r[i] = i*d+A[i]; }
	ufds = _ufds();
	segL = new node(1, n);
	segR = new node(1, n);
	sort(o+1, o+n+1, [] (ll x, ll y) { return A[x] < A[y]; });
	FOR(i,1,n+1)
	{
		ll x = o[i];
		if(segL->rmq(1, x-1).s != LLINF)edges.pb(spi(l[segL->rmq(1, x-1).s] + r[x], pi(segL->rmq(1, x-1).s, x)));
		if(segR->rmq(x+1, n).s != LLINF)edges.pb(spi(l[x]+r[segR->rmq(x+1, n).s], pi(segR->rmq(x+1, n).s, x)));
		segL->update(x, l[x]);
		segR->update(x, r[x]);
	}
	sort(all(edges));
	for(auto i : edges)
	{
		ll x = i.s.f, y = i.s.s, c = i.f;
		if(min(x,y)<=0||max(x,y)>n||ufds.same(x,y)) continue;
		ans += c;
		ufds.merge(x,y);
	}
	cout << ans << "\n";
}


Measured memory_bytes: 76908
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((int)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-9
typedef pair<int, int> II;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI 2 * acos(0)

#define maxn 55

bool can[55][55][55];
int n, a[maxn], b[maxn];

int main(){
	srand(1412);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);

    Rep(i, 51) Rep(j, 51) can[i][i][j] = 1;

    for(int t = 1; t <= 50; t++) for(int i = 0; i <= 50; i++) for(int j = 0; j <= 50; j++){
    	if(can[i][j][t - 1] || can[i % t][j][t - 1]) can[i][j][t] = 1;
    }

    cin >> n;
    For(i, 1, n) cin >> a[i]; For(i, 1, n) cin >> b[i];
    For(i, 1, n) if(!can[a[i]][b[i]][50]){
    	cout << -1 << endl;
    	return 0;
    }

    vector<int> V[maxn];
    For(i, 1, n) V[i].pb(a[i]);
    ll res = 0;
    for(int t = 50; t >= 0; t--){
    	bool cann = true;
    	For(i, 1, n){
    		bool ok = false;
    		Rep(j, sz(V[i])){
    			int u = V[i][j];
    			if(can[u][b[i]][t]){
    				ok = true;
    				break;
    			}
    		}
    		if(!ok){
    			cann = false;
    			break;
    		}
    	}
    	if(!cann){
    		For(i, 1, n){
    			bool color[maxn];
    			ms(color, 0);
    			Rep(j, sz(V[i])){
    				int u = V[i][j];
    				color[u] = 1;
    				if(u % (t + 1) >= b[i]){
    					color[u % (t + 1)] = 1;
    				}
    			}
    			V[i].clear();
    			For(j, 0, 51) if(color[j]) V[i].pb(j);
    		}
    		res = onbit(res, t + 1);
    	}
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<queue>
#include<map>

using namespace std;


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

    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int k=0;k<n;k++){
        if(k > 0) cout << " ";
        cout << a[k];
    }
    cout << endl;

    for(int i=1;i<n;i++){
        int tmp = a[i];
        int j = i-1;
        while(j>=0 && a[j] > tmp){
            a[j+1] = a[j];
            j--;
        }

        a[j+1] = tmp;
        
        for(int k=0;k<n;k++){
            if(k > 0) cout << " ";
            cout << a[k];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include <set>

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

const LL inf = 1000000000000000;
const LL mod = 1000000007;

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

	LL sz = s.size();

	LL cnt = 0;
	for (int i = 0; i < sz/2; ++i) {
		if (s[i] != s[sz-1-i]) {
			cnt++;
		}
	}

	cout << cnt << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a;
	int n;
	
	while (scanf("%d", &a) != EOF){
		n = a % 39;
		if (n == 0){
			printf("3C39\n");
		}
		else if (n >= 1 && n <= 9){
			printf("3C0%d\n", n);
		}
		else {
			printf("3C%d\n", n);
		}
	}
	
	return (0);
}

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

using info = array<int, 3>;

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

    int d;
    long long g;
    cin >> d >> g;
    vector<info> v;
    for (int i = 1; i <= d; ++i) {
        info a;
        a[0] = i * 100;  // score
        cin >> a[1] >> a[2]; // count, bonus
        v.push_back(a);
    }
    auto res = static_cast<int>(g / 100);
   do {
        long long g_copy = g;
        int total_count = 0;
        for (info a: v) {
            int count = ceil(g_copy * 1.0/ a[0]);
            count = min(count, a[1]);
            g_copy -= a[0] * count;
            if (count == a[1]) g_copy -= a[2];
            total_count += count;
            a[1] -= count;
            if (g_copy <= 0) break;
        }
           res = min(res, total_count);
    } while (next_permutation(v.begin(), v.end()));

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int C[N-1],S[N-1],F[N-1];
  for (int i = 0; i < N-1; i++) {
    cin >> C[i] >> S[i] >> F[i];
  }
  for (int i = 0; i < N-1; i++) {
    int now = 0;
    for (int j = i; j < N-1; j++) {
      if (now < S[j]) {
        now = S[j] + C[j];
      } else {
        now += ((F[j] - (now % F[j])) % F[j]) + (C[j]);
      }
    }
    cout << now << endl;
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void) {
	int H, W;
	while(1){
	    scanf("%d %d", &H, &W);
	    if(H==0 && W==0){
	    	break;
	    }
	    for(int i=0; i<H; i++){
	    	for(int j=0; j<W; j++){
	    		printf("#");
	    	}
	    	printf("\n");
	    }
	    printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2108
S = gets.chomp
T = gets.chomp
s_table = {}
t_table = {}
is_ok = (0..(S.size - 1)).all? do |i|
  s = S[i]
  t = T[i]
  s_table[t] = s if s_table[t].nil?
  t_table[s] = t if t_table[s].nil?
  sx = s_table[t]
  tx = t_table[s]
  sx == s && tx == t
end
puts(is_ok ? 'Yes' : 'No')


Measured memory_bytes: 3836
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

char dp[2][100001];
int vec[100];
int n, k;

int go(int tu, int kk) {
	if (dp[tu][kk] != -1) return dp[tu][kk];

	int ret = tu;
	if (tu == 0) {
		for (int i = 0; i < n; i++) {
			if (vec[i] > kk) break;
			ret |= go(tu ^ 1, kk - vec[i]);
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if (vec[i] > kk) break;
			ret &= go(tu ^ 1, kk - vec[i]);
		}
	}

	// printf("%d")
	return dp[tu][kk] = ret;
}

int main() {
	memset(dp, -1, sizeof(dp));
	scanf("%d %d", &n, &k);

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

	int t = go(0, k);
	printf("%s", t ? "First" : "Second");
}

Measured memory_bytes: 6656
N = int(input())

cnt = 0
def dfs(n):
    global cnt
    if n>N:
        return 0
    s = str(n)
    if '3' in s and '5' in s and '7' in s:
        cnt += 1
    dfs(int(s+'3'))
    dfs(int(s+'5'))
    dfs(int(s+'7'))

dfs(3)
dfs(5)
dfs(7)
print(cnt)


Measured memory_bytes: 3064