akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
const int nmax = 8;

bool visited[nmax];
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax])
{
    bool all_visited = true;
    for (int i = 0; i < N; i++)
    {
        if (visited[i] == false)
        {
            all_visited = false;
        }
    }
    if (all_visited)
    {
        return 1;
    }

    int ret = 0;
    for (int i = 0; i < N; i++)
    {
        if (graph[v][i] == false)
            continue;
        if (visited[i])
            continue;

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

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

    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        graph[a - 1][b - 1] = true;
        graph[b - 1][a - 1] = true;
    }
    visited[0] = true;
    cout << dfs(0, N, visited) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
int main(){
  int a,b;	
  cin >> a >> b;
  if (a > 0 && a < 10 && b > 0 && b < 10){
  cout << a * b << endl;
  }
  else{
  cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 11
#define INF 9999999

int n,r[MAX][MAX],v[MAX],mini,mn,maxnum,minnum;
bool visit[MAX];

int dijkstra(int s){
    for(int i = 0 ; i < MAX ; i++){
        v[i] = INF;
        visit[i] = false;
    }
    
    v[s] = 0;
    while(true){
        mini = INF;
        for(int i = 0 ; i <= maxnum ; i++){
            if(v[i] < mini && !visit[i]){
                mini = v[i];
                mn = i;
            }
        }
        
        if(mini == INF) break;
        visit[mn] = true;
        
        for(int i = 0; i <= maxnum ; i++){
            int t = r[mn][i]+v[mn];
            v[i] = min(v[i],t);
        }
    }
    
    int sum = 0;
    for(int i = 0 ; i <= maxnum ; i++){
        sum += v[i];
    }
    
    return sum;
}


int main(){
    int a,b,c;

    while(cin >> n,n){
        
        for(int i = 0 ; i < MAX ; i++)
            for(int j = 0 ; j < MAX ; j++)
                r[i][j] = INF;
        
        maxnum = 0;
        for(int i = 0 ; i < n ; i++){
            cin >> a >> b >> c;
            r[a][b] = c;
            r[b][a] = c;
            maxnum = max(maxnum,max(a,b));
        }

        int mx = INF, e;
        for(int i = 0 ; i <= maxnum ; i++){
            int val = mx;
            mx = min(mx,dijkstra(i));
            if(val > mx) e = i;
        }
        cout << e << " " << mx << endl;
    }
    
    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) cin >> v[i];
    sort(all(v), greater<>());
    int sum = 0;
    for(int i = 0; i < k; ++i) {
        sum += v[i];

    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
//  author  :  brucewayne8
#include <bits/stdc++.h>
#define fast       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll         long long
//pair
#define pii        pair<int,int>
#define fi         first
#define sec        second
//end


//vector
#define vi          vector<int>
#define vl          vector<long>
#define vii         vector<pii>
#define vs          vector<string>
#define sz(x)       (int)x.size()
#define pb          push_back
//end


//matrice
#define vvi         vector<vector<int>>
#define vvii        vector<vector<pii>>
//end


//map
#define mi          map<int,int>
#define mii         map<pii,int>
//end


//loop
#define f(i,a,b)  for(int i=a;i<b;i++)
#define f0(i,a)  for(int i=0;i<a;i++)
#define rf(i,a,b)  for(int i=b;i>=a;i--)
#define rf0(i,a)  for(int i=a;i>=0;i--)
//end


//nec
#define int         ll
#define endl        '\n'
const int mod  = 1e9+7 ;
//end


using namespace std;

void solve(){
    int n;
    cin >>n;
    int d1,d2;
    vector<int> arr;
    f0(i,n){
        cin>>d1>>d2;
        if(d1==d2) arr.pb(0);
        else arr.clear();
        if(arr.size()==3) {cout<<"Yes"<<endl; return;}
    }
    cout<<"No"<<endl;

}


int32_t main(){
fast;
int t=1;
// cin>>t;
f(i,0,t){
//cout<<"Case #"<<i+1<<": ";
solve();
}
return 0;
}

Measured memory_bytes: 3564
import sys
import itertools
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

#max(chr(ord("z")+1), 
def tami(re,res,cnt,ma):
  if cnt == N:
    ans.append(res)
    return
  for i in range(ord("a"), ma+2):
    tami(chr(i),res+chr(i),cnt+1,max(ma, i))

N = I()

ans = []
tami(chr(ord("a")-1),"",0,ord("a")-1)
ans.sort()
for i in ans:
  print(i)

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

int main(){
	string S;
	cin >> S;
	for(int i = 0; i < S.length(); i++){
		string sub = S.substr(i, 1);
		if((i+1) % 2 == 0){
			if(sub == "R"){
				cout << "No" << endl;
				return 0;
			}
		}else{
			if(sub == "L"){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m;
pair <pair <int, int>, int> q[200005];
vector <pair <int, int> > g[100005];
int val[100005], vis[100005];
void dfs(int u, int V) {
	vis[u] = 1; val[u] = V;
	for (int i = 0; i < g[u].size(); ++ i) {
		int v = g[u][i].first, w = g[u][i].second;
		if (!vis[v]) dfs(v, V + w);
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++ i) {
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		-- u, -- v;
		q[i] = make_pair(make_pair(u, v), w);
		g[u].push_back(make_pair(v, w));
		g[v].push_back(make_pair(u, -w));
	}
	for (int i = 0; i < n; ++ i) {
		if (!vis[i]) dfs(i, 0);
	}
	for (int i = 0; i < m; ++ i) {
		if (val[q[i].first.second] - val[q[i].first.first] != q[i].second) {
			puts("No"); return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

using namespace std;

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

    for(int i=0;i<s.length()-1;i++){
        if(s.substr(i,2) == "AC"){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0) cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
} 


Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d', $N);
for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, '%d %d %d', $a, $b, $c);
    $a2 = pow($a, 2);
    $b2 = pow($b, 2);
    $c2 = pow($c, 2);

    if ($a2 + $b2 === $c2 || $a2 + $c2 === $b2 || $b2 + $c2 === $a2) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}

Measured memory_bytes: 6548
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

//Main
var sc = bufio.NewScanner(os.Stdin)
var N, M, X int

const MAX = 12

func main() {
	sc.Split(bufio.ScanWords)
	N, M, X = nextInt(), nextInt(), nextInt()

	C := make([]int, N)
	var A [MAX][MAX]int

	for i := 0; i < N; i++ {
		C[i] = nextInt()
		for j := 0; j < M; j++ {
			A[i][j] = nextInt()
		}
	}

	L := 1
	for i := 1; i <= N; i++ {
		L *= 2
	}

	minv := -1
	for i := 0; i < L; i++ {
		cost := 0
		skills := make([]int, M)
		b := fmt.Sprintf("%012b", i)

		b = b[12-N:]

		for j := 0; j < N; j++ {
			//fmt.Println(string(b[j]))
			if string(b[j]) == "1" {
				cost += C[j]
				for k := 0; k < M; k++ {
					skills[k] += A[j][k]
				}
			}

		}

		//fmt.Println(b, skills)

		ok := true
		for j := 0; j < M; j++ {
			if skills[j] < X {
				ok = false
				break
			}
		}

		if ok {
			if minv == -1 {
				minv = cost
			} else {
				minv = minInt(minv, cost)
			}

		}

	}

	fmt.Println(minv)

}


Measured memory_bytes: 2244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()

const int N = 100010;
int a[N], vis[N], n, m;
vector<int> adj[N];
vector<ii> comp;

void dfs (int u) {
  vis[u] = 1;
  comp.push_back({u, a[u]});
  for (int v : adj[u]) if (!vis[v]) dfs(v);
}

int main() {
  scanf("%d%d", &n, &m);
  int u, v;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int ans = 0;
  memset(vis, 0, sizeof vis);
  for (int i = 1; i <= n; i++) if (!vis[i]) {
    dfs(i);
    set<int> v;
    for (const auto& p : comp) v.insert(p.second);
    for (const auto& p : comp) ans += v.count(p.first);
    comp.clear();
  }
  printf("%d\n", ans);
}



Measured memory_bytes: 14964
while True:
    x=int(input())
    
    if x==0:
        break
    
    y=1000-x

    m1=y//500
    m2=(y-(500*m1))//100
    m3=((y-(500*m1))-(100*m2))//50
    m4=(((y-(500*m1))-(100*m2))-(50*m3))//10
    m5=((((y-(500*m1))-(100*m2))-(50*m3))-(10*m4))//5
    m6=((((y-(500*m1))-(100*m2))-(50*m3))-(10*m4))-5*m5
    
    z=m1+m2+m3+m4+m5+m6
    
    print(z)


Measured memory_bytes: 5592
// https://atcoder.jp/contests/abc156/tasks/abc156_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> V(N);
    REP(i, N) { cin >> V[i]; }
    int sum = accumulate(ALL(V), 0LL);
    int avg = round((double)sum / N);
    int ans = 0;
    REP(i, N) { ans += (V[i] - avg) * (V[i] - avg); }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main(void){

  int CNT = 0;
  string s;
  while( cin >> s ){

    int N = s.size();
    int cnt = 0;
    if( N == 1 ){
      CNT++;
      // cout << "OK" << endl;
      continue;
    }
    int x = 0;
    int y = N - 1;
    while(1){

      if( x >= N/2 )break;
     
      if( s[x] == s[y] ){
	cnt++;
	x++;
	y--;
      }
      else{
	break;
      }
    }
    
    if( cnt == N/2 ){
      CNT++;
      // cout << "ok" << endl;
    }
  }
  cout << CNT << endl;
  return 0;
}

Measured memory_bytes: 1184
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn msd(mut n: i64) -> i64 {
    while n >= 10 {
        n /= 10;
    }
    n
}

fn main() {
    let N = read!(i64);

    let mut map = vec![vec![0_i64; 10]; 10];
    let mut count = 0_i64;

    for A in 1..N + 1 {
        let x = msd(A) as usize;
        let y = (A % 10) as usize;

        if x == 0 || y == 0 {
            continue;
        }

        count += if x == y {
            map[y][x] * 2 + 1
        } else {
            map[y][x] * 2
        };

        map[x][y] += 1;
    }

    println!("{}", count)
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int n, d, x;
	cin >> n >> d >> x;
	int p[11][11];
	for(int i = 0; i < d; i++){
		for(int j = 0; j < n; j++){
			cin >> p[i][j];
		}
	}
	for(int i = 0; i < d - 1; i++){
		int dp[11][100001] = {};
		for(int j = 0; j < 100001; j++){
			dp[n][j] = j;
		}
		for(int j = n - 1; j >= 0; j--){
			for(int k = 0; k < 100001; k++){
				dp[j][k] = dp[j + 1][k];
				int tmp = p[i + 1][j];
				if(k - p[i][j] >= 0){
					tmp += max(dp[j + 1][k - p[i][j]], dp[j][k - p[i][j]]);
					dp[j][k] = max(tmp, dp[j + 1][k]);
				}
				// cout << j << " " << k << " " << dp[j][k] << endl;
			}
		}
		x = dp[0][x];
	}
	cout << x << endl;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s1, s2, s3; cin >> s1 >> s2 >> s3;
    cout << (char)(s1[0]-32) << (char)(s2[0]-32) << (char)(s3[0]-32) << endl;

    return 0;
}


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

void LCS(char *x, char *y){
	int m = strlen(x+1);
	int n = strlen(y+1);
	int i, j, **c;
	
	c = malloc(sizeof(int)*(2205));
	for (i = 0; i <= m; i++)
		c[i] = malloc(sizeof(int)*(2205));
	
	for (i = 0; i <= m; i++){
		for (j = 0; j <= n; j++){
			c[i][j] = 0;
		}
	}
	
	for (i = 1; i <= m; i++){
		for (j = 1; j <= n; j++){
			if (x[i] == y[j])
				c[i][j] = c[i - 1][j - 1] + 1;
			else if (c[i - 1][j] >= c[i][j - 1])
				c[i][j] = c[i - 1][j];
			else
				c[i][j] = c[i][j - 1];
		}
	}
	
	printf("%d\n", c[i-1][j-1]);
	for (i = 0; i < m; i++)free(c[i]);
	free(c);
	
}

int main(){
	int i, n;
	char x[1001], y[1001];

	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%s%s", x + 1, y + 1);
		LCS(x, y);
	}
	return 0;
}

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

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(n*a,b) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#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)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

int signof(int a) {
	if(a>0) return 1;
	if(a<0) return -1;
	return 0;
}

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];

	int count = 0;
	for(int i=0;i<n;i++) {
		count++;
		while(a[i+1]-a[i]==0) {
			i++;
			if(i+1==n) goto stop;
		}
		int sign = signof(a[i+1]-a[i]);
		while((a[i+1]-a[i])*sign>=0) {
			i++;
			if(i+1==n) goto stop;
		}
	}

stop:
	print(count);

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int a, b, c, d;
	a = (int)(s[0] - '0');
	b = (int)(s[1] - '0');
	c = (int)(s[2] - '0');
	d = (int)(s[3] - '0');
	int ans;
	string op1, op2, op3;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				if (i == 0) { ans = a + b; }
				else { ans = a - b; }
				if (j == 0) { ans += c; }
				else { ans -= c; }
				if (k == 0) { ans += d; }
				else { ans -= d; }
				if (ans == 7) {
					if (i == 0) { op1 = "+"; }
					else { op1 = "-"; }
					if (j == 0) { op2 = "+"; }
					else { op2 = "-"; }
					if (k == 0) { op3 = "+"; }
					else { op3 = "-"; }
					cout << s[0] + op1 + s[1] + op2 + s[2] + op3 + s[3] + "=7" << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

const long long mod = 1e9 + 7;

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

	long long p = 1;
	for (int i = 1; i <= n; i++) {
		p = (p*i)%mod;
	}
	std::cout << p << std::endl;

}

Measured memory_bytes: 764
n, k = [int(i) for i in input().split()]
s = [int(i) for i in input()]

p = []
counter = 1
if s[0] == 0:
    p.append(0)
for i in range(1, n):
    if s[i] == s[i-1]:
        counter += 1
    else:
        p.append(counter)
        counter = 1
p.append(counter)

l = p[0::2] + [0, 0]
r = p[1::2]

counter = sum(r[:k]) + sum(l[:k+1])
imax = counter
for i in range(k, len(r)):
    counter += l[i+1] + r[i]
    counter -= l[i-k] + r[i-k]
    if counter > imax:
        imax = counter

print(imax)

Measured memory_bytes: 5532
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

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

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

double dist(double x, double y, double a, double b){
  return sqrt((x - a) * (x - a) + (y - b) * (y - b));
}

void solve(){
  int N;
  cin >> N;
  vector<double> x(N), y(N);
  rep(i, N) cin >> x[i] >> y[i];
  double sum = 0;
  rep(i, N)rep(j, N) sum += dist(x[i], y[i], x[j], y[j]);
  sum /= N * N - N;
  double ans = sum * (N-1);
  pres(ans);

}

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


Measured memory_bytes: 896
//============================================================================
// Name        : abc141_c.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

// わずかに早くなるかも
#pragma GCC optimize ("Ofast")
// 浮動小数点数の計算がボトルネックとなるときは 100ms くらい改善するかも？
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
using namespace std;

// K から自分以外が正解した回数を引いて 0 以下なら No
// <=> K - (解答できなかった回数) <= 0 なら No
// <=> K - (Q - 解答できた回数) <= 0 なら No
// <=> K - Q + (解答できた回数) <= 0 なら No
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, K, Q;
	cin >> N >> K >> Q;
	int count[N + 1] = {0}; // count[0] は使わない, count[1]~count[N] を使う
	int A[Q + 1] = {0}; // A[0] は使わない, A[1]~A[i]~A[Q] を使う
	// 解答者の入力 -> 解答者ごとの解答数の集計
	for (int i = 1; i <= Q; ++i) { // i 番目に正解したのは参加者 A[i]
		cin >> A[i];
		++(count[A[i]]);
	}
	// 出力
	for (int j = 1; j <= N; ++j) {
		cout << ((K - Q + count[j] <= 0) ? "No" : "Yes") << endl;
	}
	return 0;
}


Measured memory_bytes: 1408
import java.io.IOException;
import java.util.NavigableSet;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if ((n | m) == 0)
				break;
			int[] num = new int[n + 1];
			for (int i = 1; i <= n; i++)
				num[i] = scanner.nextInt();
			NavigableSet<Integer> set = new TreeSet<Integer>();
			for (int i = 0; i <= n; i++)
				for (int j = i; j <= n; j++)
					if (num[i] + num[j] <= m)
						set.add(num[i] + num[j]);
			int ans = 0;
			int l = set.first();
			int r = set.last();

			while (!set.isEmpty()) {
				if (l + r < m) {
					ans = Math.max(ans, l + r);
					l = set.pollFirst();
				} else {
					r = set.pollLast();
				}
			}
			System.out.println(ans);

		}
	}
}

Measured memory_bytes: 141540
#include <iostream>
#include <cmath>

#define INF 10000001

long long h[INF][3];
long long dp[INF][3];

void cmpmax(long long *,long long );

int main(void){
  int n;
  std::cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      std::cin >> h[i][j];
      dp[i][j] = 0;
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(j!=k){
          cmpmax(&dp[i+1][k],dp[i][j]+h[i][k]);
        }
      }
    }
  }
  long long res = 0;
  for(int i=0;i<3;i++){
    cmpmax(&res,dp[n][i]);
  }
  std::cout << res << std::endl;
  return 0;
}

