akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int, int> pii;

template <typename A, typename B>
string to_string(pair<A, B> p){
    return "(" + to_string(p.fi) + ", " + to_string(p.se) + ")";
}

template <typename T>
string to_string(T v){
    string s = "{";
    bool first = true;
    for(const auto & x : v){
        if(!first) s += ", ";
        first = false;
        s += to_string(x);
    }
    return s + "}";
}

void debug_out(){ cerr << endl;}
template <typename First, typename... Next>
void debug_out(First F, Next... N){
    cerr << " " << to_string(F);
    debug_out(N...);
}

#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1
#endif

bool pal(string& s, int i, int j){
    for(int k = i, kk = j; k < kk; k++, kk--) if(s[k] != s[kk]) return false;
    return true;
}

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

    int n = s.size();
    int mid = n/2;
    // 0 1 2 3 4
    // mid = 2

    if(pal(s, 0, n-1) and pal(s, 0, mid-1) and pal(s, mid+1, n-1)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
K, N = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i).sort

max_d = 0
0.upto(N-2).each do |i|
  d = A[i+1] - A[i]
  max_d = d if d > max_d
end

d = [A[0] + K - A[-1], A[-1] - A[0]].min
max_d = d if d > max_d

puts K - max_d


Measured memory_bytes: 19824
fn find(n : i32, s : i32) -> Option<(i32, i32, i32)> {
    for n10 in (0..).take_while(|x| x * 10000 <= s) {
        for n5 in (0..).take_while(|x| x * 5000 + n10 * 10000 <= s) {
            let n1 = (s - n10 * 10000 - n5 * 5000) / 1000;
            if n1 + n5 + n10 == n {
                return Some((n10, n5, n1))
            }
        }
    }
    None
}
fn main() {
    let (n, s): (i32, i32) = readln();
    match find(n, s) {
        Some((a, b, c)) => println!("{} {} {}", a, b, c),
        None => println!("-1 -1 -1"),
    }
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashSet;

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n { vs.push(readln()); }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
impl<T> FromLn for Vec<T> where T: FromLn {
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4476
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#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>

#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>

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define T int t = 0; cin >> t; while(t--)
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 998244353;
const ll mx = 6e5;

void input(){
    IOS;
    int n;
    cin >> n;
    set<string>st;
    while(n--){
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << (int)st.size() << endl;

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


Measured memory_bytes: 19288
#include <iomanip>
#include <iostream>

using namespace std;
// clang-format off
using i64 = int64_t;
using i32 = int32_t;
#define all(x) x.begin(), x.end()
// #define int i64
template <class T, typename U> constexpr inline bool exist(const T &s, const U &e) { return s.find(e) != s.end(); }
template <class T> constexpr inline i32 SZ(const T &x) { return x.size(); }
template <class T> constexpr inline bool rmn(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> constexpr inline bool rmx(T &a, T b) { return a < b ? (a = b, true) : false; }
const char el = '\n'; const i32 MOD = 1e9 + 7, INF = 0x3f3f3f3f; const i64 INFLL = ((i64)INF << 32) | INF;

#ifdef LOCAL // debugging swiss knife
template <typename Ostream, typename Cont> enable_if_t<is_same<Ostream, ostream>::value, Ostream &> operator<<(Ostream &os, const Cont &v) { os << "{"; for (const auto &x : v) os << x << ", "; return os << "}"; }
template <typename Ostream, typename... Ts> Ostream &operator<<(Ostream &os, const pair<Ts...> &p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class... Args> void dbg_out(Args... args) { ((std::cerr << "\033[32m" << args << "\033[37m, "), ...); }
#define dbg(...) cerr << "\033[1;31m" << __LINE__ << ": [" << #__VA_ARGS__ << "]\033[37m  = ", dbg_out(__VA_ARGS__), cerr << "\033[0m" << endl;
#else
#define dbg(...) ;
#endif
// clang-format on
////////////////////////////////// TEMPLATE ENDS /////////////////////////////////
// Original author: Burunduk1; Optimizations by madhur4127
// Works only on Linux based systems. NOT on CodeForces.
// See FastIO.hpp for usage
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
static struct input {
    struct stat ip_stat;
    char *ptr;
    int pos, len;
    input() {
        fstat(0, &ip_stat);
        pos = 0, len = ip_stat.st_size, ptr = (char *)mmap(NULL, len, PROT_READ, MAP_PRIVATE, 0, 0);
    }
} ip;
char getChar() {
    // assert(ip.pos < ip.len);
    return ip.ptr[ip.pos++];
}
template <typename T = int> inline T read() {
    char s = 1, c = read<char>();
    T x = 0;
    if (c == '-') s = -1, c = getChar();
    while ('0' <= c && c <= '9')
        x = x * 10 + c - '0', c = getChar();
    return s == 1 ? x : -x;
}
template <> inline char read<char>() {
    char c = getChar();
    while (c <= 32)
        c = getChar();
    return c;
}

int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(13), cerr << fixed << setprecision(3);

    i64 n = read();
    i64 ans = n * (n + 1) / 2;
    for (i64 i = 1; i < n; ++i) {
        ans += i * (i + 1) / 2;
        i64 l = read(), r = read();
        if (l > r) swap(l, r);
        ans -= l * (n + 1 - r);
    }
    cout << ans << el;

    return 0;
}

#undef int

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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")

bool huga(int n){
	int nn = 0, g = 0, s = 0;
	while(n){
		if(n%10 == 7)nn++;
		else if(n%10 == 5)g++;
		else if(n%10 == 3)s++;
		else return false;
		n/= 10;
	}
	return nn&&g&&s;
}

int fuga(int n){
	if(n == 0) return 3;
	if(n%10 == 3) return (n/10)*10+5;
	if(n%10 == 5) return (n/10)*10+7;
	return fuga(n/10)*10+3;
}

signed main(){
	cout<<fixed<<setprecision(7);
	
	int n, count = 0;
	
	cin>>n;
	
	for(int i = 0; i <= n;){//cout<<i<<endl;
		if(huga(i))count++;
		 i = fuga(i);
	}
	
	cout<<count<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
class Paper:
    def __init__(self, x, y):
        
        self.A = [[0 for i in range(x)] for j in range(y)]
        self.size = (x, y)
    def drop(self, x, y, s):
        if s == 1:
            if y+1 <= self.size[1]-1:
                self.A[y+1][x] += 1            
            for i in range(max(0, x-1) , 1 + min(self.size[0]-1, x+1)):
                self.A[y][i] += 1
            if y-1 >= 0:
                self.A[y-1][x] += 1

        if s == 2:
            if y+1 <= self.size[1]-1:
                for i in range(max(0, x-1) , 1 + min(self.size[0]-1, x+1)):
                    self.A[y+1][i] += 1
            for i in range(max(0, x-1) , 1 + min(self.size[0]-1, x+1)):
                self.A[y][i] += 1
            if y-1 >= 0:
                for i in range(max(0, x-1) , 1 + min(self.size[0]-1, x+1)):
                    self.A[y-1][i] += 1

        if s == 3:
            if y+2 <= self.size[1]-1:
                self.A[y+2][x] += 1
            if y+1 <= self.size[1]-1:
                for i in range(max(0, x-1) , 1 + min(self.size[0]-1, x+1)):
                    self.A[y+1][i] += 1
            for i in range(max(0, x-2) , 1 + min(self.size[0]-1, x+2)):
                self.A[y][i] += 1
            if y-1 >= 0:
                for i in range(max(0, x-1) , 1 + min(self.size[0]-1, x+1)):
                    self.A[y-1][i] += 1
            if y-2 >= 0:
                self.A[y-2][x] += 1

if __name__ == "__main__":
    import sys 
    p = Paper(10, 10)
    L = sys.stdin.readlines()
    for l in L:
        x, y, s = map(int, l.split(','))
        p.drop(x, y, s)
#        for i in range(10):
#            print(p.A[i])
#        print()
    temp = []
    for y in p.A:
        temp.extend(y)

    A1 = temp.count(0)
    A2 = max(temp)

    print(A1)
    print(A2)
        
            
    
    

Measured memory_bytes: 7896
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
  int N,C[20],V[20],S=0;
  
  scanf("%d",&N);
  for(int i=1;i<=N;i++){
    scanf("%d",&C[i]);
  }
  for(int i=1;i<=N;i++){
    scanf("%d",&V[i]);
  }
  
  for(int i=1;i <= N;i++){
      if(C[i]-V[i] <= 0){
          S+=0;
      }else{
          S+=C[i]-V[i];
      }
  }
  
  printf("%d",S);
  
  
   return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

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

    int current = 1;
    REP(i, n)
        current = min(current * 2, current + k);

    cout << current << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

mod = 10**9 + 7

def solve():
    m, n = map(int, input().split())

    ans = modpow(m, n, mod)

    print(ans)

def modpow(x, y, mod):
    return ((modpow(x, y >> 1, mod)**2 % mod) * x**(y & 1)) % mod if y else 1

if __name__ == '__main__':
    solve()

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

int main(void) {
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 != 0) {
    cout << "No" << '\n';
    return 0;
  }
  string st, ts;
  rep(i, n / 2) {
    st += s[i];
    ts += s[n / 2 + i];
  }
  cout << (st == ts ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int N = 50;
const long double EPS = 1e-9;

using namespace std;

template <class T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

	int n, ans;
	cin >> n;
	ans = 0;
	for (int a = 1; a <= n; ++a) {
		for (int b = 1; b <= n; ++b) {
			for (int c = 1; c <= n; ++c) {
				ans += gcd(gcd(a, b), c);
			}
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3600
a,b,c,d = map(int,input().split())

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

def wari(n,x,y):
    return n- ( (n//x)+(n//y)-(n//(lcm(x,y))) )

#print(wari(b,c,d))
#print(wari(a-1,c,d))

print(wari(b,c,d)-wari(a-1,c,d))


Measured memory_bytes: 38384
#! c:/Python27/python.exe
# coding: UTF-8

def plusNum(x, y):
    x += y
    return x

n = input()
while(n):
    sumA = 0
    sumB = 0
    for i in range(n):
        A, B = map(int,raw_input().split())
        judgeAB = A - B
        if judgeAB > 0:
            sumA = plusNum(sumA, A+B)
        elif judgeAB < 0:
            sumB = plusNum(sumB, A+B)
        else:
            sumA = plusNum(sumA, A)
            sumB = plusNum(sumB, B)
    print "%d %d" % (sumA, sumB)
    n = input()

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

long long dp[310][310][310] = {};

void solve(long long N, long long K, std::vector<long long> H) {


    for (int i = 0; i < 310; i++) {
        for (int j = 0; j < 310; j++) {
            for (int k = 0; k < 310; k++) {
                dp[i][j][k] = 1e18;
            }

        }
    }



    H.insert(H.begin(), 0);

    dp[1][0][0] = 0;
    for (int i = 1; i < H.size(); i++) {
        for (int j = 0; j < i; j++) {
            for (int k = 0; k < i; k++) {
                // 使う
                dp[i + 1][i][k + 1] = min(dp[i + 1][i][k + 1], dp[i][j][k] + max(0ll, H[i] - H[j]));
                //使わない
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);

            }
        }
    }
    long long ans = 1e18;
    for (int i = N - K; i <= N; i++) {
        for (int j = 0; j < H.size(); j++) {
            ans = min(ans, dp[H.size()][j][i]);
        }
    }
    cout << ans << endl;

}

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> H(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &H[i]);
    }
    solve(N, K, std::move(H));
    return 0;
}


Measured memory_bytes: 232960
import java.math.BigInteger;
import java.util.Scanner;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=0;i<n;i++){
			BigInteger value = sc.nextBigInteger();
			BigInteger value_2 = sc.nextBigInteger();

			String s = ""+value.add(value_2);
			if(s.length() > 80){
				System.out.println("overflow");
			}else{
				System.out.println(s);
			}
		}
	}
}

Measured memory_bytes: 18556
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
a.sort! {|m, n| n <=> m }

alice = 0
bob = 0
n.times do |i|
  if i%2==0
    alice += a[i]
  else
    bob += a[i]
  end
end
puts alice - bob

Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int main() {
    int ans[3] = {};
    while (1) {
        int a[3];
        cin>>a[0]>>a[1]>>a[2];
        sort(a,a+3);
        if(a[0]+a[1]<=a[2]) break;
        if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2])ans[0]++;
        if(a[0]*a[0]+a[1]*a[1]>a[2]*a[2])ans[1]++;
        if(a[0]*a[0]+a[1]*a[1]<a[2]*a[2])ans[2]++;
    }
    cout<<ans[0]+ans[1]+ans[2];
    for(int i=0; i<3; i++) cout<<" "<<ans[i];
    cout<<endl;
}

Measured memory_bytes: 1176
import numpy as np
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split())) for _ in range(N)]
ans=0
for i in range(N):
    if sum(np.array(A[i])*np.array(B))+C>0:
        ans+=1
