akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

typedef long long ll;

const int MAX = 55;

ll N, X;

ll layers[MAX];
ll patty[MAX];

ll solve(ll n, ll k) { // レベルnバーガーのk層目までのパティの数
  if (n == 0) return 1;
  if (k == 1) return 0;
  if (k <= layers[n-1]+1) return solve(n-1, k-1);
  if (k == layers[n-1]+2) return patty[n-1]+1;
  if (k <= 2*layers[n-1]+2) return patty[n-1]+solve(n-1, k-2-layers[n-1])+1;
  return patty[n];
}

int main() {

  cin >> N >> X;

  layers[0] = 1;
  patty[0] = 1;
  for (int i = 1; i <= N; i++) {
    layers[i] = layers[i-1]*2+3;
    patty[i] = patty[i-1]*2+1;
  }

  cout << solve(N, X) << endl;
}

Measured memory_bytes: 256
// atc.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <string>
#include    <algorithm>
using namespace std;

int main()
{
	int x;
	cin >> x;
	vector<string> A(x+1,"zzzzzzzzzzz");
	vector<string> O(x,"");
	vector<string> O2(x,"");
	int count = 0, max = 0;;
	int num=0;


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

	sort(A.begin(), A.end());

	for (int i = 0; i < x; i++) {

		if (A[i] == A[i + 1]) {
			count++;
		}
		else {
			if (count > max) {
				max = count;
				O = O2;
				num = 0;
				O[num] = A[i];
				num++;

			}
			else if(count == max) {
				O[num] = A[i];
				num++;
				

			}
			count = 0;
		}
	}

	for (int i = 0; i < num; i++) {
		cout << O[i] << endl;
	}


	return 0;

}


Measured memory_bytes: 17408
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };
}
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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{max, min};
use std::collections::{BinaryHeap, HashMap};
 
type Graph = Vec<Vec<usize>>;
const M: usize = 1e9 as usize + 9;

fn main() {
    input_byline! {
        n: usize,
    }
 
    let mut v = vec![vec![]; n];
    for i in 0..n {
        input_byline! {
            a: usize,
        }
        for j in 0..a {
            input_byline! {
                x: usize1,
                y: usize,
            }
            v[i].push((x, y));
        }
    }
 
    let mut ans = 0;
    for i in 0..1 << n {
        let mut ok = true;
        for j in 0..n {
            if (i >> j) & 1 == 0 {
                continue;
            }
            for k in 0..v[j].len() {
                if (i >> v[j][k].0) & 1 != v[j][k].1 {
                    ok = false
                }
            }
        }
        if ok {
            ans = max(ans, (i as u32).count_ones());
        }
    }
    println!("{}", ans);
}

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

int main(int argc, char *argv[]){
  int N;
  long long X;
  long long D=-1000000001;
  cin>>N>>X;
  vector<long long> vec(N+1,1000000007);
  for(int i=1; i<N+1; i++){
    long long x; cin>>x;
    vec[i]=abs(X-x);
  }
  sort(vec.begin(),vec.end());
  if(vec.size()==2){
    cout<<vec[0]<<endl;
    return 0;
  }
  for(long long i=1; i<=vec[0];i++){
    for(int j=0; j<N; j++){
      if(vec[j]%i!=0) break;
      else if(j==N-1){
	D=max(D,i);
	
      }
    }
  }
  cout<<D<<endl;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int,input().split()))
for i in range(n-1):
  if a[i] > a[i+1]:
    if a[i] == a[i+1] + 1:
      a[i+1] += 1
    else:
      print('No')
      exit()
print('Yes')

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

typedef long long int ll;

int main () {
    ll n;
    cin >> n;
    
    string s;
    cin >> s;
    
    ll ans = 0;
    
    for (int i=0 ; i<n-2 ; i++) {
        if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
    }
    
    cout << ans << endl;
}

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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

    if(isupper(x)){
        cout<<'A'<<endl;
    }else{
        cout<<'a'<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdlib>

using namespace std;

int main(void){
  int a, b, c, d;
  
  cin >> a >> b >> c >> d;
  
  if( abs(a-b) > d || abs(b-c) > d ){
    if( abs(a-c) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys
from random import randint
from datetime import datetime

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]

def randomize(n):
    return [ randint(1, 26) for _ in range(n) ]

def get_now():
    dt = datetime.now()
    return dt.second + dt.microsecond/1000000

def main():
    start = get_now()
    end = get_now()
    # 開催日数
    D = ii()
    # 満足度の下がりやすさ
    C = lmi()
    # 得られる満足度
    S = lmif(D)
    # 開催するコンテスト
    T = randomize(D)

    def scoring():
        # 最後に開かれた日付
        last = [0]*26
        score = 0
        for i in range(D):
            score += S[i][T[i]-1]
            last[T[i]-1] = i+1
            for j in range(26):
                score -= C[j] * (i+1 - last[j])
        return score

    max_score = scoring()
    # print(max_score)
    ans = T.copy()
    # a = 0
    while end - start < 1.95:
        idx, value = randint(0, D-1), randint(1, 26)
        old = T[idx]
        T[idx] = value
        score = scoring()
        if max_score < score:
            ans = T.copy()
            max_score = score
        else:
            T[idx] = old
        # if a % 10000 == 0:
        #     print(a, *T, score, max_score)
        # a += 1
        end = get_now()
    print(*ans, sep='\n')

main()


Measured memory_bytes: 9784
#include <iostream>
#include <string>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    int n,sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        sum=sum+i+1;
    }
    cout<<sum<<endl;
    return 0;
    // Your code here!
    
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
const ll MOD=1000000007;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) {return b?gcd(b, a%b):a;}
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans*(b&1?a:1);
}
inline constexpr int modpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
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;}
const ll LINF=0x1fffffffffffffff;