void cmpmax(long long *a,long long b){
  if(*a<b){*a = b;}
}


Measured memory_bytes: 8448
#include <stdio.h>
   
int main(int argc, const char * argv[]) {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if(a <= b){
    if(b <= c)
      printf("%d %d %d\n", a, b, c);
    else
      if(a <= c)
        printf("%d %d %d\n", a, c, b);
      else
        printf("%d %d %d\n", c, a, b);
  }else{
    if(a <= c)
      printf("%d %d %d\n", b, a, c);
    else
      if(b <= c)
        printf("%d %d %d\n", b, c, a);
      else
        printf("%d %d %d\n", c, b, a);  
  }  
return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main() {
    // int n;
    // scanf("%d", &n);
    char c[5];
    int i;
    scanf("%s", c);
    for(i = 0; i < 2; i++) {
        if(c[i] == c[i+1] && c[i] == c[i+2]) {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
const ll M=1000000007;
//------------------------------------------//

int main(){
    ll X;cin>>X;
    ll money=100;
    int ans=0;

    rep(i,10000){
        money+=money/100;
        
        ans++;
        if(money>=X) break;
    }
   
    cout<<ans<<endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100003;
const int mod = 1e9 + 7;

int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };
int n;
int a;
map<int,int>mp;
int main() {
//	freopen("input.txt", "r", stdin);
scanf("%d",&n);
int mx1=0,mx2=0;
for(int i=0;i<n;i++){
	scanf("%d",&a);
	mp[a]++;
	if(mx1>mx2)
		swap(mx1,mx2);
	if(mp[a]>=2 && a>mx1){
mx1=a;
mp[a]-=2;
	}
	if(mp[a]>=2 && a>mx2){
mx2=a;
mp[a]-=2;
	}

}
cout<<(ll) mx2 *mx1;



}



Measured memory_bytes: 4992
import sys

mod = 10**9 + 7

def solve():
    n, m = map(int, input().split())
    x = [int(i) for i in input().split()]
    y = [int(i) for i in input().split()]

    ans = calc_all_section_length_sum(x)
    ans = (ans * calc_all_section_length_sum(y)) % mod

    print(ans)

def calc_all_section_length_sum(a):
    n = len(a)
    res = 0

    for i, ai in enumerate(a):
        res += (ai * (2*i + 1 - n)) % mod
        res %= mod

    return res

if __name__ == '__main__':
    solve()

Measured memory_bytes: 19648
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  if (a < 3200)
  {
    cout << "red" << endl;
  }
  else
  {
    cout << s << endl;
  }

  return 0;
}


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

string T = "AKIHABARA";

int main(){
    string S;
    int Slen;
    int dp[10][10] = {};
    cin >> S;
    Slen = S.length();
    if(Slen > 9){
        cout << "NO" << endl;
        return 0;
    }
    for(int i=1;i<=9;i++){
        for(int j=1;j<=Slen;j++){
            if(T[i-1] == S[j-1]){
                dp[i][j] = max({dp[i-1][j-1]+1, dp[i-1][j], dp[i][j-1]});
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    bool KIHBR = ((S.find('K') != string::npos) && (S.find('I') != string::npos) &&
                  (S.find('H') != string::npos) && (S.find('B') != string::npos) &&
                  (S.find('R') != string::npos));
    if(dp[9][Slen] == Slen && KIHBR){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#if defined(LOCAL)
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#endif
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<int, int>;
using lu = unsigned long long;
using l = long long;
using vs = vector<string>;
using vii = vector<ii>;
using vl = vector<l>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using ll = pair<l, l>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using mll = unordered_map<l, l>;
using sl = unordered_set<l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10;
const double PI = 3.14159265358979323846;
const l e0 = 1, e3 = 1000, e5 = 100000, e6 = 10 * e5, e7 = 10 * e6,
        e8 = 10 * e7, e9 = 10 * e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a, b, c) for (l a = l(b); a < l(c); a++)
#define B(a, b, c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

void solve(istream &in, ostream &out);
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  tst::test_init(argc, argv);
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  tst::maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}
const l MOD = e9 + 7; // end of template

void solve(istream &in, ostream &out) {
  l n; in >> n;
  l x, y; in >> x >> y; x *= 1000; y *= 1000;
  l z = 0;
  l best = INF;
  F(i, 0, n) {
    l h; in >> h;
    l t = x - h * 6;
    if (abs(t - y) < best) {
      best = abs(t - y);
      z = i;
    }
  }
  out << z + 1 << lf;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <algorithm>
#include <strstream>
#include<vector>
using namespace std;

int main(){
	int t,n;
	while(cin>>t && t)
	{
		cin>>n;
		int ans=0;
		for(int i=0; i<n; i++)
		{
			int a,b;
			cin>>a>>b;
			ans+=b-a;
		}
		if(ans>=t)puts("OK");
		else cout<<t-ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL

struct Edge {
	int from, to;
	ll w;
};
typedef vector<vector<Edge>> Graph;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}

ll gettugibaisu(ll from, ll k) {

	ll ret = ((from + k - 1) / k) * k;

	return ret;
}

ll getmaebaisu(ll to, ll k) {

	ll ret = (to / k) * k;

	return ret;
}


signed main(void) {
	int n, m;
	cin >> n >> m;
	Graph g(n);
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].push_back({a,b,1});
		g[b].push_back({ b,a,1 });
	}

	vector<int> wh(n, 2);

	int cou[2] = {};

	function<bool(int, int)> dfs = [&](int c, int pc) {
		wh[c] = 1 - pc;
		cou[wh[c]]++;
		for (auto itr : g[c]) {
			if (wh[itr.to] != 2 && wh[itr.to] == wh[c]) {
				return false;
			}
			if (wh[itr.to] == 2) {
				if (!dfs(itr.to, wh[c])) {
					return false;
				}
			}
		}

		return true;
	};

	bool nibu = dfs(0, 0);

	if (!nibu) {
		cout << (ll)(n - 1)*n / 2  - m<< endl;
	}
	else {
		cout << ((ll)cou[0] * cou[1]) - m << endl;
	}
	return 0;
}



Measured memory_bytes: 8576
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NK = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, K) = (NK[0], NK[1]);

        var ans = 0.0;

        for (int i = 0; i < N; i++)
        {
            var now = i + 1L;
            var count = 0;
            while(now < K)
            {
                now *= 2;
                count++;
            }

            ans += (1.0 / N) * Math.Pow(0.5, count);
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 28676
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    if k == 0:
        print(n**2)
        return
    ans = 0
    for b in range(k+1,n+1):
        s = n//b
        ans += s*(b-k)
        ans += max(0,n-s*b-k+1)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38896
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
using namespace std;

long long H,W,N;

bool in_area(long long x, long long y){
	return x >=1 && y >= 1 && x+2 <= H && y+2 <= W;
}

int main(){
	while(cin >> H >> W >> N){
		vector< pair<long long,long long> > v(N+10);
		vector< pair<long long,long long> > s;
		set < pair<long long,long long> > S;
		long long ans[10] = {0};
		for(int i=0;i<N;i++){
			int a, b;
			cin >> a >> b;
			v[i] = make_pair(a,b);
		}
		for(int i=0;i<v.size();i++){
			for(int k=0;k<3;k++){
				for(int l=0;l<3;l++){
					if(in_area(v[i].first-k,v[i].second-l)){
						s.push_back(make_pair(v[i].first-k,v[i].second-l));
						S.insert(make_pair(v[i].first-k,v[i].second-l));
					}
				}
			}
		}
		if(s.size()!=0){
			sort(s.begin(),s.end());
			long long j = 0, count = 1;
			while(j<=s.size()-2){
				if(s[j] == s[j+1]){
					count++;
					j++;
				}else{
					ans[count]++;
					count = 1;
					j++;
				}
			}
			ans[count]++;
		}
		ans[0] = (H-2)*(W-2) - S.size();
		for(int i=0;i<10;i++){
			cout << ans[i] << endl;
		}
	}
}

Measured memory_bytes: 73956
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

bool used[200005];

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

    int n, q;
    cin >> n >> q;
    vector<tuple<int, int, int>> tup(n);
    set<P> s;
    for(int i = 0; i < n; ++i){
        int s, t, x;
        cin >> s >> t >> x;
        s -= x;
        t -= x;
        tup[i] = tie(x, s, t);
    }
    for(int i = 0; i < q; ++i){
        int d;
        cin >> d;
        s.insert(P(d, i));
    }
    
    sort(tup.begin(), tup.end());
    vector<int> res(q, -1);
    for(int i = 0; i < n; ++i){
        int x, st, term;
        tie(x, st, term) = tup[i];
        auto it = s.lower_bound(P(st, -1));
        while(it != s.end()){
            if(it->first >= term)   break;
            res[it->second] = x;
            auto tmp = it++;
            s.erase(tmp);
        }
    }

    for(int i = 0; i < q; ++i){
        cout << res[i] << "\n";
    }
}


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

using namespace std;

int a[111111];
int dp[111111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m;
	for(int i=0;i<m;i++) cin>>a[i];
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		dp[i]=int(1e9);
		for(int j=0;j<m;j++)
		{
			if(i>=a[j])
			{
				dp[i]=min(dp[i],dp[i-a[j]]+1);
			}
		}
	}
	cout<<dp[n]<<'\n';
}

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

int main() {
    string S;
    cin >> S;
    bool A=false;
    for (int i=0 ; i<S.size()-1 ; i++){
        if (S.at(i)==S.at(i+1))
        A=true;
    }
    if (A==true)
    cout << "Bad" << endl;
    else if (A==false)
    cout << "Good" << endl;
}

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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

/*// x0, y0, y1, complexity
char dpx[190][190][190][17];
// x0, y0, x1, complexity
char dpy[190][190][190][17];*/
int H, W;
vector<string> s;
char dp[20000][20000];
int encode[190][190];

int calc(int x0, int y0, int x1, int y1) {
    if (x1 == x0 || y1 == y0)
        return 0;
    if (x1 <= x0+1 && y1 <= y0+1)
        return 0;
    //cerr << x0 << " " << y0 << " " << x1 << " " << y1 << endl;
    char& dpVal = dp[encode[x0][x1]][encode[y0][y1]];
    if (dpVal)
        return dpVal-1;
    int lo = x0, hi = x1;
    int ans = 1e9;
    while (hi - lo > 1) {
        int mid = (lo + hi) / 2;
        int c1 = calc(x0, y0, mid, y1);
        int c2 = calc(mid, y0, x1, y1);
        ans = min(ans, max(c1, c2) + 1);
        if (min(c1, c2)+1 >= ans)
            break;
        if (c1 > c2) {
            hi = mid;
        }
        else {
            lo = mid;
        }
    }
    lo = y0, hi = y1;
    while (hi - lo > 1) {
        int mid = (lo + hi) / 2;
        int c1 = calc(x0, y0, x1, mid);
        int c2 = calc(x0, mid, x1, y1);
        ans = min(ans, max(c1, c2) + 1);
        if (min(c1, c2)+1 >= ans)
            break;
        if (c1 > c2) {
            hi = mid;
        }
        else {
            lo = mid;
        }
    }
    if (ans == 1 && s[x1-1][y1-1] == s[x0][y0]) {
        ans = 0;
    }
    dpVal = ans + 1;
    return ans;
}

int main(){
	ios::sync_with_stdio(0);
    int encodeN = 0;
    rep(i,0,190)
        rep(j,i+1,190)
            encode[i][j] = encodeN++;
    cin >> H >> W;
    s = vector<string>(H);
    rep(i,0,H)
        cin >> s[i];
    int ans = calc(0, 0, H, W);
    cout << ans << endl;
    /*rrep(x0,H+1,0)
    rrep(y0,W+1,0)
    rep(complexity,0,17) {
        int x1 = x0 + 1;
        while (x1 < H && s[x1][y0] == s[x0][y0])
            ++x1;
        dpx[x0][y0][y0+1][0]=x1;
        int y1 = y0 + 1;
        while (y1 < W && s[x0][y1] == s[x0][y0])
            ++y1;
        dpx[x0][y0][x0+1][0]=y1;
        rep(x1,x0+2,H) {
            int y1 = dpy[x0][y0][x1-1][complexity];
            while (true) {
                int xmid = dpx[x0][y0][y1][complexity-1];
                int x1prim = dpx[xmid][y0][y1][complexity-1];
                if (x1prim < x1) {
                    --y1;
                }
            }
            int ymid = dpy[x0][y0][x1][complexity-1];
            int y1 = max(y1, dpy[x0][ymid][x1][complexity-1]);
            dpy[x0][y0][x1][complexity] = y1;
        }
    }*/
    /*rep(x0,0,H)
    rep(x1,x0+1,H+1)
    rep(y0,0,W)
    rep(y1,y0+1,W+1) {

    }*/
}


Measured memory_bytes: 352512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long h,n;
  cin>>h>>n;
 
  long sum=0;
  for(long i=0;i<n;i++)
  {
      long temp;
      cin>>temp;
      sum+=temp;

  }
  if(sum>=h)
  cout<<"Yes"<<endl;
  else
  {
      cout<<"No"<<endl;
  }
  

  
    
}


Measured memory_bytes: 256
#素因数分解
#factorization(2016)=[[2, 5], [3, 2], [7, 1]]の形で出力
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int((n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


n=int(input())
import bisect

p=factorization(n)
anli=[0,2,5,9,14,20,27,35,44,54]
ans=0
for li in p:
  s=li[1]
  ans+=bisect.bisect_left(anli,s)
print(ans if n>1 else 0)

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

int main()
{
    long A, B, K; cin >> A >> B >> K;
    if (A > K) cout << A - K << " " << B << endl;
    else if (A + B >= K) cout << 0 << " " << B - (K - A) << endl;
    else cout << 0 << " " << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
typedef long long  ll;

int a[N], b[N], n;

int main() {
    scanf("%d", &n);
    ll sum = 0;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n-1; i++) {
        if (i % 2) {
            sum = sum + 1LL * a[i];
        } else {
            sum = sum - 1LL * a[i];
        }
    }
    int aa = (sum + 1LL * a[n]) / 2;
    b[1] = aa;
    for (int i = 2; i <= n; i++) {
        b[i] = a[i-1] - b[i-1];
    }
    for (int i = 1; i <= n; i++) {
        printf("%d ", 2 * b[i]);
    }    
    return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>

int main(void) {

  int a, b, c, d, e, k;

  do {
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    scanf("%d", &e);
    scanf("%d", &k);
  } while (a < 0 || a > 123 || b < 0 || b > 123 || c < 0 || c > 123 || d < 0 || d > 123 || e < 0 || e > 123 || k < 0 || k > 123);

  int dist[10] = { b - a, c - a, d - a, e - a, b - c, b - d, b - e, c - d, c - e, d - e};

  int n = 0;
  for (int i = 0; i < 10; i++) {
    if (dist[i] > k) {
      n--;
    }
  }

  if (n < 0) {
    printf(":(\n");
  } else {
    printf("Yay!\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    class BIT{
            ll n;
      		vector<ll> bitree;
        public:
        	BIT(unsigned long _n) : bitree(_n + 1, 0){
              n = _n;
            }
        	void add(ll id, ll x){
              while(id <= n){
                bitree[id] += x;
                id += id & -id;
              }
              return;
            }
        	ll sum(ll id){
              ll temp = 0;
              while(id > 0){
                temp += bitree[id];
                id -= id & -id;
              }
              return temp;
            }
      };
    cin>>N>>S>>Q;
    vector<BIT> num(26, BIT(N));
    rep(i,N){
        int al = S[i] - 'a';
        num[al].add(i + 1, 1);
    }
    rep(i,Q){
        cin>>A;
        if(A == 1){
            char c;
            cin>>B>>c;
            --B;
            if(c != S[B]){
                num[S[B] - 'a'].add(B + 1, -1);
                num[c - 'a'].add(B + 1, 1);
                S[B] = c;
            }
        }else{
            int l, r, res = 0;
            cin>>l>>r;
            rep(j, 26) res += ((num[j].sum(r) - num[j].sum(l - 1)) != 0);
            cout<<res<<endl;
        }
    }
}

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

int main(){
  int n, m, ans[100001], suff[100001];
  string s;
  cin >> n >> m;
  cin >> s;
  suff[n] = n;
  for(int i = n-1 ; i >= 0 ; i--){
    if(s[i] == '0') suff[i] = i;
    else suff[i] = suff[i+1];
  }

  int j = 0;

  for(int i = n ; i > 0 ; i = suff[max(i-m, 0)]){
    if(i == suff[max(i-m, 0)]){
      cout << -1 << endl;
      return 0;
    }
    ans[j++] = i-suff[max(i-m, 0)];
  }
  
  for(int i = j-1 ; i >= 0 ; i--){
    if(i < j-1) cout << " ";
    cout << ans[i];
  }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string w="AKIHABARA";
  for(int mask=0;mask<(1<<9);mask++){
    bool t=true;
    string p="";
    for(int i=0;i<9;i++){
      if(mask &(1<<i)){
        p+=w[i];
      }else{
        t&=w[i]=='A';
      }
    }
    if(!t)continue;
    if(s==p){
      cout << "YES" << endl;
      return 0;
    }
    
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll a, b;
  cin >> a >> b;
  cout << max(a - 2 * b, 0LL) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	scan(N);
	ll ans=0;
	rep1(i,N){
		if(i%3!=0&&i%5!=0) ans+=i;
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 3624
unittest
{
	assert( [ "ABC" ].parse.expand.solve == "ARC" );
	assert( [ "ARC" ].parse.expand.solve == "ABC" );		// 追加ケース
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	return ( s == "ABC" ) ? "ARC" : "ABC";
}


Measured memory_bytes: 2776