print(ans)

Measured memory_bytes: 12496
S = input()

if S[0] == "R" and S[0] == S[1] == S[2]:
    print(3)
elif S[0] == "R" and S[0] == S[1]:
    print(2)
elif S[1] == "R" and S[1] == S[2]:
    print(2)
elif S.count("R") > 0:
    print(1)
else:
    print(0)


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

using namespace std; 



int main()
{
	int a;
	int m = 0;
	int max = 0;

	cin >> a ;
	
	for (int i = 2; i < a - 1; i++)
	{
		for (int j = 2; m <= a; j++)
		{
			if (j == 2) m = i;
			m *= i;
			
			
			if (m > a)break;
			if (m > max) max = m;
		}
		m = 0;
		
		
	}
	if (a == 1) max = 1;
	cout << max << endl;
}


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

using namespace std;

const int maxn = 100003;

int number[maxn];
bool redball[maxn];

int main() {
    int N, M, x, y;
    cin >> N >> M;
    for (int i = 1; i <= N; i++) {
        number[i] = 1;
        redball[i] = 0;
    }
    redball[1] = 1;
    for (int i = 1; i <= M; i++) {
        cin >> x >> y;
        if (redball[x]) {
            redball[y] = 1;
        }
        number[x] -= 1;
        number[y] += 1;
        if (number[x] == 0) {
            redball[x] = 0;
        }
    }
    int sum = 0;
    for (int i = 1; i <= N; i++) {
        if (redball[i] == true) {
            sum += 1;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main(void)
{
	int i,n,x,y;
	cin>>n;
	for(i=1;i<=n;i++){
		y=0;
		if(i%3==0){
			y=1;
		}
		x=i;
		while(0<x){
			if(x%10==3){
				y=1;
			}
			x=x/10;
		}
		if(y==1){
			cout<<" "<<i;
		}
	}
	cout<<endl;
	return 0;
}


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

using namespace std;
#define ll long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

const ll MOD = 1e9 + 7;

ll fact[100100];
ll facti[100100];

ll comb(int a, int b)
{
	if (b < 0 || b > a) return 0;
	return (((fact[a] * facti[b]) % MOD) * facti[a-b]) % MOD;
}

ll mypowdfs(ll a, ll b, ll next)
{
	if (b == 0) return 1;
	if (b & 1) return ((next % MOD) * mypowdfs(a, b >> 1, (next*next) % MOD)) % MOD;
	return mypowdfs(a, b >> 1, (next*next) % MOD);
}

ll mypow(ll a, ll b)
{
	return mypowdfs(a, b, a);
}

void init()
{
	fact[0] = facti[0] = 1;
	reps(i, 1, 100100) {
		fact[i] = (fact[i-1] * i) % MOD;
		facti[i] = mypow(fact[i], 1e9+5) % MOD;
	}
}

bool num[100001];
int a[100002];
int r, l, numi;

int main()
{
	init();
	int N;
	cin >> N;
	rep(i, N+1) {
		cin >> a[i];
		if (num[a[i]]) {
			numi = a[i];
			r = i;
		}
		num[a[i]] = true;
	}
	rep(i, N+1) {
		if (a[i] == numi) {
			l = i;
			break;
		}
	}
	reps(i, 1, N+2) {
		cout << (comb(N+1, i) + (MOD-comb(l+N-r, i-1))) % MOD << endl;
	}
}


Measured memory_bytes: 3200
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v),v.end()));
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	set<int> st;
	REP(i, k) {
		int a;
		cin >> a;
		st.insert(a);
	}

	FOR(i,n, INF) {
		int a = i;
		int flag = 1;
		while (a > 0) {
			if (st.find(a % 10) != st.end())flag = 0;
			a /= 10;
		}
		if (flag) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
  string str1, str2 = "abcdefghijklmnopqrstuvwxyz";
  cin >> str1;
  sort(str1.begin(), str1.end());
  int ptr = 0;
  for (int i = 0; i < str1.length(); ptr++) {
    if (str1[i] != str2[ptr]) {
      cout << str2[ptr] << endl;
      return 0;
    }
    while (str1[i] == str2[ptr]) i++;
  }
  if (ptr < str2.length()) {
    cout << str2[ptr] << endl;
  } else {
    cout << "None" << endl;
  }
  return 0;
}

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

