akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    vector<int> dp(100010, Inf);
    dp[0] = 0;
    FOR(i, 1, 100010) {
      for (int j = 1; j <= i; j *= 6) {
        dp[i] = min(dp[i], dp[i - j] + 1);
      }
      for (int j = 1; j <= i; j *= 9) {
        dp[i] = min(dp[i], dp[i - j] + 1);
      }
    }
    cout << dp[n] << '\n';

    return 0;
}


Measured memory_bytes: 640
# パスカルの三角形
N, K = map(int, input().split())

n = max(K, N - K + 1)
c = [[0] * (n + 1) for _ in range(n + 1)]
c[0][0] = 1
for i in range(1, n + 1):
    ci = c[i]
    ci1 = c[i - 1]
    ci[0] = 1
    for j in range(1, i + 1):
        ci[j] = (ci1[j - 1] + ci1[j]) % 1000000007

result = []
for i in range(1, K + 1):
    result.append(c[K - 1][i - 1] * c[N - K + 1][i] % 1000000007)
print('\n'.join(str(i) for i in result))


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

bool solve() {
    ll K, X;
    cin >> K >> X;
    return 500*K >= X;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
use std::io;

// https://cp-algorithms.com/algebra/prime-sieve-linear.html
fn linear_sieve(max_to_check: usize) -> (Vec<usize>, Vec<usize>) {
    let n = max_to_check;
    // Assume all numbers are initially prime
    let mut minimum_prime_factor = vec![0; n + 1];
    let mut primes = Vec::new();
    let mut cd = vec![1; n + 1];

    for i in 2..=n {
        if minimum_prime_factor[i] == 0 {
            // i is prime, there are not any smaller prime factors for i
            minimum_prime_factor[i] = i;
            primes.push(i);
        }
        // We iterate over all primes less than the minimum prime factor of i
        for &prime in primes.iter() {
            if i * prime > n || prime > minimum_prime_factor[i] {
                break;
            }
            minimum_prime_factor[i * prime] = prime;
        }
        let mut expo = 0;
        let cur_mpf = minimum_prime_factor[i];
        let mut without_mpf = i;
        while minimum_prime_factor[without_mpf] == cur_mpf {
            without_mpf /= cur_mpf;
            expo += 1;
        }
        cd[i] = (expo + 1) * cd[without_mpf];
    }
    (primes, cd)
}

fn solve(n: usize, cd: &[usize]) -> usize {
    let mut ans = 0;
    for k in 1..=n {
        ans += k * cd[k];
    }
    ans
}

fn main() {
    let mut n = String::new();
    io::stdin()
        .read_line(&mut n)
        .expect("failed to read input.");
    let n: usize = n.trim().parse().expect("invalid input");
    let (_primes, cd) = linear_sieve(n);
    let ans = solve(n, &cd);
    println!("{}", ans);
}

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

using ll = long long;

int main() {
    string s;
    int K;
    cin >> s >> K;
    set<string> st;
    int n = s.size();
    rep(i, n) {
        rep(j, 5) {
            if (i + j == n) break;
            st.insert(s.substr(i, j + 1));
        }
    }
    auto itr = st.begin();
    rep(i, K - 1) itr++;
    cout << *itr << endl;
}

Measured memory_bytes: 1664
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

x = ni()
def sol():
    for i in range(-200, 200):
        for j in range(-200, 200):
            if (i ** 5) - (j ** 5) == x:
                print(i, j)
                return

sol()

Measured memory_bytes: 9256
import collections
import math


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def count_num(n):
    i = 2
    ret = 1
    while True:
        n = n - i
        if n <= 0:
            return ret
        i = i+1
        ret = ret + 1


def main():
    N = int(input())
    list_factorize = prime_factorize(N)
    c = collections.Counter(list_factorize)
    list_key = list(c.keys())
    list_count = list(c.values())
    ans = 0
    for i in range(0, len(list_key)):
        num = list_count[i]
        ans += count_num(num)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9472
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>

using namespace std;
int a,b,c;
int main()
{
  
  cin>>a>>b>>c;
  if(b-a==c-b)cout<<"YES";
  else cout<<"NO";
  
  return 0;
}
/*

*/ 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    printf("%d\n", n*n*n);
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int h,w;
char fld[55][55];

signed main(){
    cin>>h>>w;
    rep(i,h)cin>>fld[i];

    rep(i,h){
        rep(j,w){
            if(fld[i][j]=='#'){
                cout<<'#';
                continue;
            }

            int cnt=0;
            for(int dx=-1;dx<=1;dx++){
                for(int dy=-1;dy<=1;dy++){
                    int ny=i+dy;
                    int nx=j+dx;
                    if(ny<0||ny>=h||nx<0||nx>=w)continue;
                    if(fld[ny][nx]=='#')cnt++;
                }
            }
            cout<<cnt;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
void main(){
	int a, b;
	char op;
	scanf("%d %c %d", &a, &op,&b);
	writeln(op=='+'?a+b:a-b);
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2564
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

H, N=map(int, input().split())
An=sorted(list(map(int, input().split())), reverse=True)
for a in An:
    H -= a

if H <= 0:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 14428
MOD = 10 ** 9 + 7

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    X, Y = ZZ()
    if (X + Y)%3 != 0:
        print(0)
        return

    N = (X + Y)//3
    if abs(X - Y) > N:
        print(0)
        return
        
    fact = [0] * (N + 1) # fact[n] = n!
    ifact = [0] * (N + 1)

    for i in range(N+1):
        if i == 0:
            fact[i] = 1
            continue
        fact[i] = i * fact[i-1]
        fact[i] %= MOD
    ifact[N] = pow(fact[N], MOD-2, MOD)
    for i in range(N)[::-1]:
        ifact[i] = ((i+1) * ifact[i+1])%MOD

    m = (2*X - Y)//3
    n = (-X + 2*Y)//3

    output = fact[m+n] * ifact[m] * ifact[n] % MOD
    print(output)

    return

if __name__ == '__main__':
    main()



Measured memory_bytes: 55796
#include <stdio.h>
#include <string.h>
typedef unsigned int uint;

inline static uint gl(void){
    uint x = 0;
    for(;;){
        const uint c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

#define H 200000
uint v[H] __attribute__((aligned(64)));
int main(void){
    memset(v, 0x33, sizeof(uint)*H);
    {
        const uint h = gl();
        gl();
        const uint n = gl();
        for(uint i=0; i<n; i++){
            const uint x = gl()-1;
            const uint y = gl()-1;
            v[x] = y<v[x] ? y : v[x];
        }
        v[h] = 0;
    }
    {
        uint right = 0;
        uint x = 1;
        for(;;){
            const uint b = v[x];
            const uint r = right+1;
            if(b<r){
                printf("%d\n", x);
                return 0;
            }else if(b>r){
                right=r;
            }
            x++;
        }
    }
}


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

int main(){
    int n,m;
    cin >> n >> m;
    int a[50],b[50],c[50],d[50];
    int ans[50],an,answer;
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
        ans[i]=1000000000;
    }
    for(int i=0;i<m;i++)cin >> c[i] >> d[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            an=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(an<ans[i]){
                answer=j;
                ans[i]=an;
            }
        }
        cout << answer+1 << endl;
    }
}

Measured memory_bytes: 256
//I am so vegetable
//#define _LOCAL_
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define CT count
#define EP empty
#define _for(i,a,b) for(ll i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 2e5 + 5;
const int MOD = 998244353;
const double eps = 1e-6;
const double pi = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(int x, int y) { ll ans = 1; for (; y; y >= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll comb(int n, int m) {
	if(n<m)return 0;
	ll ans = 1;
	if (m > n - m)m = n - m;
	_for(i, n - m + 1, n + 1)ans *= i;
	_for(i, 1, m + 1)ans = ans /i;
	return ans;
}
int main(){
	FIO;
	int n,m,sum=0;
    cin>>n>>m;
    sum=n*(n-1)/2+m*(m-1)/2;
    cout<<sum;
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
xx = []
yy = []
n.times do |i|
    x,y = gets.chomp.split(" ").map(&:to_i)
    xx << x
    yy << y
end

arr = [*1..n]
ans = 0
count = 0
arr.permutation do |ar|
    count += 1
ar.each_cons (2) do |i,j|
    ans += ((xx[j-1] - xx[i-1]) ** 2 + (yy[j-1] - yy[i-1]) ** 2) ** 0.5
end
end
puts ans / count

Measured memory_bytes: 14820
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		long[]S = new long[N];
		long[]T = new long[M];
		string[] str2 = Console.ReadLine().Split();
		string[] str3 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			S[i] = long.Parse(str2[i]);
		}
		for(var i=0;i<M;i++){
			T[i] = long.Parse(str3[i]);
		}
		long mod = 1000000007;
		long[,]D = new long[N+1,M+1];
		for(var i=0;i<N;i++){
			for(var j=0;j<M;j++){
				if(S[i]==T[j]){
					D[i+1,j+1] = (D[i,j+1]+D[i+1,j]+1) % mod;
				} else {
					D[i+1,j+1] = (D[i,j+1]+D[i+1,j]-D[i,j]+mod) % mod;
				}
			}
		}
		Console.WriteLine((D[N,M]+1)%mod);
	}
}

Measured memory_bytes: 42464
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    

  int main(){
 lint n;
 cin>>n;
 lint ans=INF;
 repp(i,1,sqrt(n)+1){
        if(n%i==0)ans=min(ans,i+n/i);
 }
cout<<ans-2;
  }
  
  
     
  

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, M;
  std::string S;
  std::cin >> N >> M >> S;
  std::vector<i64> answers;
  std::reverse(S.begin(), S.end());
  i64 curr = 0;
  while (curr < N) {
    i64 next;
    for (next = std::min(curr + M, N); S[next] == '1'; --next);
    if (next == curr) {
      std::cout << -1 << std::endl;
      return 0;
    }
    answers.push_back(next - curr);
    curr = next;
  }
  std::reverse(answers.begin(), answers.end());
  std::string delimiter = "";
  for (const i64& answer : answers) {
    std::cout << delimiter;
    std::cout << answer;
    delimiter = " ";
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 1528
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		char c;
		String s;
		s = "";// ?????????

		// a~z?????§???????????????????´????????????????
		List<String> list = new ArrayList<String>();
		// a~z?????§???????´?(26??????
		list.add("a");
		list.add("b");
		list.add("c");
		list.add("d");
		list.add("e");
		list.add("f");
		list.add("g");
		list.add("h");
		list.add("i");
		list.add("j");
		list.add("k");
		list.add("l");
		list.add("m");
		list.add("n");
		list.add("o");
		list.add("p");
		list.add("q");
		list.add("r");
		list.add("s");
		list.add("t");
		list.add("u");
		list.add("v");
		list.add("w");
		list.add("x");
		list.add("y");
		list.add("z");

		// ?????°???????´????????????????
		List<Integer> list2 = new ArrayList<Integer>();
		// ?????????0???????´?(26??????
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);
		list2.add(0);

		// ??°???????????????
		do {

			// ??????????????????
			String str = br.readLine();
			//System.out.println(str.length());
			//if (br.ready()) {
			//}else{
			//	break;
			//}

			// ????????°????????????
			for (int count = 0; count < str.length(); count++) {
				c = str.charAt(count);
				// ?????????????°????????????????
				s = String.valueOf(c).toLowerCase();
				// 26?????????????????????
				for (int i = 0; i < 26; i++) {
					// ????????±???????????£?????´??????list2?????°??????+??????
					if (list.get(i).equals(s)) {
						list2.set(i, list2.get(i) + 1);
					}
				}
			}

		}while (br.ready());
		
		// ??¨?????????
		for (int count2 = 0; count2 < 26; count2++) {
			sb.append(list.get(count2));
			sb.append(" : ");
			sb.append(list2.get(count2));
			sb.append("\n");
		}
		
		// ????????????????????????
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(new String(sb));

	}
}

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

using namespace std;

#define int long long

template <typename T> T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T> T lcm(T m, T n) { return n * m / gcd(n, m); }
template <typename T> T fact(T n) { return (n == 0 ? 1 : n * fact(n - 1)); }
template <typename T> T modpow(T a, T e, T m) { return (e == (T)0 ? 1 : ((a % m) * modpow((a % m), e - 1, m)) % m); }

constexpr int MOD = 1e9 + 7;

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

  vector<pair<int, int>> p(n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    p[i] = make_pair(x, y);
  }

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

  double dist = 0;
  do {
    for (int i = 1; i < n; ++i) {
      double d = (p[i - 1].first - p[i].first) * (p[i - 1].first - p[i].first) +
                 (p[i - 1].second - p[i].second) * (p[i - 1].second - p[i].second);
      dist += sqrt(d);
    }
  } while (next_permutation(p.begin(), p.end()));

  dist /= (double)(fact(n));

  cout << setprecision(10) << dist << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

ll h, w;
char s[60][60];

ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};
bool solve(ll x, ll y){
    for(ll i=0;i<4;++i){
        ll nx = x + dx[i];
        ll ny = y + dy[i];
        if(nx < 0 or nx >= h or ny < 0 or ny >= w){
            continue;
        }
        if(s[nx][ny] == '#'){
            return true;
        }
    }
    return false;
}

int main(){
    cin>>h>>w;
    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            cin>>s[i][j];
        }
    }

    string ans = "Yes";
    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            if(s[i][j] == '#'){
                if(solve(i, j)){
                    continue;
                }else{
                    ans = "No";
                    break;
                }
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
gets
ds = gets.split.map(&:to_i).each_with_object(Hash.new(0)) do |c, h|
  h[c] += 1
end

gets
ts = gets.split.map(&:to_i).each_with_object(Hash.new(0)) do |t, h|
  h[t] += 1
end

ans = "YES"

ts.keys.each do |t|
  next if ts[t] <= ds[t]

  ans = "NO"
  break
end

puts ans


Measured memory_bytes: 56568
import sys
sys.setrecursionlimit(200000) #追加
def opt_S(S,h,n):
    if(n == 0):return 0
    elif(n == 1):return abs(h[1]-h[0])
    else :
        if(S[n] != -1):return S[n]
        s1 = opt_S(S,h,n-1) + abs(h[n-1]-h[n])
        s2 = opt_S(S,h,n-2) + abs(h[n-2]-h[n])
        S[n] = min(s1,s2)
        return S[n]
 
 
S = [-1]*(101010)
N = int(input())
h = list(map(int,input().split()))
print(opt_S(S,h,N-1))

Measured memory_bytes: 93708
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CCountOrder solver = new CCountOrder();
        solver.solve(1, in, out);
        out.close();
    }

    static class CCountOrder {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            Integer[] p = new Integer[n];
            Integer[] a = new Integer[n];
            Integer[] b = new Integer[n];
            for (int i = 0; i < n; i++) p[i] = i + 1;
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            for (int i = 0; i < n; i++) b[i] = in.nextInt();

            NextPermutation<Integer> np = new NextPermutation<>();
            int ca = 0;
            int cb = 0;
            int cnt = 0;
            while (true) {
                if (Arrays.equals(p, a)) ca = cnt;
                if (Arrays.equals(p, b)) cb = cnt;
                cnt++;
                if (np.nextPermutation(p) == null) break;
            }

            out.println(Math.abs(ca - cb));
        }

    }

    static class NextPermutation<T extends Comparable<T>> {
        public T[] nextPermutation(T[] array) {
            int k = -1;
            int i = array.length - 2;
            while (i >= 0) {
                if (array[i].compareTo(array[i + 1]) < 0) {
                    k = i;
                    break;
                }
                i--;
            }

            // 存在しない場合nullを返す
            if (k == -1) return null;
            int l = k + 1;
            i = array.length - 1;
            while (i > k + 1) {
                if (array[k].compareTo(array[i]) < 0) {
                    l = i;
                    break;
                }
                i--;
            }

            T tmp = array[k];
            array[k] = array[l];
            array[l] = tmp;
            int[] res = new int[array.length];
            // k+1 <-> n-1
            for (int j = k + 1; j < array.length + k - j; j++) {
                tmp = array[j];
                array[j] = array[array.length + k - j];
                array[array.length + k - j] = tmp;
            }
            return array;
        }

    }
}



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

