akhauriyash/Code-Regression huggingface dataset:
/*
	*	Created By: 'Present_Sir'
	*	Created On: Sunday 12 July 2020 10:34:25 AM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;


void solve(){
    int n;
    cin>>n;
    vector<int> v(n+1);
    for(int i=1; i*i<n; i++){
        for(int j=1; j*j<n; j++){
            for(int k=1; k*k<n; k++){
                int ans = i*i + j*j + k*k + i*j + j*k + i*k;
                if(ans>n) continue;
                v[ans]++;
            }
        }
    }
    for(int i=1; i<=n; i++){
        cout<<v[i]<<endl;
    }
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3600
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int n; cin>>n;
    ll k; cin>>k;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    vector<vector<ll>> dp(70, vector<ll>(2, -1));
    dp[51][0] = 0;
    for(int d=50; d>=0; d--){
        ll base = (1LL << d);
        int cnt1 = 0;
        for(int i=0; i<n; i++){
            if(base & a[i]) cnt1++;
        }

        if(dp[d+1][1] >= 0){
            // 未満フラグが既に立っている
            chmax(dp[d][1], dp[d+1][1] + base * max(cnt1, n - cnt1));
        }

        if(dp[d+1][0] >= 0){
            if(k & base){
                // 0 にして、未満フラグを立てる
                chmax(dp[d][1], dp[d+1][0] + base * cnt1);

                // 1 にして、未満フラグを立てない
                chmax(dp[d][0], dp[d+1][0] + base * (n - cnt1));
            }
            else{
                // 0 にせざるを得ず、未満フラグを立てられない
                chmax(dp[d][0], dp[d+1][0] + base * cnt1);
            }
        }
    }

    cout << max(dp[0][0], dp[0][1]) << endl;
    
    return 0;
}

Measured memory_bytes: 1024
use std::io;
use std::str::FromStr;


fn main() {
    let s = getline();

    if s == "Sunny" {
        println!("Cloudy");
    }
    else if s == "Cloudy" {
        println!("Rainy");
    }
    else {
        println!("Sunny");
    }
}

#[allow(dead_code)]
fn getline() -> String {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().to_string()
}

#[allow(dead_code)]
fn read<T>() -> T where T : FromStr {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn reads<T>() -> Vec<T> where T : FromStr {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn printv<T>(xs: &[T]) where T : std::fmt::Display {
    xs.iter().fold("", |s, x| {
        print!("{}{}", s, x);
        " "
    });
    println!();
}

Measured memory_bytes: 4352
def main():
    from builtins import int, map, list, print, min
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N = input_number()
    K = input_number()
    X = input_number_list()
    ans = 0
    for x in X:
        ans += min(x * 2, abs(K - x) * 2)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from itertools import*
from collections import*
h,w,d=map(int,input().split())
g=defaultdict(tuple)
f=defaultdict(int)
for i in range(h):
    for j,v in enumerate(map(int,input().split())):
        g[v]=(i,j)
        
q=int(input())

for i in range(1,d+1):
    for k,v in enumerate(accumulate([0]+[sum(abs(s-t)for s,t in zip(g[j+d],g[j]))for j in range(i,h*w+1-d,d)])):
        f[i+k*d]=v
        
for i in range(q):
    l,r=map(int,input().split())
    print(f[r]-f[l])
    

Measured memory_bytes: 38408
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
struct UnionFind {
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N+1, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
};


int main(){
  int N;
  cin>>N;
  UnionFind UF(N);
  int M;
  cin>>M;
  for(int i = 0;i<M;i++){
    int a,b;
    a;
    b;
    cin>>a>>b;
    UF.unite(a,b);
  }
  int ans = 0;
  for(int i = 1;i<=N;i++){
    if(i == UF.root(i)){
      ans++;
    }
  }
  cout << ans-1 << endl;
  return 0;
}

Measured memory_bytes: 3696
n= int(input())
x = list(map(int,input().split()))

sort_x=sorted(x)

left_num=sort_x[n//2-1]
right_num=sort_x[n//2]
for i in range(n):
  if x[i]<=left_num:
    print(right_num)
  else:
    print(left_num)

Measured memory_bytes: 25556
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int64_t i=(k);i<(int64_t)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using Graph = vector<vector<int>>;

void add_edge(Graph &g, int a, int b) {
  g[a].push_back(b);
  g[b].push_back(a);
}

bool dfs(const Graph &g, vector<int> &vis, int i) {
  for (int j : g[i]) {
    if (vis[j] == -1) {
      vis[j] = vis[i] ^ 1;
      if (!dfs(g, vis, j)) return false;
    } else if (vis[j] == vis[i]) {
      return false;
    }
  }
  return true;
}

int main() {
  int64_t v,e;
  cin>>v>>e;
  Graph g(v);
  REP(i,e) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    add_edge(g, a, b);
  }
  vector<int> vis(v, -1);
  bool ok = true;
  int cnt = 0;
  REP(i,v) {
    if (vis[i] == -1) {
      vis[i] = 2 * cnt;
      if (!dfs(g, vis, i)) {
        ok = false;
      }
      ++cnt;
    }
  }
  if (!ok) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> ary(cnt, 0);
  REP(i,v) {
    if ((vis[i] % 2) == 0) {
      ++ary[vis[i]/2];
    } else {
      --ary[vis[i]/2];
    }
  }
  REP(i,cnt) ary[i] = abs(ary[i]);
  int64_t sum = 0;
  REP(i,cnt) sum += ary[i];
  bitset<100001> dp;
  dp[0] = true;
  REP(i,cnt) {
    bitset<100001> tmp = dp;
    tmp |= dp << ary[i];
    swap(tmp, dp);
  }
  int64_t mx = 0;
  REP(i,sum+1) {
    if (dp[i]) {
      int64_t k = 2*i - sum;
      mx = max(mx, (v - k)/2 * (v + k)/2 - e);
    }
  }
  cout << mx << endl;
  return 0;
}



Measured memory_bytes: 9432
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	a := make([]int, n)

	for i := range a {
		a[i] = readInt()
	}

	sort.Ints(a)

	var i int
	for {
		if i+1 == n {
			println(a[i])
			return
		}
		a[i], a[i+1] = a[i+1]%a[i], a[i]
		if a[i] == 0 {
			i++
		}
	}
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    int n;cin >> n;
    int sum=0;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(),a.end());

    int j=0;
    while(sum%10==0 && j<n){
        if(a[j]%10!=0) sum -= a[j];
        j++;
    }

    if(sum%10==0) cout << 0 << endl;   
    else cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3552
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    vvll edges(n);
    REP(i, m) {
        ll a, b; cin >> a >> b;
        edges[a - 1].push_back(b - 1);
        edges[b - 1].push_back(a - 1);
    }
    ll q; cin >> q;
    vll v(q), d(q), c(q);
    REP(i, q) {
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }

    vll col(n, 0), ddd(n, -1);
    for (ll i=q-1; i>=0; i--) {
        // v[i] から距離 d[i] まで塗られているなら上書きはない
        if (ddd[v[i]] >= d[i]) continue;

        ll tmpd = d[i];
        queue<ll> node;
        node.push(v[i]);
        while (tmpd >= 0 && !node.empty()) {
            queue<ll> nnode;
            while (!node.empty()) {
                q = node.front(); node.pop();
                if (ddd[q] >= tmpd) continue;
                ddd[q] = tmpd;
                if (col[q] == 0) col[q] = c[i];
                for (ll e: edges[q]) nnode.push(e);
            }
            node = nnode;
            tmpd--;
        }
    }

    REP(i, n) {
        cout << col[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 12080
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Math;

class Program
{
    static void Main()
    {
        var K = int.Parse(ReadLine());

        var ans = string.Join("", Repeat("ACL", K));

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28260
#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(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end(),greater<int>());
  int cnt=1;
  int h=0;
  long long ans=0;
  for(int i=1;i<n;i++){
     if(a[i]==a[i-1])cnt++;
     else cnt=1;
     if(cnt==4){
        ans=(long long)a[i]*a[i];
        cout<<ans<<endl;
        return 0;
     }
     else if(cnt==2 && h==0)h=a[i];
     else if(cnt==2 && h!=0){
        ans=(long long)h*a[i];
        cout<<ans<<endl;
        return 0;
     }
     else continue;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 200200;
int n;
ll a[N][2];
ll b[N];
ll pref[N];
ll ans = (ll)1e16;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	ll sumA = 0, sumB = 0;
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", &a[i][0], &a[i][1]);
		sumA += a[i][0];
		sumB += a[i][1];
		b[2 * i] = a[i][0];
		b[2 * i + 1] = a[i][1];
	}
	ans = min(sumA, sumB);
	sort(b, b + 2 * n);
	for (int i = 0; i < 2 * n; i++)
		pref[i + 1] = pref[i] + b[i];
	for (int i = 0; i < n; i++) {
		ll cur = 0;
		int pos = n - 2;
		for (int j = 0; j < 2; j++) {
			if (a[i][j] <= b[pos])
				pos++;
			else
				cur += a[i][j];
		}
		ans = min(ans, cur + pref[pos]);
	}
	printf("%lld\n", ans);

	return 0;
}


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

const int MAXN = 410;
typedef long long LL;
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a *= a) if (b & 1) res *= a;
	return res;
}
int C[MAXN][4], n;
LL hash(int * a) { return a[0] | a[1] << 16 | (LL) a[2] << 32 | (LL) a[3] << 48; }
void dehash(int * a, LL t) {
	static const int mask = (1 << 16) - 1;
	a[0] = t & mask, t >>= 16;
	a[1] = t & mask, t >>= 16;
	a[2] = t & mask, t >>= 16;
	a[3] = t & mask;
}
void mk(int * t, int a, int b, int c, int d) {
	t[0] = a, t[1] = b, t[2] = c, t[3] = d;
}
void rotate(int * a) {
	static int t;
	t = a[3], a[3] = a[2], a[2] = a[1], a[1] = a[0], a[0] = t;
}
int rtteq(int * a) {
	LL hs = hash(a); int res = 0;
	for (int i = 0; i != 4; ++i) res += hash(a) == hs, rotate(a);
	return res;
}
void mins(int * a) {
	LL h[4];
	for (int i = 0; i != 4; ++i) h[i] = hash(a), rotate(a);
	int at = std::min_element(h, h + 4) - h;
	for (int i = 0; i != at; ++i) rotate(a);
}
LL down(int a, int b) {
	LL res = 1;
	for (int i = a; i > a - b; --i) res *= i;
	return res;
}
std::map<LL, int> hav, pt;
void ins(int * a, int v) { hav[hash(a)] += v; }
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < 4; ++j)
			std::cin >> C[i][j];
		mins(C[i]); ins(C[i], 1);
	}
	LL ans = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j) {
			ins(C[i], -1), ins(C[j], -1);
			for (int T = 0; T != 4; ++T) {
				int t[4];
				mk(t, C[i][3], C[i][2], C[j][3], C[j][2]);
				mins(t); ++pt[hash(t)];
				mk(t, C[i][2], C[i][1], C[j][0], C[j][3]);
				mins(t); ++pt[hash(t)];
				mk(t, C[i][1], C[i][0], C[j][1], C[j][0]);
				mins(t); ++pt[hash(t)];
				mk(t, C[i][0], C[i][3], C[j][2], C[j][1]);
				mins(t); ++pt[hash(t)];
				LL r = 1;
				for (auto x : pt) {
					r *= down(hav[x.first], x.second);
					dehash(t, x.first);
					r *= pow(rtteq(t), x.second);
				}
				ans += r;
				pt.clear();
				rotate(C[j]);
			}
			ins(C[i], 1), ins(C[j], 1);
		}
	std::cout << ans / 3 << std::endl;
	return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::unordered_set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ull N; cin >> N;
  --N;
  ull ans = N % 2 == 0 ? (N / 2) * (N + 1) : ((N + 1) / 2) * N;
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
using System;
class P
{
    static void Main()
    {
        string s;
        int l = (s = Console.ReadLine()).Length;
        int j = (l - (s[0] == s[l - 1] ? 1 : 0)) % 2;
        Console.WriteLine(j == 0 ? "Second" : "First");
    }
}

Measured memory_bytes: 13116
#include<iostream>
#include<queue>
using namespace std;
int x[10][10], y[10][10], z[10][10], p[6] = { 1,6,36,216,1296,7776 };
int a[6], H, W, C, cnt, res; queue<pair<int, int>>Q;
void h(int A, int B, int C) { if (z[A][B] == 0 && y[A][B] == C) { z[A][B] = 1; Q.push(make_pair(A, B)); } }
int main() {
	while (true) {
		for (int j = 0; j < 100; j++) { x[j / 10][j % 10] = -1; }
		cin >> H >> W >> C; C--; if (H == 0 && W == 0 && C == -1) { break; }res = 0;
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cin >> x[i][j]; x[i][j]--;
			}
		}
		for (int i = 0; i < p[5]; i++) {
			for (int j = 0; j < 4; j++) { a[j] = (i / p[j]) % 6; }a[4] = C;
			for (int j = 0; j < 100; j++) { y[j / 10][j % 10] = x[j / 10][j % 10]; }
			for (int j = 0; j < 5; j++) {
				Q.push(make_pair(1, 1));
				for (int k = 0; k < 100; k++) { z[k / 10][k % 10] = 0; }z[1][1] = 1;
				while (!Q.empty()) {
					pair<int, int>a0 = Q.front(); Q.pop(); int a1 = a0.first, a2 = a0.second, a3 = y[a1][a2];
					h(a1 + 1, a2, a3); h(a1 - 1, a2, a3); h(a1, a2 - 1, a3); h(a1, a2 + 1, a3);
				}
				for (int k = 0; k < 100; k++) { if (z[k / 10][k % 10] == 1) { y[k / 10][k % 10] = a[j];} }
			}
			cnt = 0;
			Q.push(make_pair(1, 1));
			for (int k = 0; k < 100; k++) { z[k / 10][k % 10] = 0; }z[1][1] = 1;
			while (!Q.empty()) {
				pair<int, int>a0 = Q.front(); Q.pop(); int a1 = a0.first, a2 = a0.second, a3 = y[a1][a2];
				h(a1 + 1, a2, a3); h(a1 - 1, a2, a3); h(a1, a2 - 1, a3); h(a1, a2 + 1, a3);
			}
			cnt = 0;
			for (int k = 0; k < 100; k++) { if (z[k / 10][k % 10] == 1) { cnt++; } }
			res = max(res, cnt);
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N,A,B;cin>>N>>A>>B;
  if((B-A)%2==0)cout<<(B-A)/2<<endl;
  else cout<<min((2*N-A-B+1)/2,(A+B-1)/2)<<endl;
}

Measured memory_bytes: 256
/*
	*	Created By: 'Present_Sir'
	*	Created On: Friday 21 August 2020 11:09:23 AM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;


void solve(){
    int n;
    cin>>n;

    string s;
    cin>>s;

    if((int)s.length() > n){
        string st = s.substr(0,n);
        st += "...";
        cout<<st<<endl;
    }else{
        cout<<s<<endl;
    }
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3624
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, D = map(int, input().split())
X = []

for _ in range(N):
	X.append(list(map(int, input().split())))
	
count = 0

for i in range(N - 1):
	for j in range(i + 1, N):
		dist = 0
		for k in range(D):
			dist += (X[i][k] - X[j][k]) ** 2
			
		dist **= 0.5
		if dist - int(dist) == 0:
			count += 1

print(count)


Measured memory_bytes: 38384
#include <stdio.h>

int main(void)
{
	int a[200000],s[200000],i,N,j,count[200000],count1=0;
	long long total;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		a[i]=0;
	}
	for(i=0;i<N;i++){
		scanf("%d",&s[i]);
		if(a[s[i]]==1){
			count[count1]=s[i];
			count1++;
		}
		a[s[i]]++;
	}
	for(i=0;i<count1;i++){
		total+=(long long)a[count[i]]*(a[count[i]]-1)/2;
	}
	for(i=0;i<N;i++){
		if(a[s[i]]>=2)printf("%lld\n",(long long)total-a[s[i]]*(a[s[i]]-1)/2+(a[s[i]]-2)*(a[s[i]]-1)/2);
		else printf("%lld\n",total);
	}
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	string s;
	cin>>s;
	ll ans=0,num=0;
	for(int i=0;i<(1<<s.size()-1);i++){
		for(int j=0;j<s.size();j++){
			num=num*10+s[j]-'0';
			if(i & 1<<j){
				ans+=num;
				num=0;
			}
		}
		ans+=num;
		num=0;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    int k,n; cin >> k >> n;
    vi a(n);
    forn(i,n) cin >> a[i];
    int ans = 0;
    forn(i, n-1) {
        int x = a[i+1] - a[i];
        ans = max(ans, x);
    }
    int x = k - a[n-1] + a[0];
    ans = max(ans, x);
    cout << k-ans << endl; 

    return 0;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
ans = []
for x in a:
    for i in range(len(x) - 1):
        ans.append(x[i+1])
cnt = 0
for i in range(m):
    if ans.count(i+1) == n:
        cnt += 1
print(cnt)

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

int main(){
    bool nonp[100005] = {};
    nonp[0] = nonp[1] = true;
    for(int i = 2; i < 100005; i++){
        if(nonp[i]) continue;
        for(int j = i+i; j < 100005; j += i)    nonp[j] = true;
    }
    int imos[100005] = {};
    for(int i = 1; i < 100005; i+=2){
        imos[i] = (!nonp[i] && !nonp[(i+1)/2]);
    }
    for(int i = 1; i < 100005; i++) imos[i] += imos[i-1];

    int q, l, r;
    cin >> q;
    while(q-- > 0){
        cin >> l >> r;
        cout << imos[r] - imos[l-1] << endl;
    }
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

void fail() {
    cout << "No\n";
    exit(0);
}

void win() {
    cout << "Yes\n";
    exit(0);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    forn(i, 0, n) cin >> a[i];
    sort(all(a));
    if (a.back() - a[0] > 1) fail();
    if (a.back() == a[0]) {
        if (a[0] == n - 1) win();
        else {
            int mn = 1, mx = n / 2;
            if (mn <= a[0] && a[0] <= mx) win();
            else fail();
        }
    }
    int cnt0 = 0, cnt1 = 0;
    forn(i, 0, n) {
        if (a[i] == a[0]) ++cnt0;
        else ++cnt1;
    }
    int mn = cnt0 + 1;
    int mx = cnt0 + cnt1 / 2;
    if (mn <= a.back() && a.back() <= mx) win();
    else fail();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[])
{
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int cur1 = 0, cur2 = 0;
    rep(i, n)
    {
        if (s[i] == 'c')
        {
            cout << "No" << endl;
        }
        else
        {
            if (s[i] == 'a' && cur1 < a + b)
            {
                cout << "Yes" << endl;
                cur1++;
            }
            else if (s[i] == 'b' && cur1 < a + b && cur2 < b)
            {
                cout << "Yes" << endl;
                cur1++;
                cur2++;
            }
            else
            {
                cout << "No" << endl;
            }
        }
    }

    return 0;
}


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

int main()
{
  int64_t a, b, c;
  cin >> a >> b >> c;
  int64_t x = c - a - b;
  cout << (a + b < c and 4 * a * b < x * x ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#define N 8
#define FREE -1
#define NOT_FREE 1


int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

int X[N][N];

void initialize(){
  int i;
  
  for(i=0;i<N;i++){
    row[i]=FREE;
    col[i]=FREE;
  }
    for(i=0;i<N*2-1;i++){
      dpos[i]=FREE;
      dneg[i]=FREE;
    }
}

void printBoard(){
  int i,j;
  
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
	if(row[i]!=j) return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j){
      printf("Q");
      }
      else printf(".");
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  
  if(i==N){
    printBoard();
    return;
  }

  for(j=0;j<N;j++){
    if(NOT_FREE==col[j] || NOT_FREE==dpos[i+j] || NOT_FREE==dneg[i-j+N-1]) continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main(){
  int i,j,k,r,c;
  
  initialize();

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      X[i][j]=0;
    }
  }

  scanf("%d",&k);

  for(i=0;i<k;i++){

    scanf("%d%d",&r,&c);
    X[r][c]=1;
  }

  recursive(0);

  return 0;

}

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


int main(){

  int n, m; cin >> n >> m;
  vector<char> kazu(n, 'a');

  rep(i,m){
    char s, c;
    cin >> s >> c;
    int a = s - '0';
    a--;
    if(s == '1' && c == '0'){
      if(n != 1){
        cout << -1 << '\n';
        return 0;
      }
      else kazu[0] = c;
      
    }

    if(kazu[a]  == 'a') kazu[a] = c;
    else{
      if(kazu[a] != c){
        cout << -1 << '\n';
        return 0;
      }
    }
  }
  string ans;
  rep(i,n){
    if(kazu[i] == 'a') kazu[i] = '0';
    ans += kazu[i];
  }
  if(ans.size() == 1){
    cout << ans << '\n';
    return 0;
  }
  if(ans[0] == '0') ans[0] = '1';
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
INF=1000000
n,wmax=gets.split.map(&:to_i)
bags=[]
dp=Array.new(110){[0]*100010}

n.times.each do
    bags<<gets.split.map(&:to_i)
end

for i in 0..n-1
    wi,vi=bags[i]
    for w in 0..wmax
        if w-wi>=0
        dp[i+1][w]=[dp[i][w-wi]+vi,dp[i+1][w],dp[i][w]].max
        else
        dp[i+1][w]=[dp[i][w],dp[i+1][w]].max
        end
    end
end
#p dp[0..10]
p dp[n].max

Measured memory_bytes: 100592
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int n; cin >> n;
	set<int> temp;
	map<int,int> mp;
	FOR(n){
		int x; cin >> x;
		temp.insert(x);
		++mp[x];
	}
	vector<int> a;
	for(int xx : temp) a.pb(xx);
	set<pair<int,pair<int,int>>> s;
	FOR(i,a.size()){
		FOR(j,i+1,a.size()){
			FOR(k,j+1,a.size()){
				int e1 = a[i], e2 = a[j], e3 = a[k];
				if(e1 + e2 > e3){
					s.insert({e1,{e2,e3}});
				}
			}
		}
	}
	int ans = 0;
	for(auto x : s){
		//cout << x.first <<  " " << x.second.first << " " << x.second.second << '\n';
		int ta = mp[x.first] * mp[x.second.first] * mp[x.second.second];
		ans += ta;
	}
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 13556
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
   ll n,k;
   while (cin>>n>>k)
   {
       int a[n+5];
       for (int i=0;i<n;i++)
       {
           cin>>a[i];
       }
       if (n==k)
       {
           cout<<1<<endl;
       }
       else if (k==2)
       {
           cout<<n-1<<endl;
       }
       else
       {
           int a=n-k;
           int b=a/(k-1);
           int p=(b+1);
           if (a%(k-1)==0)
           {
               cout<<p<<endl;
           }
           else
           {
               cout<<p+1<<endl;
           }
       }
   }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//constexpr long long MOD = 1e9 + 7;
//constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

bool compare_first(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.first != y.first) {
        return x.first < y.first;
    }
    else {
        return x.second < y.second;
    }
}

bool compare_second(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.second != y.second) {
        return x.second < y.second;
    }
    else {
        return x.first < y.first;
    }
}

struct {
    bool operator()(pair<string, int> x, pair<string, int> y) const
    {
        return x.second <= y.second && x.first < y.first;
    }
} compare_map;

const ll MAX = 500000000;
const ll MOD = 1000000007;

template<typename T>
T gcd(T a, T b) {
    T c = 1;
    while (c != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

class Node {
public:
    Node(int v, ll sum, bool root) 
    :value(v), correctValue(sum), isRoot(root)
    {

    }
    vector<Node> children;
    int value;
    ll correctValue;
    bool isRoot;
};

void generateChildren(int depth, Node& current) {
    if (depth > 10) {
        return;
    }
    int c = current.value;
    for (int i = c - 1; i <= c + 1; i++) {
        if (i < 0 || 9 < i) {
            continue;
        }
        current.children.push_back(Node(i, current.correctValue * 10 + i, false));
    }
    for (auto& n : current.children) {
        generateChildren(depth + 1, n);
    }
}

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

    //int h, w, k, a, b, c;

    int k;
    cin >> k;
    Node root(0, 0, true);
    for (int i = 1; i <= 9; i++)
    {
        root.children.push_back(Node(i, i, false));
    }

    for (auto& n : root.children) {
        generateChildren(2, n);
    }

    queue<Node> q;
    q.push(root);
    int index = -1;
    while (!q.empty()) {
        Node c = q.front(); q.pop();
        for (auto n : c.children) {
            q.push(n);
        }
        index++;
        if (index == k) {
            cout << c.correctValue << "\n";
            return 0;
        }
    }

    return 0;
}



Measured memory_bytes: 34944
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 100000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}



class RollingHash{
private:
    ll mod;
    set<ll> hash[1000100];

public:
    RollingHash(){
        random_device rnd;
        mt19937 mt(rnd());
        uniform_int_distribution<> rand_mod(100000, 1000000);

        mod = rand_mod(mt);
    }

    void add(ll hash_num){
        hash[hash_num % mod].insert(hash_num);
    }

    bool search(ll hash_num){
        return hash[hash_num % mod].find(hash_num) != hash[hash_num % mod].end();
    }
};


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

    int l = 0, r = N;
    while(r - l > 1){
        int m = (l + r) / 2;
        bool ok = false;
        RollingHash rh;
        queue<ll> que;

        ll tmpHash = 0;
        ll base = 1;
        for(int i = 0; i < m-1; i++){
            base = mul(base, 26);
        }
        for(int i = 0; i < m; i++){
            tmpHash = add(mul(26, tmpHash), s[i] - 'a');
        }
        que.push(tmpHash);

        for(int i = m; i < N; i++){
            if(que.size() == m){
                ll newHash = que.front();
                rh.add(newHash);
                que.pop();
            }
            tmpHash = sub(tmpHash, mul(base, (s[i-m] - 'a')));
            tmpHash = mul(tmpHash, 26);
            tmpHash = add(tmpHash, s[i] - 'a');
            que.push(tmpHash);

            if(rh.search(tmpHash)){
                ok = true;
                break;
            }
        }

        if(ok){
            l = m;
        }
        else{
            r = m;
        }
    }
    cout << l << endl;


    return 0;
}


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

typedef unsigned long long Hash;

// h[x] = str[0..x)
vector<Hash> diffs;

Hash h[100010];
Hash p[100010];
Hash w = 8999;

// [l,r)
Hash substr(int l,int r){
	return h[r] - h[l] * p[r-l];
}
Hash concat(Hash a,Hash b,int blen){
	return a * p[blen] + b;
}

Hash makestr(int l,int r,int t){
	int len = r - l;
	int Q = len / t;
	int R = len % t;
	Hash res = 0;

	if( l + t <= r ){

		Hash x = substr(l,l+t);
		int xlen = t;
	
		for(int i = 0 ; xlen <= len ; i++){
			if( Q >> i & 1 ){
				res = concat(res,x,xlen);
			}

			x = concat(x,x,xlen);
			xlen *= 2;
		}
	}

	res = concat(res,substr(l,l+R),R);
	//cout << res << endl;
	return res;	
}


Hash makestr2(int l,int r,int t){
	int len = r - l;
	int Q = len / t;
	int R = len % t;
	int xlen = t;
	Hash x = substr(l+t,l+2*t);
	Hash res = 0;
	for(int i = 0 ; xlen <= len ; i++){
		if( Q >> i & 1 ){
			res = concat(res,x,xlen);
		}

		x = concat(x,x,xlen);
		xlen *= 2;
	}

	res = concat(res,substr(l+t,l+t+R),R);
	//cout << res << endl;
	return res;	
}


int main(){
	p[0] = 1;
	for(int i = 1 ; i <= 100000 ; i++)
		p[i] = p[i-1] * w;
	string S;
	cin >> S;
	h[0] = 0;
	for(int i = 0 ; i < S.size() ; i++){
		h[i+1] = h[i] * w + S[i];
	}

	
	diffs.push_back(0);
	for(char c =0 ; c < 26 ; c++){
		for(int i = 0 ; i < 100000 ; i++){
			diffs.push_back(c*p[i]);
			diffs.push_back(-c*p[i]);
		}
	}
	sort(diffs.begin(),diffs.end());
	
	
	int Q;
	cin >> Q;

	for(int i = 0 ; i < Q ; i++){
		int l,r,t;
		cin >> l >> r >> t;
		--l;
		//cout << substr(l,r) - makestr(l,r,t)<< endl;
		
		if( binary_search(diffs.begin(),diffs.end(), makestr(l,r,t) - substr(l,r) ) ){
			cout << "Yes" << endl;
			
		}else if( l+2*t <= S.size() and binary_search(diffs.begin(),diffs.end(), makestr2(l,r,t) - substr(l,r) ) ){
				cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	
	
}

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define mod 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()

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

  double x;
  string u;

  double count = 0;
  for (int i = 0; i < N; i++)
  {
    cin >> x >> u;
    if (u == "JPY") {
      count += x;
    } else {
      count += x * 380000.0 ;
    }
  }

PS(count);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
   int N;
   cin>>N;
   vector<int> A(N);
   for(int i=0;i<N;i++){
       cin>>A.at(i);
       A.at(i)=A.at(i)-i-1;
   }
   sort(A.begin(),A.end());
   int b=(N%2==0)? A.at(N/2-1):A.at((N+1)/2-1);
   ll sum=0;
   for(int i=0;i<N;i++){
       sum+=abs(A.at(i)-b);
   }
   cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
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;}

bool isok(char c) {
    if(c=='A' || c=='G' || c=='C' || c=='T') return true;
    return false;
}

int main() {
    string str; cin >> str;
    int tmp=0, ans = 0;
    for(int i=0; i<str.size(); i++){
        if(isok(str[i])){
            tmp++;
            ans = max(ans, tmp);
        }
        else{
            tmp=0;
        }
    }
    cout << ans << endl;
}



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

unordered_map<int,int> mp;
#define INF (1<<30);


int main(void) 
{
    int sum = 0, rmax = 0, t[6], r;
    for(int i=0;i<5;i++) {
        cin >> t[i];
        sum += ((t[i]+9)/10)*10;
        r = (10-t[i] % 10)%10;
        if(r > rmax) rmax = r;
    }
    cout << sum - rmax << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

constexpr double pi = 3.14159265358979323846;

int main()
{
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	h *= 30;
	h += (m / 60) * 30;
	m *= 6;

	double measure = abs(h - m);
	measure *= (pi / 180);
	cout.precision(20);
	cout << fixed << sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(measure)) << endl;
}

Measured memory_bytes: 4236
package main

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

var (
	sc    = bufio.NewScanner(os.Stdin)
	words = [4]string{"dream", "dreamer", "erase", "eraser"}
)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func solve(target string) bool {

	if len(target) == 0 {
		return true
	}

	for _, v := range words {
		if strings.HasPrefix(target, v) {
			if res := solve(target[len(v):]); res {
				return true
			}
		}
	}

	return false
}

func main() {
	var input string
	fmt.Scan(&input)

	if res := solve(input); res {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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

#include <bits/stdc++.h>

using namespace std;

void solve(istream &in, ostream &out) {
    int L, R, d;
    in >> L >> R >> d;

    int res = 0;
    for (int i = L; i <= R; ++i) {
        if (i % d == 0)
            ++res;
    }
    out << res << '\n';
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solve(in, out);
}


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

int main() {
	int n, i, j, k, l, ans;
	while (cin >> n) {
		ans = 0;
		for (i = 0; i <= 9; i++) {
			if (i > n) continue;
			for (j = 0; j <= 9; j++) {
				if (i + j > n) continue;
				for (k = 0; k <= 9; k++) {
					if (i + j + k > n) continue;
					for (l = 0; l <= 9; l++)
						if (i + j + k + l == n) {
							ans++; break;
						}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 2964
#include <cstdio>
#include <iostream>

using namespace std;

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a; 
}

int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

int main() {
	int a, b;
	while (scanf("%d%d", &a, &b) != EOF) {
		printf ("%d %d\n", gcd(a, b), lcm(a, b));
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v){os << " [" << i++ << "]" << x; if (i % 5 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 5 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll x, a, b;
  std::cin >> x >> a >> b;

  bool judge = std::abs(a-x) < std::abs(b-x);
  if (judge) {
    print("A");
  } else {
    print("B");
  }


  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> V(n), C(n);
  for (int i = 0; i < n; i++) cin >> V[i];
  for (int i = 0; i < n; i++) cin >> C[i];

  int ans = - 1e9;
  for (int i = 0; i < (1 << n); i++) {
    int x = 0, y = 0;
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        x += V[j];
        y += C[j];
      }
    }
    ans = max(ans, x - y);
  }

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

Measured memory_bytes: 256
K,T = map(int,input().split())
A = list(map(int,input().split()))
minA = min(A)
maxA = max(A)
sumA = sum(A)

if len(A) == 1:
  ans = A[0]-1
else:
  ans = max(0,maxA-1-(sumA-maxA))

print(ans)


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

class Fib {
	vector<ll> memo;
public:
	Fib(ll initial_size = 16) : memo(initial_size,-1) {};// -1 is sentinel
	ll operator() (ll n) {
		if (n > memo.size() - 1) {
			memo.resize(2*n,-1);
		}
		if (n == 0 || n == 1) {
			return 1;
		}
		if (memo[n] != -1) {
			return memo[n];
		}
		memo[n] = operator()(n-1) + operator()(n-2); 
		return memo[n];
	}
};

int main () {
	int n;
	cin >> n;
	Fib fib;
	cout << fib(n) << endl;
	return 0;
}



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

int main(){
	string c , t , result ;

	cin >> c >> t;

	result = (c[0]==t[2] && c[1]==t[1] && c[2]==t[0] ) ? "YES" : "NO" ;

	cout << result<< endl;

	return 0;
}

Measured memory_bytes: 256