#define ll long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define bac(i,a,b) for(int i=b-1;i<=a;i--)

#define pb push_back
#define vi vector<int>
#define vll vector<ll>

#define mod 1000000007
int n;
int res(vector<vi> &a,int r,int c,int c1,int c2,vector<vi> &z)
{
    if(z[r][c]!=-1)
    return z[r][c];
    if(r==n-1)
    return z[r][c]=a[n-1][c];
    if(c==0)
    {
        c1=1;c2=2;
    }
    else if(c==1)
    {
        c1=0;c2=2;
    }
    else if(c==2)
    {
        c1=0;c2=1;
    }
    int d=r+1;
    int left=res(a,d,c1,0,0,z);
    int right=res(a,d,c2,0,0,z);
    return z[r][c]=a[r][c]+max(left,right);
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	vector<vi> a(n,vi(3,0));
	vector<vi> z(n,vi(3,-1));
	for(int i=0;i<n;i++){
	        cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	int b=res(a,0,0,0,0,z);
	int c=res(a,0,1,0,0,z);
	int d=res(a,0,2,0,0,z);
	int e=b>c?b>d?b:d:c>d?c:d;
	cout<<e<<endl;
	return 0;
}


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

int main()
{
    int n,k,x;

    cin >> n >> k;

    int ans = 0;
    for (size_t i = 0; i < n; i++)
    {
        cin >> x;
        ans += min(x,k - x) * 2;
    }
    
    cout << ans << endl;
}

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

x = (1+(1+8*N)**0.5)/2
if x.is_integer():
  print('Yes')
  x = int(x)
  print(x)
  S = [[] for _ in range(x)]
  e = 1
  for i in range(x):
    for j in range(i+1,x):
      S[i].append(e)
      S[j].append(e)
      e += 1
  for s in S:
    print(len(s),*s)
else:
  print('No')

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

using namespace std;

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

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

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

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

    co << a * b / 2 << en;
  
	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define ALL(a) (a.begin()),(a.end())


int64_t N; 
int64_t K; 
int64_t C; 
vector<int> L;
vector<int> R;
string S;
int main() {
 
    cin>>N>>K>>C>>S; 

    
    for(int i=0; i<N; i++){
        if(S[i]=='o'){
            L.push_back(i);
            i=i+C;
        }
    }

    for(int i=N-1; i>=0; i--){
        if(S[i]=='o'){
            R.push_back(i);
            i=i-C;
        }
    }
    reverse((R.begin()),(R.end()));

    int64_t x=0;
    int64_t j=0;

    for(int i=0; i<N; i++){
        if(S[i]=='o'){
		    x=lower_bound((L.begin()),(L.end()),i)-L.begin();
		    j=lower_bound(ALL(R),i+1)-R.begin();
    		j=R.size()-j;
	    	if(x+j<K) cout<<i+1<<endl;	
        }
    }

    return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  vector<ll> a(n);
  int i;
  rep(i,n)cin>>a[i];
  sort(all(a));
  vector<ll> sum(n+1,0);
  rep(i,n)sum[i+1]=sum[i]+a[i];
  int ans=1;
  for(i=n-1;i>=1;i--)
  {
    if(sum[i]*2>=a[i])
    {
      ans++;
    }
    else break;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#!/usr/bin/env ruby

def rotate(dice,direction)
    case direction
    when "N"
        return [dice[1],dice[5],dice[2],dice[3],dice[0],dice[4]]
    when "E"
        return [dice[3],dice[1],dice[0],dice[5],dice[4],dice[2]]
    when "W"
        return [dice[2],dice[1],dice[5],dice[0],dice[4],dice[3]]
    when "S"
        return [dice[4],dice[0],dice[2],dice[3],dice[5],dice[1]]
    when "Z"
        return [dice[0],dice[2],dice[4],dice[1],dice[3],dice[5]]
    end
end

def changetop(dice,i)
    case i
    when 0 
        return dice
    when 1 
        return rotate(dice,"N")
    when 2
        return rotate(dice,"W")
    when 3
        return rotate(dice,"E")
    when 4
        return rotate(dice,"S")
    when 5
        return rotate(rotate(dice,"N"),"N")
    end
end


diceA = gets.split.map(&:to_i)
diceB = gets.split.map(&:to_i)

tempdice = []
6.times do |index|
    tempdice = changetop(diceB,index)
    if tempdice == diceA then
        puts "Yes"
        exit
    end
    3.times do 
        tempdice = rotate(tempdice,"Z")
        if tempdice == diceA then
            puts "Yes"
            exit
        end
    end
end
puts "No"



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

int main(){
    int h,w,d;
    cin >> h >> w >> d;
    vector<pair<int,int>> a(h*w+1);
    int kk;
    for (int i=1;i<h+1;i++){
        for (int j=1;j<w+1;j++){
            cin >> kk;
            a.at(kk).first=j;a.at(kk).second=i;
        }
    }
    vector<int> b(h*w+1);
    for (int i=1;i<h*w+1;i++){
        if (i<=d) b.at(i)=0;
        else b.at(i)=b.at(i-d)+abs(a.at(i).first-a.at(i-d).first)+abs(a.at(i).second-a.at(i-d).second);
    }
    int q;
    
    cin >> q;
    rep(i,q){
        int ans=0;
        int l,r,vv;
        cin >> l >> r;
        if (l%d==0) vv=d;
        else vv=l%d;
        ans=b.at(r)-b.at(l);
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <string>

const int mod = 1e9+7;

using namespace std;

int main(void){
    int n;
    cin >> n;
    map<int, int> m;
    map<int, int>::iterator ite;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        ite = m.find(tmp);
        if(ite == m.end()){
            m.insert(make_pair(tmp,1));
        }else{
            m[tmp]++;
        }
    }
    long long ans=0;
    for(ite = m.begin(); ite != m.end(); ite++){
        if(ite->second % 2 == 1){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4864
package main

import (
	"fmt"
	"math"
)

func main() {
	var s, t string
	fmt.Scanf("%s", &s)
	fmt.Scanf("%s", &t)

	length := len(t)
	var count int
	result := float64(math.MaxInt32)
	for i := 0; i < len(s)-length+1; i++ {
		str := s[i : i+length]
		for i, v := range str {
			if string(v) != string(t[i]) {
				count++
			}
		}
		result = math.Min(result, float64(count))
		count = 0
	}
	fmt.Println(int(result))
}


Measured memory_bytes: 1852
#include <bits/stdc++.h>
#define For(i, l, r) for(int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}

typedef long long ll;
ll n, a, b;

int main () {
#ifdef zjp_shadow
	freopen ("C.in", "r", stdin);
	freopen ("C.out", "w", stdout);
#endif
	cin >> n;
	For (i, 1, n) {
		ll x, y, nx, ny;
		cin >> x >> y;

		ll times = max(max(a / x, b / y), 1ll);
		for (nx = x * times, ny = y * times; nx < a || ny < b; nx += x, ny += y);
		a = nx; b = ny;
	}
	cout << a + b << endl;
    return 0;
}


Measured memory_bytes: 256
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,T;
    cin >> N >> T;
    vector<pair<int,int>> res(N);
    for(int i = 0; i < N; i++) {
        int c,t;
        cin >> c >> t;
        res[i].first = c;
        res[i].second = t;
    }
    sort(res.begin(),res.end());
    //for(auto p : res) cout << p.first << " "<< p.second << endl;
    for(P p : res) {
        if(p.second <= T) {
            cout << p.first << endl;
            return 0;
        }
    }
    cout << "TLE" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,k; cin >> n >> k;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    ll res = 0;
    rep(i,n){
        if(h[i] >= k)res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>

using namespace std;
typedef long long ll;

int N;
int dp[301][301];
int A[300];

int main() {
	while (1) {
		cin >> N;
		if (N == 0)return 0;
		
		for (int i = 0; i <= 300; i++)for (int j = 0; j <= 300; j++)dp[i][j] = 0;

		for (int i = 0; i < N; i++)cin >> A[i];

		for (int W = 2; W <= N; W++) {
			for (int i = 0;; i++) {
				int j = i + W - 1;
				if (j >= N)break;
				if (dp[i + 1][j - 1] == W - 2 && abs(A[i] - A[j]) <= 1)dp[i][j] = W;
				for (int k = i; k < j; k++) {
					dp[i][j] = max(dp[i][j], dp[i][k] + dp[k + 1][j]);
				}
			}
		}
		cout << dp[0][N - 1] << endl;

	}
	return 0;
}


Measured memory_bytes: 3468
#include<iostream>
#include<string>
#include<cstring>
#include<cctype>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s;
	cin>>s;
	int i=0;
	while(i<s.size()){
		if(s[i]!='A' && s[i]!='Z'){
			s.erase(i,1);
		}else{
			i++;
		}
	}
	for(int i=0;i<s.size();){
		if(i%2==0){
			if(s[i]!='A'){
				s.erase(i,1);
			}else{
				i++;
			}
		}else{
			if(s[i]!='Z'){
				s.erase(i,1);
			}else{
				i++;
			}
		}
		if(s.size()==0)break;
	}
	if(s.size()>0){
		if(s[s.size()-1]!='Z')s.erase(s.size()-1,1);
		if(s[0]=='A' && s[s.size()-1]=='Z'){
			cout<<s<<endl;
		}else{
			cout<<"-1"<<endl;
		}
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}

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

int main() {
	long long N;
	cin >> N;
	long long total = 0;
	for (long long i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			total = i;
		}
	}
	long long result = N / total;
	long long count = 0;
	while (result != 0) {
		result = result / 10;
		count++;
	}
	cout << count << endl;
}

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

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

	int c = 0;
	auto l = 0;
	auto r = S.length() - 1;
	while (l < r) {
		if (S[l] != S[r]) {
			c++;
		}
		l++;
		r--;
	}

	cout << c << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	string S;

	getline(cin, S);
	int len = S.length();

	rep(i, len) {
		if ('a' <= S[i] && S[i] <= 'z') S[i] -= 0x20;
		else if ('A' <= S[i] && S[i] <= 'Z') S[i] += 0x20;
	}

	cout << S << endl;

	return 0;
}



Measured memory_bytes: 3196
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;


int main() {
	int d;
	cin >> d;
	if (d == 25) {
		cout << "Christmas" << endl;
	}
	else if (d == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (d == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (d == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B

solve s = min a b
    where
        a = length $ filter (not . id) $ B.zipWith (==) s t
        b = length $ filter (not . id) $ B.zipWith (==) s u
        t = B.pack $ take (B.length s) (cycle ['0','1'])
        u = B.pack $ take (B.length s) (cycle ['1','0'])

main = do
    s <- B.getLine
    print $ solve s

Measured memory_bytes: 6524
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
using ll = long long;
const int INF=1001001001;
const int MAX_N = 200005;

int main(){
  int n;
  cin >> n;
  
  map<string, int> gift;  
  rep(i, n){
  string s;
  cin >> s;
    if(gift.count(s)) gift.at(s)++;
    else gift[s] = 0;
  }
  
  cout << gift.size() << endl;
  
  return 0;
}
    

Measured memory_bytes: 19160
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

int main() {
  int N;
  string tmp;
  cin >> N;
  map<string, int> mp;
  
  for(int i=0; i<N; i++) {
    cin >> tmp;
    if(mp[tmp]==0) mp[tmp] = 1;
    else mp[tmp]++;
  }
  
  /*for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    cout << "key = " << itr->first                // キーを表示
         << ", val = " << itr->second << "\n";    // 値を表示
  }*/
  
  //cout << ((judge==1) ? "APPROVED" : "DENIED") << endl;
  
  int max = 0;
  vector<string> list;
  for(auto itr=mp.begin(); itr!=mp.end(); ++itr) {
    if(itr->second == max) {
      list.push_back(itr->first);
    } else if(itr->second > max) {
      max = itr->second;
      list.erase(list.begin(), list.end());
      list.push_back(itr->first);
    }
  }
  
  for(int i=0; i<list.size(); ++i) {
    cout << list[i] << " " << endl; 
  }
  
  return 0;
}

Measured memory_bytes: 27508
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

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

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int h,w;
  cin>>h>>w;
  int c[10][10];
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cin>>c[i][j];
    }
  }
  
  int a[h][w];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      int x;
      cin>>x;
      a[i][j] = x;
    }
  }
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      for(int k = 0; k < 10; k++){
        chmin(c[j][k],c[j][i]+c[i][k]);
      }
    }
  }
  ll ans = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(a[i][j]!=-1) ans+=c[a[i][j]][1];
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,K;
  cin >> A >> B >> K;
  bool narrow = false;
  if (B - A + 1 <= K * 2) narrow = true;
  if (!narrow) {
    for (int i = 0; i < K; i++) {
      cout << A + i << endl;
    }
    for (int i = K - 1; i >= 0; i--) {
      cout << B - i << endl;
    }
  }
  else {
    for (int i = A; i <= B; i++) {
      cout << i << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
use strict;
use warnings;
use utf8;

my @x;
my ($aa) = split /\s/, <STDIN>;
my ($bb) = split /\s/, <STDIN>;
my ($cc) = split /\s/, <STDIN>;
my ($dd) = split /\s/, <STDIN>;
my ($ee) = split /\s/, <STDIN>;

push @x, sort {$a <=> $b} $aa, $bb, $cc, $dd, $ee;

my @y;
my $sum = 0;
my $min = 0;
foreach my $x (@x) {
    my $aa = (($x % 10) > 0 ? 10 : 0);
    my $z = $x - ($x % 10) + (($x % 10) > 0 ? 10 : 0);

    push @y, $z;
    $sum +=  $z;
}


my $z = 0;
for (my $i = 0; $i < @x; $i++) {
    my $w = $y[$i] - $x[$i];

    if ($w > $z) {
        $z = $w;
    }
    #printf "%3s  : %3s\n", $x[$i], $y[$i];
}



printf "%s\n", $sum - $z;


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    string a, b;
    cin >> a >> b;
    if(a == b) cout << "=" << endl;
    else if(a > b) cout << ">" << endl;
    else cout << "<" << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define intpow(a, n) (int)pow((long double) a, (long double) n)
#define int long long

signed main(){
    int n; cin >> n;
    int sum = 0;
    reps(a,1,n)reps(b,1,n)reps(c,1,n){
        sum += gcd(a,gcd(b,c));
    }
    cout << sum << endl;
}

Measured memory_bytes: 3636
num = int(input())
int_row = list(map(lambda x: int(x), input().split(" ")))
ans = 0
for i in range(num):
    if i == 0:
        ans += int_row[0]
    elif i == num - 1:
        ans += int_row[-1]
    else:
        ans += min(int_row[i - 1], int_row[i])
print(ans)


Measured memory_bytes: 3060
def process(alpha, m):
    for i in range(m):
        h = int(input())
        ba = alpha[:h]
        #print(ba)
        alpha = alpha[h:] + ba
        #print(alpha)
    return alpha

results = []

while True:
    alpha = input()
    if alpha == "-":
        break
    m = int(input())
    res = process(alpha, m)
    results.append(res)

for w in results:
    print(w)


Measured memory_bytes: 5600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		long N = sc.nextLong(), K = sc.nextLong();
		long[] mon = new long[(int)N];
		for(int i = 0; i < N; i++) {
			mon[i] = sc.nextLong();
		}
		Arrays.sort(mon);
		if(N<=K) {
			pw.print(0);
		}else {
			for(int j = (int)N-1; j >= N-K; j--) {
				mon[j] = 0;
			}
			long sum = Arrays.stream(mon).sum();
			pw.print(sum);;
		}
		pw.close();
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}

Measured memory_bytes: 58184
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    double x[3], y[3], xp, yp;
    double ax, ay, bx, by;
    while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> xp >> yp) {
        int posi = 0, nega = 0;
        for (int i=0; i<3; ++i) {
            ax = x[(i+1)%3] - x[i];
            ay = y[(i+1)%3] - y[i];
            bx = xp - x[i];
            by = yp - y[i];
            if (ax * by - ay * bx > 0) {
                posi ++;
            } else {
                nega ++;
            }
        }
        if ( ! posi || ! nega) {
            cout << "YES" << "\n";
        } else {
            cout << "NO" << "\n";
        }
    }
    return 0;
}

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

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

using namespace std;

int main(){
	string s; cin>>s;
	s+=string(15-s.length(),'o');
	cout<<(count(s.begin(),s.end(),'o')>=8?"YES":"NO")<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    char s[30];
    cin >> s;
    int cnt[30];
    fill(cnt, cnt + 30, 0);
    imfor(i, strlen(s)) {
        cnt[s[i] - 'a']++;
    }
    imfor(i, 26) {
        if (cnt[i] > 1) {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"


int main(int argc, char const *argv[]) {

  // std::string A;
  // std::cin >> A;
  // std::cout << A[0] << '\n';
  //
  // int NN;
  // std::cin >> NN;
  // std::cout << NN*NN << '\n';

  int NN, KK;

  std::cin >> NN>>KK;

  long long ans = 0;

  for (size_t a = 1; a < NN + 1; a++) {
    int b = KK - a % KK;
    if ((2*b )% KK == 0) {
      long long kosu = (NN-b) / KK + 1;
      ans+= kosu * kosu;
    }
  }

  std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX_A 20

int A[MAX_A];
int n;

int solve(int i,int m){
  int res;
  if(m == 0)
    return 1;
  if(i>=n)
    return 0;
  res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}

int main(){

  int i,q,Q;

  scanf("%d",&n);

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

  scanf("%d",&q);

  for(i=0;i<q;i++){
    
    scanf("%d",&Q);
       
    if(solve(0,Q)==1)
      printf("yes\n");
    else
      printf("no\n");
  }
    return 0;
}
   

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>


int main() {

	long long n, m;

	std::cin >> n >> m;

	std::vector<long long> v(n, -1);

	for (size_t i = 0; i < m; i++)
	{
		long long a, b;

		std::cin >> a >> b;

		if (v[a - 1] == -1 || v[a - 1] == b) {
			v[a - 1] = b;
		}
		else {
			std::cout << -1 << std::endl;
			return 0;
		}
	}

	if (n > 1 && v[0] == 0) {
		std::cout << -1 << std::endl;
		return 0;
	}

	if (n > 1) v[0] = std::max(v[0], 1LL);
	for (size_t i = 0; i < n; i++)
	{
		std::cout << std::max(v[i], 0LL);
	}

	std::cout << std::endl;


	return 0;
}


Measured memory_bytes: 256