using namespace std;

void solve(){
    int n; cin >> n;
    int counter = 0;
    for(int i = 1; i <= n; i++){
        if(i%2 != 0) counter++;
    }
    printf("%lf", (double)counter/(double)n);
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;
signed main(){
  int n,maxw;
  cin >> n >> maxw;
  vint ZERO(0);
  vint ONE(0);
  vint TWO(0);
  vint THREE(0);
  int w,v;
  cin >> w >> v;
  ZERO.push_back(v);
  rep(i,n-1){
    int ww,vv;
    cin >> ww >> vv;
    if(ww - w == 0) ZERO.push_back(vv);
    if(ww - w == 1) ONE.push_back(vv);
    if(ww - w == 2) TWO.push_back(vv);
    if(ww - w == 3) THREE.push_back(vv);
  }
  sort(ZERO.begin(),ZERO.end());
  reverse(ZERO.begin(),ZERO.end());
  sort(ONE.begin(),ONE.end());
  reverse(ONE.begin(),ONE.end());
  sort(TWO.begin(),TWO.end());
  reverse(TWO.begin(),TWO.end());
  sort(THREE.begin(),THREE.end());
  reverse(THREE.begin(),THREE.end());
  int ans = 0;
  erep(i,ZERO.size()) erep(j,ONE.size()) erep(s,TWO.size()) erep(t,THREE.size()){
    if(w*i + (w + 1)*j + (w + 2)*s + (w + 3)*t <= maxw){
      //cout << i << " " << j << " " << s << ' ' << t << " " << endl;
      int temp = 0;
      rep(ii,i){
        temp += ZERO[ii];
      }
      rep(jj,j){
        temp += ONE[jj];
      }
      rep(ss,s){
        temp += TWO[ss];
      }
      rep(tt,t){
        temp += THREE[tt];
      }
      ans = max(ans,temp);
    }
  }
  cout << ans << endl;
}

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

int main(void)
{
	int sq[15][15];
	int size;
	int i, x, y;
	
	while (1){
		scanf("%d", &size);
		
		if (size == 0){
			break;
		}
		
		memset(sq, 0, sizeof(sq));
		
		x = size / 2;
		y = x + 1;
		
		for (i = 1; i <= size * size; i++){
			sq[y][x] = i;
			x++;
			y++;
			
			if (y == size){
				y = 0;
			}
			if (x == size){
				x = 0;
			}
			
			if (sq[y][x] != 0){
				y++;
				x--;
				if (y == size){
					y = 0;
				}
				if (x == -1){
					x = size - 1;
				}
			}
		}
		
		for (x = 0; x < size; x++){
			for (y = 0; y < size; y++){
				printf("%4d", sq[x][y]);
			}
			printf("\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<stdio.h>

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

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

const int NN = 111, WW = 1111;
const int INF = 1e8;
int N, W;
int w[NN], v[NN];
int dp[NN][NN*WW];

int dfs(int idx, int wSum) {
   if (idx == N) {
      return 0;
   } 
   if (wSum + w[idx] > W) {
      return dfs(idx+1, wSum);
   } 
   if (dp[idx][wSum] != -1) {
      return dp[idx][wSum];
   }
   return dp[idx][wSum] = max(dfs(idx+1, wSum + w[idx]) + v[idx], dfs(idx+1, wSum));
}

int main() {
   cin >> N >> W;
   rep (i, N) {
      cin >> v[i] >> w[i];
   }
   rep (i, NN) {
      rep (j, NN*WW) {
         dp[i][j] = -1;
      }
   }
   cout << dfs(0, 0) << endl;

   return 0;
}


Measured memory_bytes: 56584
#!/usr/bin/env python3

N, T = map(int, input().split())

ans = 10**9
for i in range(N):
    c, t = map(int, input().split())
    if t <= T and ans > c:
        ans = c

if ans == 10**9:
    print('TLE')
else:
    print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
  
#define mp make_pair
#define s second 
#define f first
#define ll long long
#define pb push_back
  
using namespace std;
/*
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  */
const int inf = 2e9+7, mod=1e9+7;
const int N = 2e6;

int ans=0;

int used[N], d[N];
 
int xx[8]={1, 1, -1, -1, 2, 2, -2, -2};
int yy[8]={2, -2, 2, -2, 1, -1, 1, -1};

vector <int> g1[N], g2[N];

ll a[1200][1200];
int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
		 char c;
		 cin >> c;
		 if(c=='#')
		 	a[i][j]=-1;
		}
	}
	a[1][1]=1;
	for(int i=1; i<=n; i++){
		
		for(int j=1; j<=m; j++){
			a[i][j]%=mod;
			if(a[i][j+1]!=-1 && a[i][j]>0)
				a[i][j+1]+=a[i][j];
			if(a[i+1][j]!=-1 && a[i][j]>0)
				a[i+1][j]+=a[i][j];
//			cout << a[i][j]<< " " ;
		}
//		cout << endl;
	}
	cout << a[n][m];
	return 0;
}



Measured memory_bytes: 106752
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#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 gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int h, w;
  cin >> h >> w;
  rep(i,h)rep(j,w) {
    string s;
    cin >> s;
    if (s == "snuke") {
      printf("%c%d\n", 'A'+j, i+1);
    }
  }
  return 0;
}







Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
map<string,int>dp;
inline string operator &(const string &a,const string &b){
	R int n=a.length();string c(n,'0');
	fp(i,0,n-1)c[i]=(a[i]=='1'&&b[i]=='1'?'1':'0');
	return c;
}
int dfs(string s){
	if(s.empty())return 1;
	if(dp.count(s))return dp[s];
	if(s.length()==1)return s[0]-'0'+1;
	R int res=mul(s[0]=='1'?2:1,dfs(s.substr(1)));
	R int n=s.length();
	fp(d,1,n){
		string t=s.substr(0,d);
		for(R int k=d;k<=n-d;k+=d){
			t=t&s.substr(k,d);
			upd(res,mul(dfs(t),dfs(s.substr(k+d))));
		}
	}
	return dp[s]=res;
}
int main(){
	string s;cin>>s;
	printf("%d\n",dfs(s));
	return 0;
}

Measured memory_bytes: 5632
# coding: utf8
# 日本語を入力できるようにするために上記一文が必要

a,b,c,d = map( int , input().split())

num_list = [a*c,a*d,b*c,b*d]

ans = num_list[0]
for i in num_list:
        if ans < i:
                ans = i

print(ans)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
#define right sefudermano
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int32_t main(){
  fastio;
  string s,t;
  cin>>s>>t;
  int n = s.size();
  int res=0;
  for(int i=0;i<n;i++){
    if(s[i]!=t[i])res++;
  }
  cout << res << endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
} 

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

int main(){

	int n,k;
	cin >> n >> k;

	vector<int> a(n);
	int mm = INT_MAX;
	for(int i=0;i<n;i++){
		cin >> a[i];
		mm = min(mm , a[i]);
	}

	vector< int > dp(k+10);
	for(int i=0;i<mm;i++){
		dp[i]=1;
	}
	// for(int i=0;i<=k;i++){
	// 	cout << dp[i] << " ";
	// }
	// cout << "\n";
	sort(a.begin(),a.end());

	for(int i=mm;i<=k;i++){
		dp[i]=1;
		for(int j=0;j<n;j++){
			if(i-a[j]>=0){
				if(dp[i-a[j]]==1){
					dp[i]=0;
					break;
				}
			}else{
				break;
			}
		}
	}

	// for(int i=0;i<=k;i++){
	// 	cout << dp[i] << " ";
	// }
	// cout  << "\n";

	if(dp[k]==1){
		cout << "Second" << "\n";
	}else{
		cout << "First" << "\n";
	}


	return 0;
}

Measured memory_bytes: 640
import java.util.*;

class Main{
    public static void main(String[] args){
	Scanner s = new Scanner(System.in);
	int k,a,b,c;
	
	k = s.nextInt();
	
	for(int i=0;i<k;i++){
	    a=s.nextInt();
	    b=s.nextInt();
	    c=s.nextInt();
	    
	    if(b>a&&b>c){
		int swap = b;
		b=c;
		c=swap;
	    }else if(a>b&&a>c){
		int swap = a;
		a=c;
		c=swap;
	    }
	    
	    if((c*c)==(a*a+b*b)){
		System.out.println("YES");
	    }
	    else{
		System.out.println("NO");
	    }
	    
	}
    }
}

Measured memory_bytes: 23356
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
using namespace std;
int main()
{
    ll a,b,i,ans=0;
    cin>>a>>b;
    b=2*b;
    ans=(a-b>0)?a-b:0;
    cout<<ans<<endl;

    return 0;
}





Measured memory_bytes: 3608
#include <stdio.h>
int main(void){
	int a,b,c,temp;
	scanf("%d %d %d",&a,&b,&c);
	if(a > b){
		temp=a;
		a=b;
		b=temp;
	}
	if(b > c){
		temp=b;
		b=c;
		c=temp;
	}
	if(a > b){
		temp=a;
		a=b;
		b=temp;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
/**#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	double a, b;
	std::cin >> a >> b;
	if (a == b) {
		std::cout << "AB" << std::endl;
	}
	else if (a < b) {
		std::cout << 'B' << std::endl;
	}
	else {
		std::cout << 'A' << std::endl;
	}
 	return 0;
}
int main() {
	int a, b;
	std::cin >> a >> b;
	std::vector<int>A(b, a);
	for (int i = 0;i < b;i++) {
		for (int j = 0;j < a;j++) {
			std::cin >> A[i, j];
		}
	}
	for (int i = b;i > 0;i--) {
		for (int j = a;j > 0;j--) {
			std::cout << A[i, j] << std::endl;
		}
	}
 	return 0;
}*/
int main() {
	int n;
	int sum = 0;
	std::cin >> n;
	std::vector<int>l(n);
	std::vector<int>r(n);
	for (int i = 0;i < n;++i) {
		std::cin >> l[i] >> r[i];
		sum += r[i] - l[i] + 1;
	}
	std::cout << sum << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <cctype>
#include <cstring>
#include <string>
#include <numeric>
#include <functional>
#include <iomanip>
#include <ctime>

using namespace std;

typedef long long LL;
typedef unsigned long long uLL;

struct NODE
{
    double x,y,z;
}nd[22];
int n,m;
double res;
double dis[22][22];
int pik[22];
int len;
void DFS(int u,int last)
{
    if(u==m)
    {
        double sum=0;
        for(int i=0;i<u;i++)
        {
            int x=pik[i];
            for(int j=i+1;j<u;j++)
            {
                int y=pik[j];
                sum+=dis[x][y];
            }
        }
        if(res<sum)res=sum;
        return ;
    }
    for(int i=last;i<n;i++)
    {
        pik[u]=i;
        DFS(u+1,i+1);
    }
}

int main()
{
	while(~scanf("%d%d",&n,&m))
	{
	    for(int i=0;i<n;i++)
	    {
	        scanf("%lf%lf%lf",&nd[i].x,&nd[i].y,&nd[i].z);
	    }
	    for(int i=0;i<n;i++)
	    {
	        for(int j=0;j<n;j++)
	        {
	            dis[i][j]=(nd[i].x-nd[j].x)*(nd[i].x-nd[j].x)+(nd[i].y-nd[j].y)*(nd[i].y-nd[j].y)+(nd[i].z-nd[j].z)*(nd[i].z-nd[j].z);
	        }
	    }
	    res=0;
	    DFS(0,0);
	    printf("%.10lf\n",res);
	}
	return 0;
}

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

int main(void){
    
    int n;
    ll ans=0;
    
    cin >> n;
    
    for(int i=1; i<=n; i++){
        
        if(i%3!=0&&i%5!=0){
            
            ans += i;
            
        }
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    map<ll,int> n1, n2;
    for ( int i = 1; i < N; i++ ) {
        n2[A[i]]++;
    }

    // mind[k]:kの最小の素因数(k>=2)
    auto PrimeFactorTable = [](ll n) {
        vector<ll> pr;
        vector<ll> mind(n+1);
        mind[0] = mind[1] = 1;
        for ( ll k = 2; k <= n; k++ ) {
            if ( mind[k] == 0 ) {
                pr.push_back(k);
                mind[k] = k;
            }
            for ( ll j = 0; j < pr.size() && pr[j]<=mind[k] && k*pr[j]<=n; j++ ) {
                mind[k*pr[j]] = pr[j];
            }
        }
        return mind;
    };
    ll NM = 1e6;
    vector<ll> mind = PrimeFactorTable(NM);

    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        map<ll, int> fsc;
        ll a = A[i];
        while ( a > 1 ) {
            fsc[mind[a]]++;
            a /= mind[a];
        }
        vector<ll> fs, fst;
        fs.push_back(1);
        for ( auto p : fsc ) {
            swap(fst,fs);
            ll y = 1;
            fs.clear();
            for ( ll k = 0; k <= p.second; k++ ) {
                for ( ll f : fst ) {
                    fs.push_back(f*y);
                }
                y *= p.first;
            }
        }
        bool ok = true;
        for ( ll f : fs ) {
            if ( n1.count(f) > 0 || n2.count(f) > 0 ) {
                ok = false;
                break;
            }
        }
        if ( ok ) ans++;
        if ( i < N-1 ) {
            n1[A[i]]++;
            n2[A[i+1]]--;
            if ( n2[A[i+1]] == 0 ) n2.erase(A[i+1]);
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 26096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main(){
    int n;  cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a.at(i);
    
    ll ans=0;
    FORD(i, n-1, 1){
        ans += a[i]/2;
        a[i] %= 2; 
        ll x = min(a[i], a[i-1]);
        ans += x;
        a[i-1] -= x;
        
        //cout << ans << ' ' << a[i-1] << ' ' << a[i] << endl;
    }
    cout << ans+a[0]/2 << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
  for (int i = g; i < n; ++i) {
    int v = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > v) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n) {
  for (int h = 1; h <= n; h = 3*h + 1)
    G.push_back(h);
  for (int i = G.size() - 1; i >= 0; --i)
    insertionSort(A, n, G[i]);
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &A[i]);
  cnt = 0;
  
  shellSort(A, n);
  
  printf("%ld\n", G.size());
  for (int i = G.size() - 1; i > 0; --i)
    printf("%d ", G[i]);
  printf("%d\n", G[0]);
  printf("%lld\n", cnt);
  for (int i = 0; i < n; ++i)
    printf("%d\n", A[i]);
    
  return 0;
}

Measured memory_bytes: 6532
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N,M;cin>>N>>M;
  vector<P> a(N);

  if(N %2 == 1){
    ll tmp = (N - 1) / 2;
    rep(i,M){
      a[i].first = tmp - i;
      a[i].second = tmp + i + 1;
    }

  }
  else{
    ll tmp = (N + 1) / 2;
    for(ll i = 0; i < (M + 1) / 2; i++){
      a[i].first = tmp - i - 1;
      a[i].second = tmp + i;
    }
    for(ll i = (M + 1) / 2; i < N; i++){
      a[i].first = tmp - i - 1;
      a[i].second = tmp + i + 1;
    }
  }

  rep(i,M){
    cout << a[i].first <<" " << a[i].second << endl;
  }

}


Measured memory_bytes: 5996
#include <bits/stdc++.h>
#define INF 2000000001
#define MAX 502
using namespace std;

int main()
{
	int H;
	int heap[MAX];
	cin >> H;
	for (int i = 0; i < MAX; i++) {
		if (i >= 1 && i <= H)
			cin >> heap[i];
		else
			heap[i] = INF;
	}
	for (int i = 1; i <= H; i++) {
		cout << "node " << i << ": ";
		cout << "key = " << heap[i] << ", ";
		if (heap[i / 2] != INF)
			cout << "parent key = " << heap[i / 2] << ", ";
		if (heap[i * 2] != INF)
			cout << "left key = " << heap[i * 2] << ", ";
		if (heap[i * 2 + 1] != INF)
			cout << "right key = " << heap[i * 2 + 1] << ", ";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main() {
	string s, t; cin >> s >> t;
	int count = 0;
	string ans;
	for(int i=0;i<s.size();i++){
		ans[i] = s[i];
	}
	if(t.size()>s.size()){
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	for(int i=s.size()-t.size();i>=0;i--){
		for(int j=0;j<t.size();j++){
			if(s[i+j]==t[j] || s[i+j]=='?'){
				count++;
				ans[i+j] = t[j];
			}		
		}
		if(count==t.size()){
			break;
		}else{
			count = 0;
			ans = s;
		}
	}
	if(count!=t.size()){
		cout << "UNRESTORABLE" << endl;
	}else{
		for(int i=0;i<s.size();i++){
			if(ans[i]=='?'){
				ans[i] = 'a';
			}
			cout << ans[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256