struct unionfind{
    vector<ll> d;
    unionfind(ll x):d(x,-1){}
    ll root(ll x) {return d[x]<0?x:d[x]=root(d[x]);}
    ll size(ll x) {return -d[root(x)];};
    bool unite(ll x,ll y) {x=root(x),y=root(y); if(x!=y){if(d[x]>d[y])swap(x,y);d[x]+=d[y];d[y]=x;}return x!=y;}
    bool find(ll x,ll y) {return root(x)==root(y);}
};
int main(){
  string s,t;
  cin>>s>>t;
  ll cnt=0;
  rep(i,0,3){
    if(s[i]==t[i]) cnt++;
  }
  cout<<cnt;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 100002;

int n, m, Q;
long long s[maxn], t[maxn], q[maxn];

bool mycmp(int i, int j) {
	return q[i] < q[j];
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m >> Q;
	for (int i = 0; i < n; ++i)
		cin >> s[i];

	for (int i = 0; i < m; ++i)
		cin >> t[i];

	vector<int> idx(Q);
	for (int i = 0; i < Q; ++i)
	{
		cin >> q[i];
		idx[i] = i;
	}

	sort(idx.begin(), idx.end(), mycmp);

	int ls = -1, lt = -1;
	long long maxDist = 2e9;
	maxDist *= 10;

	vector<long long> ans(Q);

	for (int i = 0; i < Q; ++i) {
		long long cur = q[idx[i]];

		while (ls+1 < n && s[ls+1] < cur)
			++ls;

		while (lt+1 < m && t[lt+1] < cur)
			++lt;

		// printf("cur:%lld ls:%d lt:%d\n", cur, ls, lt);

		long long res = maxDist;
		if (ls >= 0 && lt >= 0)
			res = cur - min(s[ls], t[lt]);
		// printf("res:%lld\n", res);

		if (ls < n-1 && lt < m-1)
			res = min(res, max(s[ls+1], t[lt+1]) - cur);

		// printf("res:%lld\n", res);
		if (ls >= 0 && lt < m-1)
			res = min(res, cur - s[ls] + t[lt+1] - cur + min(cur - s[ls], t[lt+1] - cur));

		if (lt >= 0 && ls < n-1)
			res = min(res, cur - t[lt] + s[ls+1] - cur + min(cur - t[lt], s[ls+1] - cur));
		
		// printf("res:%lld\n", res);
		ans[idx[i]] = res;
	}

	for (int i = 0; i < Q; ++i)
		cout << ans[i] << endl;

	return 0;
}

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

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int N,T;
    int c[105] = {}, t[1005] = {};
    int min_cost = 1e9;
    cin>>N>>T;
    rep(i,N) cin>>c[i]>>t[i];

    for(int i=0; i<N; i++){
        if(t[i]<=T){
            if(min_cost > c[i]){
                min_cost = c[i];
            }
        }
    }
    if(min_cost==1e9)
        cout<<"TLE"<<endl;
    else
        cout<<min_cost<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int w, h;
    cin >> w >> h;
    vector<P> a(w+h);
    ll ans = 0;
    rep(i,w){
        ll p;
        cin >> p;
        a[i] = P(p, 0);
        ans += p * (h + 1);
    }
    for(int i = w; i < w + h; ++i){
        ll q;
        cin >> q;
        a[i] = P(q, 1);
        ans += q * (w + 1);
    }
    sort(a.begin(), a.end());
    int cnt[2] = {};
    rep(i,w+h){
        P x = a[i];
        if(x.second == 0){
            ++cnt[0];
            ans -= x.first * cnt[1];
        }
        else{
            ++cnt[1];
            ans -= x.first * cnt[0];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6336
import math

n,d = map(int,input().split())
x = []
y = []
count = 0
for i in range(n):
  a,b = map(int,input().split())
  x.append(a)
  y.append(b)

for i in range(n):
   k = math.sqrt(x[i]**2 + y[i]**2)
   if k <= d:
       count += 1
       
print(count)

Measured memory_bytes: 24940
#include "bits/stdc++.h"
using namespace std;
int a[100000];
int main()
{
	int n;
	long long b = 0, c = 0;	
	scanf("%d", &n);
	for(int i = 0; i < n; scanf("%d", &a[i++])){}
	sort(a, a + n);
	for(int i = n - 1, j = 1000000001; i >= 0; --i)
	{
		if(a[i] == j)
		{
			if(b)
			{
				if(!c)
				{
					c = j;
				}
			}
			else
			{
				b = j;
			}
			++j;
		}
		else
		{
			j = a[i];
		}
	}
	printf("%lld\n", b * c);
}



Measured memory_bytes: 640
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

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

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint L, R;
	cin >> L >> R;

	lint x = R / L;

	int ans = 0;
	while (x) {
		x = x >> 1LL;
		ans++;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str[3];
    cin>>str[0]>>str[1]>>str[2];
    int p=0,c;
    while(1)
    {
        if(str[p].empty())
        {
            cout<<(char)(p+'A')<<endl;
            break;
        }
        c=p;
        p=str[p][0] - 'a';
        str[c].erase(str[c].begin());
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] l = new int[n];
		for(int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}
		Arrays.sort(l);
		
		int sum = 0;
		int i = l.length - 1;
		for(int j = 0; j < k; j++) {
			sum += l[i];
			i--;
		}
		System.out.println(sum);
	}

}


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

using namespace std;

class SieveOfEratosthenes {
 private:
  std::vector<int> sieve;

 public:
  SieveOfEratosthenes(int n) : sieve(n + 1) {
    std::iota(sieve.begin(), sieve.end(), 0);
    for (int i = 2; i * i < n + 1; i++) {
      if (sieve[i] != i) continue;
      for (int j = i * i; j < n + 1; j += i) {
        if (sieve[j] == j) sieve[j] = i;
      }
    }
  }

  bool is_prime(int x) const { return x != 0 && x != 1 && sieve[x] == x; }

  std::vector<int> factor(int x) const {
    std::vector<int> res;
    while (x > 1) {
      res.emplace_back(sieve[x]);
      x /= sieve[x];
    }
    return res;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto&& e : A) {
    cin >> e;
  }
  int ma = *max_element(A.begin(), A.end());
  SieveOfEratosthenes soe(ma);
  vector<int> table(ma + 1, 0);
  for (const auto& e : A) {
    auto primes = soe.factor(e);
    set<int> st;
    for (const auto& e : primes) {
      st.insert(e);
    }
    for (const auto& e : st) {
      table[e]++;
    }
  }
  bool a = true;
  for (int i = 0; i < ma + 1; i++) {
    if (table[i] > 1) a = false;
  }
  int g = 0;
  for (const auto& e : A) {
    g = gcd(g, e);
  }
  if (a) {
    cout << "pairwise coprime" << '\n';
  } else {
    if (g == 1) {
      cout << "setwise coprime" << '\n';
    } else {
      cout << "not coprime" << '\n';
    }
  }
  return 0;
}


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

int main() {
    string a, b;
    cin >> a >> b;
    
    if (a.size() > b.size()) {
        cout << "GREATER" << endl;
        return 0;
    }
    else if (a.size() < b.size()) {
        cout << "LESS" << endl;
        return 0;
    }
    
    if (a > b) cout << "GREATER" << endl;
    else if (a < b) cout << "LESS" << endl;
    else cout << "EQUAL" << endl;
}   

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let n: usize = input();
    let mut xyh: Vec<(i32, i32, i32)> = (0..n).map(|_| (input(), input(), input())).collect();
    xyh.sort_by_key(|&(_, _, h)| -h);

    let mut ans = (0, 0, 0);
    for cx in 0..101 {
        for cy in 0..101 {
            let (x, y, h) = xyh[0];
            let ch = h + i32::abs(x - cx) + i32::abs(y - cy);
            let ok = xyh.iter().all(|&x| {
                let (x, y, h) = x;
                h == std::cmp::max(0, ch - i32::abs(x - cx) - i32::abs(y - cy))
            });
            if ok {
                ans = (cx, cy, ch);
            }
        }
    }

    println!("{} {} {}", ans.0, ans.1, ans.2);
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

#define rep(i, n) for(int i=0;i<n;i++)

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

	if (a <= c && c <= b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;
  
#define MP make_pair
#define PB push_back
#define MAX_N 2001000
#define SIZE 2000
#define X first
#define Y second
  
const int STX = 1000, STY = 1000;
  
int id[SIZE][SIZE];
bool is_prime[MAX_N+1];
vector<pair<int, int> > coord;

void Sieve() {
  fill(is_prime, is_prime+MAX_N+1, true);
  is_prime[0] = is_prime[1] = false;
  for(int i=2; i*i<=MAX_N; i++) {
    if(is_prime[i]) {
      for(int j=i*i; j<=MAX_N; j+=i) {
	is_prime[j] = false;
      }
    }
  }
}

void MakeMap() {
  int x = STX, y = STY;
  int cnt = 0;
  
  coord.PB(MP(0, 0)); // no use
  cnt ++;
  coord.PB(MP(x, y)); // cnt = 1
  
  fill(id[0], id[0]+SIZE*SIZE+1, -1);
  
  const int dx[] = {0,-1,0,1};
  const int dy[] = {-1,0,1,0};
  
  int a = 0; x = STX+1; y = STY+1;
  while(cnt <= MAX_N) {
    a += 2;
    for(int turn=0; turn<4; turn++) {
      for(int i=0; i<a; i++) {
	x += dx[turn], y += dy[turn];
	coord.PB(MP(x, y));
	id[y][x] = ++ cnt;
      }
    }
    x++, y++;
  }
}

int dp[MAX_N+1];

int main() {
  
  Sieve();
  MakeMap();
  
  int m, n;

  while(cin >> m >> n && (m|n)) {
    
    //bool ok = false;
    
    fill(dp, dp+MAX_N+1, -1);
    dp[n] = is_prime[n];
    pair<int, int> ans(dp[n], n);
    
    queue<pair<int, int> > que;
    que.push(coord[n]);
    queue<int> q_dp;
    q_dp.push(dp[n]);
    while(!que.empty()) {
      pair<int, int> now = que.front(); que.pop();
      int tmp = q_dp.front(); q_dp.pop();
      int tmpid = id[now.Y][now.X];
      if(tmp < dp[tmpid]) continue;
      
      int noid = id[now.Y][now.X];
      
      for(int i=-1; i<=1; i++) {
	pair<int, int> nex = MP(now.X+i, now.Y+1);
	if(nex.X < 0 || SIZE <= nex.X || nex.Y < 0 || SIZE <= nex.Y) continue;
	int neid = id[nex.Y][nex.X];
	if(neid <= m) {
	  if(dp[neid] < dp[noid] + is_prime[neid]) {
	    dp[neid] = dp[noid] + is_prime[neid];
	    //if(is_prime[neid]) ok = true;
	    ans = max(ans, make_pair(dp[neid], neid));
	    que.push(nex);
	    q_dp.push(dp[neid]);
	  }
	}
      }

    }
    
    /*
    int res = dp[n], lastid = -1;
    if(is_prime[n]) lastid = n;
    
    for(int i=1; i<=m; i++) {
      if(res <= dp[i] && is_prime[i]) {
	res = dp[i];
	lastid = max(lastid, i);
      }
    }
    */
    if(ans.first == 0) cout << "0 0" << endl;
    else {
      int ans2 = 2;
      cout << ans.first << " ";
      for(int i=1; i<=m; i++) {
	if(ans.first == dp[i] && is_prime[i]) {
	  ans2 = max(ans2, i);
	}
      }
      cout << ans2 << endl;
    }
  }
  
  return 0;
}

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

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

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int y[24*3600];

int main(void){
    int n,sh,sm,ss,th,tm,ts,i,s,t,ans;
    while((n=in())){
        MEMSET(y);
        ans=0;
        rep(i,n){
            scanf("%d:%d:%d",&sh,&sm,&ss);
            scanf("%d:%d:%d",&th,&tm,&ts);
            s=sh*3600+sm*60+ss;
            t=th*3600+tm*60+ts;
            y[s]++;
            y[t]--;
        }
        for(i=1;i<24*3600;i++)y[i]+=y[i-1];
        rep(i,24*3600)ans=max(ans,y[i]);
        print(ans);
    }
    return 0;
}


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

int main(){
  int n, s[1000];
  double sum = 0;
  double a = 0;
  while(1){
    cin >> n;
    if(n == 0) break;
    for(int i = 0; i < n; i++){
      cin >> s[i];
      sum += s[i];
    }
    sum /= n;
    for(int i = 0; i < n; i++){
      a += (s[i]-sum) * (s[i]-sum);
    }
    a /= n;
    a = sqrt(a);
    printf("%lf\n", a);
    sum = 0;
    a = 0;
  }
}

Measured memory_bytes: 1192
N = int(input())
x = []
l = []
for i in range(N):
    x1,l1=[int(i) for i in input().split()]
    x.append(x1)
    l.append(l1)

Range = []

for i in range(N):
  max_i = x[i] + l[i]
  min_i = x[i] - l[i]
  Range.append((min_i,max_i,x[i], l[i]))

Range = sorted(Range, key = lambda x:x[1])

#print(Range)
a = 1

for i in range(N-1):
  #print(Range[a][0], end = ","),print(Range[a-1][1])
  if Range[a][0] >= Range[a-1][1]:
    a += 1
  else:
    #if Range[a][3] >= Range[a-1][3]:
      Range.pop(a)
    #else:
      #Range.pop(a-1)

#print(Range)
print(a)


Measured memory_bytes: 28624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5;

int main(){
	int Q;
	cin>>Q;
	lli A[100],B[100];
	rep(i,Q){
		cin>>A[i]>>B[i];
		if(A[i]==B[i])cout<<2*A[i]-2<<endl;
		else if(abs(A[i]-B[i])==1)cout<<2*min(A[i],B[i])-2<<endl;
		else{
			lli sq=sqrt(A[i]*B[i]);
			if(A[i]*B[i]==sq*sq)cout<<2*sq-3<<endl;
			else if(sq*(sq+1)>=A[i]*B[i])cout<<2*sq-2<<endl;
			else cout<<2*sq-1<<endl;
		}
	}
}


Measured memory_bytes: 256
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using std::min; using std::max;
using std::swap; using std::sort;
typedef long long ll;

template<typename T>
void read(T &x) {
	int flag = 1; x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') flag = -flag; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= flag;
}
#if __cplusplus >= 201103l
template<typename T, typename... V>
void read(T &x, V&... v) { read(x), read(v...); }
#endif

const int _ = 2e5 + 10, Inf = 2e9 + 10;
int n, rmx, rmn = Inf, bmx, bmn = Inf; ll ret;
std::multiset<int> r, b;

struct node {
	int v1, v2;
	node() {}
	node(int _v1, int _v2) { v1 = _v1, v2 = _v2; }
	bool operator < (const node &a) const { return v1 < a.v1; }
} p[_];

ll calc() { return 1ll * (*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()); }

int main () {
	read(n);
	for(int i = 1, x, y; i <= n; ++i) {
		read(x, y); if(x > y) swap(x, y);
		p[i] = node(x, y), r.insert(x), b.insert(y);
	}
	ret = calc(), sort(p + 1, p + n + 1);
	for(int i = 1; i <= n; ++i) {
		int x = p[i].v1, y = p[i].v2;
		r.erase(r.find(x)), b.erase(b.find(y));
		r.insert(y), b.insert(x);
		ret = min(ret, calc());
	}
	printf("%lld\n", ret);
	return 0;
} 


Measured memory_bytes: 20608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M=1e9+7;

ll dp[10001][101][2];
string s;

ll calculate(ll d,ll pos,ll sum,bool tight){
	if(pos==s.length()){
		return sum%d==0;
	}
	if(dp[pos][sum][tight]==-1){
		ll ub=9;
		ll count=0;
		if(tight)
			ub=s[pos]-'0';
		for(ll i=0;i<=ub;i++){
			count=(count+calculate(d,pos+1,(sum+i)%d,tight&(i==ub)))%M;
		}
		dp[pos][sum][tight]=count;
	}
	return dp[pos][sum][tight];
}

int main(){
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 cout.tie(NULL);	
 ll d;
 memset(dp,-1,sizeof dp);
 cin>>s>>d;
 //cout<<s<<endl;
 cout<<(calculate(d,0,0,1)-1+M)%M<<endl;;
 return 0;
}



Measured memory_bytes: 20340
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#define rep(i, N) for(int (i)=0; (i)<N;(i)++)
using namespace std;

int main(){
    string A;
    cin>>A;
    long n = A.size(), SUM=0;
    for(long bit=1; bit<(1<<n-1); ++bit){
        vector<long> S;
        for (long i=0; i<n; i++){
            if (bit & (1<<i)){
                S.push_back(i);
            }
        }
        map<long, string> R;
        rep(i, S.size()){
            if(i==0){ 
                R[i] = A.substr(0, S[i]+1);
                R[i+1] = A.substr(S[i]+1);
            }
            else{
                R[i] = R[i].substr(0, S[i]-S[i-1]);
                R[i+1] = A.substr(S[i]+1);
            }
        }
        int sum=0;
        rep(i, R.size()){
            sum += atol(R[i].c_str());
        }
        SUM += sum;
    }
    cout<<SUM+atol(A.c_str())<<endl;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main(){

	string s;
	string search;

	getline(cin,s);
	getline(cin,search);

	s += s;

	if(string::npos == s.find(search))
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 3224
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String c = sc.next();
    int d = c.charAt(0) - 'a';
    d++;
    String ans = String.valueOf((char)('a' + d));
    System.out.println(ans);
  }
}


Measured memory_bytes: 22608
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000

//貪欲に

int main(){

    long long  q, h, s, d; cin >> q >> h >> s >> d;
    long long n; cin >> n;
    s = min(min(4*q, 2*h), s);
    //cout << s << " " << d << endl;
    if(2*s <= d) cout << n * s << endl;
    else cout << (n / 2) * d + (n % 2) * s << endl;
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 084_abc_d / Link: https://abc084.contest.atcoder.jp/tasks/abc084_d?lang=en  ----- */
/* ------問題------

「N も (N+1)÷2 も素数」を満たす奇数 N を 2017に似た数 とします。
Q 個のクエリが与えられます。
クエリ i(1≦i≦Q) では奇数 li,ri が与えられるので、li≦x≦ri かつ 2017に似た数 となる奇数 x の個数を求めてください。

-----問題ここまで----- */
/* -----解説等-----

素数表ができれば後は適当に2017っぽい数がわかるので累積和をとれば十分高速。

----解説ここまで---- */

LL N;

LL ans = 0LL;
#define primeN 100000
bool prime[primeN + 1];// 外部だとハッシュ表みたいになる
void make_prime() {
	FOR(i, 0, primeN + 1) {
		prime[i] = 1;
	}prime[0] = prime[1] = 0;

	for (int i = 2; i <= primeN; i++) {
		if (prime[i]) {
			for (int j = i * 2; j <= primeN; j += i)
				prime[j] = 0;
		}
	}
}
#undef primeN 

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

	make_prime();

	VI like2017(100001, 0);
	FOR(i, 1, 100001) {
		if (i % 2 == 1 && prime[i] && prime[(i + 1) / 2]) {
			like2017[i] = 1;
		}
	}
	VI sum(100002, 0);
	FOR(i, 0, 100001) {
		sum[i + 1] += sum[i]+ like2017[i];
	}

	cin >> N;
	FOR(i, 0, N) {
		int L, R;
		cin >> L >> R;
		cout << sum[R+1] - sum[L] << endl;
	}

	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>


// #include <deque>
// #include <stack>
// #include <set>
// #include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>
// #include <queue>
// #include <tuple>

// #include <cmath>
// #include <numeric>

using namespace std;
typedef long long ll;
typedef long l;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
const char el = '\n';

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

    int a,b;
    cin>>a>>b;
    cin.ignore();

    /*
    floor(p/10) = b;
    floor(x) = y;
    y<=x<y+1 ??
    //e.g. if x = .5,
    floor(x)==0;

    if x = .999, y = floor(x) = 0;
    
    if x==0, y = floor(x) = 0;


    In our case, b<= p/10 <= b+1;
    10b<= p < 10b+10;

    */

    for (int p =10*b; p< 10*b+10 ; ++p){
        if ((8*p)/100 == a) {
            cout<<p<<el;
            return 0;
        }
    }
    
    cout<<-1<<el;
    
    // long n, m;
    // cin>>n>>m; cin.ignore();

}



Measured memory_bytes: 256
#include <iostream>
#include <string>

int main(){
	long long n,m,positives = 0;
	std::cin >> n >> m;

	if(n==1&&m==1)positives = 0;
	else if(n==1||m==1)positives = 2;
	else positives = (m + n - 2) * 2;

	std::cout<<(m*n - positives)<<std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;

vector<pair<int, int>> edg[100003];

int main() {
	int n, m, p; cin >> n >> m >> p;
	for (int i = 0; i < m; i++) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		edg[a].push_back({ b, p - c });
	}
	vector<ll> d(n, 1e9);
	d[0] = 0;
	for (int u = 0; u < 2*n; u++) {
		for (int i = 0; i < n; i++) {
			for (auto e : edg[i]) {
				if (d[i] != 1e9 && d[e.first] > d[i] + e.second) {
					d[e.first] = d[i] + e.second;
					
					if (u >= n - 1 && e.first == n - 1) {
						cout << -1 << endl;
						return 0;
					}
				}
			}
		}
	}
	cout << max(0LL, -d[n - 1]) << endl;
	return 0;
}



Measured memory_bytes: 2688
#include <bits/stdc++.h>
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  string s;
  cin >> s;
  deque<char> d;
  for (char c : s) d.pb(c);

  int q;
  cin >> q;
  bool flip = false;
  rep(_,q) {
    int ty;
    cin >> ty;
    if (ty == 1) {
      flip = !flip;
    }
    else {
      int f; char c;
      cin >> f >> c;
      if (flip) f = 3 - f;
      if (f == 1) d.push_front(c);
      else d.push_back(c);
    }
  }
  string ans;
  for (char c : d) ans += c;
  if (flip) reverse(rng(ans));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1412
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
 
ans = [-1] * (N+1)
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
    

from collections import deque
import sys
ans = [-1] * (N+1)
todo = deque([(1,0)])
while todo:
    x,parent = deque.popleft(todo)
    # ans[x] = parent
    for y in graph[x]:
        if y == parent:
            continue
        if ans[y] != -1:
            continue
        ans[y] = x
        todo.append((y,x))
        

if -1 in ans[2:]:
    print('No')
else:
    print('Yes')
    for i in range(2,N+1):
        print(ans[i])

Measured memory_bytes: 123016
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1007;

int n;

vector <vi> wek;

vector <pii> wyn;

int main()
{
	scanf("%d", &n);
	if (n&1)
	{
		for (int i=1; i<n-i; i++)
			wek.push_back({i, n-i});
		wek.push_back({n});
	}
	else
	{
		for (int i=1; i<n+1-i; i++)
			wek.push_back({i, n+1-i});
	}
	for (int i=0; i<(int)wek.size(); i++)
	{
		for (int j=0; j<i; j++)
		{
			for (int a : wek[i])
			{
				for (int b : wek[j])
				{
					wyn.push_back({a, b});
				}
			}
		}
	}
	printf("%d\n", (int)wyn.size());
	for (pii i : wyn)
		printf("%d %d\n", i.first, i.second);
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

vector<Int> a = {2, 3, 4, 6, 8, 9, 10, 12};
vector<vector<Int>> b = {
	{0, 0, 0, 0, 0, 0, 0, 0},
	{0, 0, 0, 1, 0, 0, 0, 0},
	{1, 0, 1, 0, 0, 0, 0, 0},
	{1, 0, 1, 1, 0, 0, 0, 0},
	{1, 0, 1, 0, 1, 0, 1, 0},
	{1, 1, 1, 1, 0, 1, 0, 0},
	{1, 1, 1, 1, 0, 1, 0, 1},
	{1, 1, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1, 1}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n; cin >> n;
	if(n == 3){
		cout << 2 << " " << 5 << " " << 63 << "\n";
	}else if(n == 4){
		cout << 2 << " " << 5 << " " << 20 << " " << 63 << "\n";
	}else{
		Int m = n/8;
		Int r = n - m*8;
		for(Int i=0; i<m; ++i)
			for(Int j=0; j<8; ++j)
				cout << 12*i + a[j] << " ";
		for(Int i=0; i<8; ++i)
			if(b[r][i] == 1)
				cout << 12*m + a[i] << " ";
		cout << "\n";
	}
}

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

int V;
int d[15][15];
int dp[1 << 15][15];

int rec(int S, int v) {
	if (dp[S][v] >= 0)return dp[S][v];
	if (S == (1 << V) - 1 && v == 0)return dp[S][v] = 0;
	int res = INF;
	rep(u, V) {
		if (!(S >> u & 1))res = min(res, rec(S | 1 << u, u) + d[v][u]);
	}
	return dp[S][v] = res;
}
int main() {
	int E; scanf("%d%d", &V, &E);
	memset(d, 0x3f, sizeof(d));
	memset(dp, -1, sizeof(dp));
	rep(i, E) {
		int s, t, c; scanf("%d%d%d", &s, &t, &c);
		d[s][t] = c;
	}
	int ans = rec(0, 0);
	printf("%d\n", ans == INF ? -1 : ans);
}

Measured memory_bytes: 5140
using System;
using System.Text;
using System.Linq;
class p
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    string[] arr = new string[N];
    bool result = true;
    for (int i = 0; i < N; i++) {
      string s = Console.ReadLine();
      if (0 < i) {
        if (arr.Contains(s) || s[0] != arr[i-1][arr[i-1].Length-1]) {
          result = false;
          break;
        }
      }
      arr[i] = s;
    }
    Console.WriteLine(result ? "Yes" : "No");
  }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
int cnt[26];
int main() {

  	int n;
	scanf("%d", &n);
  	for (int i = 0; i < n; ++i) {
    	char x;
    	scanf(" %c", &x);
    	cnt[x-'a']++;
    }
  	long long prod = 1;
  	for (int i = 0; i < 26; ++i) {
    	prod *= cnt[i]+1;
      	prod %= (int)(1e9+7);
    }
  	printf("%d\n", (prod-1));
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n+1]={0};
    for(int x=1;x*x<=n;x++){
        for(int y = 1;y*y<=n;y++){
            for(int z = 1;z*z<=n;z++){
                int ans = x*x+y*y+z*z+x*y+y*z+z*x;
                if(ans<=n)
                    a[ans]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
        cout<<a[i]<<"\n";
    return 0; 
}

Measured memory_bytes: 3484
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
int cnt[505][505],dp[505][505];
int main()
{
	int n,m,Q,p,q,i,j;
	scanf("%d%d%d",&n,&m,&Q);
	while(m--) scanf("%d%d",&i,&j),cnt[i][j]++;
	for(i=n;i>=1;i--) for(j=i;j<=n;j++)
	dp[i][j]=cnt[i][j]+dp[i][j-1]+dp[i+1][j]-dp[i+1][j-1];
	while(Q--)
	{
		scanf("%d%d",&p,&q);
		cout<<dp[p][q]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include<cstdio>
int N,Q[1000010];
char S[1000010],T[1000010];
int main(){
	scanf("%d%s%s",&N,S,T);
	bool eq=1;
	for(int i=0;i<N&&eq;i++)if(S[i]!=T[i])eq=0;
	if(eq)return puts("0"),0;
	int ans=0,*h=Q+N,*t=Q+N,a=0;
	for(int l=N,r=N,i=N;r;r=l){
		for(l--;l&&T[l-1]==T[l];l--);
		for(i>l?i=l:1;i>=0&&S[i]!=T[l];i--);
		if(i<0)return puts("-1"),0;
		while(h<t&&t[-1]+a>=r)t--;
		*--h=(i--)-(--a);
		if(t-h>ans)ans=t-h;
	}
	printf("%d\n",ans);
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

const double PI = acos(-1);
#define MOD 1000000007  ///1e9+7

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) abs((a)*(b))/gcd((a),(b))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

///******************************** C o d e ********************************///



main()
{
    ll n,i,k,x,y,c=0;
    map<ll,ll> m;
    cin>>n>>k;
    ll a[n+1];
    for(i=1;i<=n;i++) {cin>>a[i]; m[i]=0;}
    for(i=0;i<k;i++){
        cin>>x>>y;
        m[x]=max(m[x],a[y]);
        m[y]=max(m[y],a[x]);
    }
    for(i=1;i<=n;i++){
        if(m[i]<a[i]) c++;
    }
    cout<<c el;
}



///Thank you.



///Brainless_Loco Terminates Here!


Measured memory_bytes: 10620
main = interact $ unlines . map (show . millennium . map read . words) . tail . lines

millennium :: [Int] -> Int
millennium [y,m,d] = day 1000 1 1 - day y m d

day y m d = (y-1) * 195 + (m-1) * 20 + d + diff_y - diff_m
 where
  diff_y = div (y-1) 3 * 5
  diff_m = if mod y 3 /= 0 then div (m-1) 2 else 0

Measured memory_bytes: 3944
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

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

    std::cout<<std::count(s.begin(), s.end(), '1')
        <<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

/*
    Author: Koushik Sahu
    Created: 29 August 2020 Sat 18:03:49
*/

int n, a[1000001];
bool divisors[1000001];

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin>>n;
    int whole = -1;
    bool pairwise = true;
    fill_n(divisors, 1000001, false);
    for(int i=0; i<n; i++){
        cin>>a[i];
        if(a[i]!=1){
            if(divisors[a[i]]){
                pairwise = false;
            }else{
                for(int j=2; j<=sqrt(a[i]); j++){
                    if(a[i]%j==0){
                        int x = j;
                        int y = a[i]/j;
                        if(divisors[x]){
                            pairwise = false;
                        }else{
                            divisors[x] = true;
                        }
                        if(x!=y){
                            if(divisors[y]){
                                pairwise = false;
                            }else{
                                divisors[y] = true;
                            }
                        }
                    }
                }
                divisors[a[i]] = true;
            }
        }
        if(whole==-1){
            whole = a[i];
        }else{
            whole = __gcd(whole, a[i]);
        }
    }
    if(pairwise){
        cout<<"pairwise coprime\n";
    }else if(whole==1){
        cout<<"setwise coprime\n";
    }else{
        cout<<"not coprime\n";
    }
    return 0;
}

Measured memory_bytes: 8500
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define rep(i,n) rep1(i,0,n)
#define rep1(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
const double PI = acos(-1);

int main(){
    int n, k;
    cin >> n >> k;
    double res = 0;
    rep1(i,1,n+1){
        int m = i;
        double p = 1.00 / n;
        while (m < k)
        {
            m *= 2;
            p *= 0.5;
        }
        res += p;
    }
    cout << setprecision(10) << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string s;
	cin>>s;
	sort(s.begin(),s.end());

	string t;
	cin>>t;
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());

	if(s<t)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256