akhauriyash/Code-Regression huggingface dataset:
class Node:
	def __init__(self, id):
		self.id = id
		self.parent_id = -1
		self.depth = -1
		self.children = None
	def get_type(self):
		if self.parent_id == -1:
			return 'root'
		elif self.children == None or len(self.children) == 0:
			return 'leaf'
		return 'internal node'
	def __str__(self):
		strNode = 'node ' + str(self.id) + ': '
		strNode += 'parent = ' + str(self.parent_id) + ', '
		strNode += 'depth = ' + str(self.depth) + ', '
		strNode += self.get_type() + ', ['
		if len(self.children) > 0:
			strNode += str(self.children[0])
			for i in range(1, len(self.children)):
				strNode +=  ', ' + str(self.children[i])
		strNode += ']'
		return strNode

def calc_depth(nodes):
	stack = []
	for i in range(len(nodes)):
		if nodes[i].parent_id == -1:
			nodes[i].depth = 0
			stack.append(nodes[i].id)
			break
	while len(stack) != 0:
		node = nodes[stack.pop()]
		for i in range(len(node.children)):
			child_id = node.children[i]
			nodes[child_id].depth = node.depth + 1
			stack.append(child_id)

n = int(input())
nodes = [Node(i) for i in range(n)]
for i in range(n):
	a = list(map(int, input().split()))
	id = a[0]
	node = nodes[id]
	m = a[1]
	children = [0] * m
	for j in range(m):
		child_id = a[2 + j]
		child = nodes[child_id]
		child.parent_id = id
		children[j] = child_id
	node.children = children

calc_depth(nodes)

for i in range(n):
	print(nodes[i])


Measured memory_bytes: 38252
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;
use std::collections::HashSet;
use itertools::Itertools;

#[fastout]
fn main() {
    input! {
    n: usize,
    x: [usize; n]
    }
    let sx = x.iter().sorted().copied().collect::<Vec<usize>>();
    for i in 0..n {
        if x[i] <= sx[n / 2 - 1] {
            println!("{}", sx[n / 2])
        } else {
            println!("{}", sx[n / 2 - 1])
        }
    }
}


Measured memory_bytes: 8464
import sys
input = sys.stdin.readline

import numpy as np

N = int(input())
A = np.array([int(input()) for x in range(N)] + [0], dtype=np.int64)

x = (A[:-1][A[:-1] >= A[1:]]).sum()

if (A > np.arange(len(A))).any():
    x = -1
if (A[1:] >= A[:-1] + 2).any():
    x = -1

print(x)

Measured memory_bytes: 23800
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(),(x).end()
#define Graph vector<vector<int>>;
#define iterG(next_v, G, v) for(auto next_v : G[v]
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    map<int, int> cnt;
    int now = 0;
    int base = 1;
    int ans = 0;
    cnt[0] = 1;
    for(int i=s.size()-1;i>=0;i--){
        now = (now + int(s[i] - '0') * base) % 2019;
        base *= 10;
        base %= 2019;
        ans += cnt[now];
        cnt[now] += 1;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3772
#include<stdio.h>
int main(){
   int h,n;
   scanf("%d %d",&h,&n);
   int a[n];
   for(int i=0;i<n;i++){
      scanf("%d",&a[i]);
      h=h-a[i];
   }
   if(h<=0){
      printf("Yes\n");
   }else{
      printf("No\n");
   }
   
   return 0;
}


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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 1e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL MOD)
{
    if(n < 0) a = fp(a, MOD - 2, MOD), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % MOD) if(n & 1) res = res * a % MOD; return res;
}

int n;
int a[11];

void dfs(int dep, int mx)
{
    if(dep == n)
    {
        for(int i = 0; i < dep; i++) putchar('a' + a[i]);
        puts("");
        return ;
    }
    for(int i = 0; i <= mx + 1; i++)
    {
        a[dep] = i;
        dfs(dep + 1, max(mx, i));
    }
}

void work()
{
    cin >>n;
    dfs(0, -1);
}


int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

signed main()
{
   cin.tie(nullptr);
   ios_base::sync_with_stdio(false);

   int n;
   cin >> n;
   vector<int> x;
   x.resize(n + 1);

   rep(i, 0, n)
   {
      cin >> x[i];
      if (x[i] % 2 == 0)
      {
         if (x[i] % 3 != 0 && x[i] % 5 != 0)
         {
            cout << "DENIED\n";
            return 0;
         }
      }
   }
   cout << "APPROVED\n";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        long a = Long.parseLong(st.nextToken());
        long b = Long.parseLong(st.nextToken());
        long c = Long.parseLong(st.nextToken());
        long d = Long.parseLong(st.nextToken());
        
        long ans1 = a * c;
        long ans2 = a * d;
        long ans3 = b * c;
        long ans4 = b * d;

        long[] ans_array = {ans1, ans2, ans3, ans4};

        Arrays.sort(ans_array);

        pw.println(ans_array[3]);
        br.close();
        pw.close();
    }
}

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

using namespace std;

const int maxn = 100000 + 5;

int n, k;
char s[maxn];

void inline Init()
{
	scanf("%d %d %s", &n, &k, s + 1);
	for(int i = 1; i <= n; ++i) s[i] -= '0';
}

int t[maxn], e[maxn], tot;

void inline Solve()
{
	if(!s[1]) {
		t[++tot] = 0;
	}
	for(int i = 1; i <= n; ++i) {
		if(s[i]) {
			++t[tot += !s[i - 1]];
		} else {
			++e[tot];
		}
	}
	if(!s[n]) t[++tot] = 0;
	if(k >= tot - 1) {
		printf("%d\n", n);
		return;
	}
	int org = 0;
	for(int i = 1; i <= k; ++i) org += t[i] + e[i];
	org += t[k + 1];
	int ans = org;
	for(int l = 1, r = k; r < tot; ++l, ++r) {
		ans = max(ans, org);
		org = org + e[r + 1] + t[r + 2] - e[l] - t[l];
	}
	printf("%d\n", ans);
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 768
n, i, j, k = 500;
f(x) { return x > n ? x - k : x; }
main() {
	scanf("%d", &n);
	if (n <= k) {
		printf("%d", n);
		for (i = n + 1; puts(""), --i;)
			for (j = n; j--;) printf("%d ", i);
		return 0;
	}
	puts("500");
	for (i--; ++i < k; puts(""))
		for (j = 0; j < k; j++) printf("%d ", f((i + j) % k + 1 + j % 2 * k));
}

Measured memory_bytes: 1152
/**
 *   @FileName	b.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.19 21:03:02
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n;cin >> n;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int a,b;cin >> a >> b;
        if (a == b) cnt++;
        else cnt = 0;
        if (cnt == 3) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 3672
import java.util.*;
import java.lang.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int[] table = new int[128];
        
        while(sc.hasNext()) {
            String s = sc.nextLine();
        
            for (int i = 0; i < s.length(); i++) {
                table[s.charAt(i)]++;
            }
        }
        for (int i = 0; i < 26; i++) {
            System.out.println((char)('a' + i) + " : " + (table['a' + i] + table['a' + i - 32]));
        }
    }
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;


int main() {
    while (true) {
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0) return 0;
        rep(y, h) {
            rep(x, w) {
                if (x == 0 || y == 0 || x == w - 1 || y == h - 1)cout << '#';
                else cout << '.';
            }
            cout << endl;
        }
        cout << endl;

    }
}


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

struct P{
	double x, y;
	P(){}
	P(double x, double y) : x(x), y(y) {
	}
	P operator - (P p) {
		return P(x-p.x,y-p.y);
	}
	double det(P p){
		return x*p.y-y*p.x;
	}
	bool operator<(const P& r) const {
		return x==r.x?y<r.y:x<r.x;
	}
};

int n;
P p[100];

void solve(){
	int k = 0;
	char tra;
	rep(i,n) scanf("%lf%c%lf", &p[i].x, &tra, &p[i].y);
	sort(p,p+n);
	P qs[200];
	rep(i,n){
		while(k > 1 && (qs[k-1]-qs[k-2]).det(p[i]-qs[k-1]) <= 0) k--;
		qs[k++] = p[i];
	}
	for(int i = n-2, t = k; i >= 0; i--){
		while(k > t && (qs[k-1]-qs[k-2]).det(p[i]-qs[k-1]) <= 0) k--;
		qs[k++] = p[i];
	}
	printf("%d\n",n-k+1); 
}

int main(){
	while(scanf("%d",&n),n) solve();
}

Measured memory_bytes: 1228
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        s: chars
    }
    println!("{}", if s.iter().all(|&x| x == s[0]) {"No"} else {"Yes"});
}


Measured memory_bytes: 4352
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()

	// 証言行列初期化
	// xがyをmat[x][y]と証言した。番兵=2
	mat := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		mat[i] = make([]int, n+1)
		for j := 0; j < n+1; j++ {
			mat[i][j] = 2
		}
	}

	al := make([]int, n)
	for i := 0; i < n; i++ {
		al[i] = nextInt()
		for j := 0; j < al[i]; j++ {
			x := nextInt() - 1
			y := nextInt()
			mat[i][x] = y
		}

	}
	ans := 0

	// 正直者リストでbit全探索
	for bit := 0; bit < (1 << n); bit++ {

		// 正直者リスト作成
		var setlist []int
		for j := 0; j < n; j++ {
			if bit&(1<<j) != 0 { // 今回ヒットした場合
				setlist = append(setlist, j)
			}
		}

		// 矛盾がないかチェック
		nomujunf := true
		//// [1]各「正直者」の、同じ人の証言について、1も0もある場合は矛盾
		// [1]各「正直者」が不親切な人に1を証言していたら矛盾
		// [2]各「正直者」が親切な人に0を証言していたら矛盾

		for j := 0; j < len(setlist); j++ {
			// 各「正直者」ごとに各証言を見ていく
			for k := 0; k < n; k++ {
				shkf, _ := hasX(k, setlist) // kは正直者かどうか
				sh := mat[setlist[j]][k]

				// 「正直だ」の証言先kが不親切な人だったら矛盾
				if (sh == 1) && (shkf == false) {
					nomujunf = false
					break
				}
				// 「不親切な人だ」の証言先kが正直者だったら矛盾
				if (sh == 0) && (shkf == true) {
					nomujunf = false
					break
				}
			}

		}

		if nomujunf == true {
			ans = max(ans, len(setlist))
		}
	}

	fmt.Println(ans)

}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func hasX(x int, plist []int) (bool, int) {
	for i, p := range plist {
		if x == p {
			return true, i
		}
	}
	return false, -1
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
func nextIntMat(a int, b int) [][]int {
	mat := make([][]int, a)
	for i := 0; i < a; i++ {
		mat[i] = make([]int, b)
		for j := 0; j < b; j++ {
			mat[i][j] = nextInt()
		}
	}
	return mat
}


Measured memory_bytes: 5688
import itertools
n=int(input())
a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))
seq=range(1,n+1)
l=list(itertools.permutations(seq))
#print(l[0])

a_num=0
b_num=0
for i in range(len(l)):
  if l[i]==a:
    a_num=i
  if l[i]==b:
    b_num=i

print(abs(a_num-b_num))

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

int main(){
    string S; cin >> S;
    long long tmp=0;
    long long ans=1e9;
    rep(i,S.size()-2){
        tmp=100*(S[i]-'0')+10*(S[i+1]-'0')+(S[i+2]-'0');
        ans=min(ans,abs(tmp-753));
    }
    cout << ans;
    
}

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


void solve(long long N, long long X, long long Y){
    vector<ll> dist_num(N);
    for(ll i = 1;i<N;i++){
        for (ll j=i+1;j<=N;j++) {
            ll idx;
            if (i<X&&j<=X)
                idx = j-i;
            else if (i <= X && j > X && j < Y)
                idx = X-i + min(j - X, Y - j + 1);
            else if (i <= X && j >= Y)
                idx = X - i + 1 + j - Y;
            else if (i > X && i < Y && j > X && j < Y)
                idx = min(i-X+1+Y-j, j - i);
            else if (i > X && i < Y && j >= Y)
                idx = min(i-X+1, Y-i) + j - Y;
            else if (i>=Y && j>=Y)
                idx = j - i;

            // cout << i << "," << j << ":" << idx << endl;
            dist_num[idx]++;
        }
            
    }
    for(int i = 1;i<=N-1;i++)
        cout << dist_num[i] << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(N, X, Y);
    return 0;
}


Measured memory_bytes: 256
def count_div(start, end, div):
    # [start, end)
    return (end - 1) // div - (start - 1) // div


def calc_start(mid):
    cnt, i = 0, 1
    while 10 ** i < mid:
        d, p = 10 ** i, 10 ** (i - 1)
        fif, three, five = count_div(p, d, 15), count_div(p, d, 3), count_div(p, d, 5)
        cnt += i * (d - p) + (three + five) * 4 - (three + five - fif) * i
        i += 1
    d = 10 ** (i - 1)
    fif, three, five = count_div(d, mid, 15), count_div(d, mid, 3), count_div(d, mid, 5)
    cnt += i * (mid - d) + (three + five) * 4 - (three + five - fif) * i
    return cnt


N = int(input()) - 1
left, right = 1, 10 ** 18
while left + 1 < right:
    mid = (left + right) // 2
    start = calc_start(mid)
    if start <= N:
        left = mid
    else:
        right = mid
ans = ''
for i in range(left, left + 9):
    tmp = ''
    if i % 3 == 0:
        tmp += "Fizz"
    if i % 5 == 0:
        tmp += "Buzz"
    if not tmp:
        tmp = str(i)
    ans += tmp
start = calc_start(left)
print(ans[N - start:N - start + 20])

Measured memory_bytes: 7776
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer N = sc.nextInt();
        Integer R = sc.nextInt();
        if(N>=10) {
            System.out.println(R);
        } else {
            System.out.println(R + (10-N) * 100);
        }
    }
}


Measured memory_bytes: 23124
#include<stdio.h>

int main(void)
{
    int i,n,x;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
    	x=i;
    	if(x % 3 == 0){
    		printf(" %d",i);
    		continue;
    	}else{
    	    do{
    		    if(x%10==3){
    		    	printf(" %d",i);
    		    	break;
    		    }
    		    x /= 10;
    	    }while(x);
    	}
    }
    printf("\n");
    return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; 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;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

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


ll bfs(ll H, ll W, vector<string> s)
{
  ll cnt = -1;
  vector<ll> seen(H * W, -1);
  queue<ll> que;
  que.push(0);
  seen[0] = 0;
  while(que.size() > 0) {
    ll p = que.front(); que.pop();
    ll x = p % W;
    ll y = p / W;
    if(x == W - 1 && y == H - 1) {
      cnt = seen[y * W + x];
      break;
    }
    ll nx, ny;
    rep(i, 4){
      nx = x + dx[i];
      ny = y + dy[i];
      if(nx >= 0 && nx < W && ny >= 0 && ny < H) {
	if(s[ny][nx] == '.' && seen[ny * W + nx] < 0) {
	  seen[ny * W + nx] = seen[y * W + x] + 1;
	  que.push(ny * W + nx);
	}
      }
    }
  }
  
  return cnt;
}


void solve()
{
  ll H,W; cin >> H >> W;
  vector<string> s(H); rep(i, H) cin >> s[i];
  ll ans = -1;
  ll fcnt = 0;
  rep(y, H) rep(x, W) {
    if(s[y][x] == '.') fcnt ++;
  }
  
  ans = bfs(H, W, s);
  if(ans >= 0) {
    ans = fcnt - ans - 1;
  }
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3716
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <vector> // vectors
#include <string> // string
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <unordered_map> // hashed by keys
#include <iomanip> //cout<<setprecision(n)
#define rep(i,n) for(int i = 0; i < n; i++)

typedef long long ll; // at least int64 > 9*10^18
typedef unsigned long long ull; // at least uint64

int main() {
  int n, m;
  std::cin >> n >> m;
  int l, r;
  int fl = 1;
  int fr = n;
  rep(i,m) {
    std::cin >> l >> r;
    fl = std::max(fl,l);
    fr = std::min(fr,r);
  }
  if(fl>fr) std::cout << 0 << std::endl;
  else std::cout << fr-fl+1 << std::endl;
  
  return 0;
}

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

long long Quaternary(long long d) {
  vector<long long> v;
  while(d != 0) {
    v.push_back(d % 4); // d % 4 = 3
    d /= 4; // d / 4 = 1
  }
  
  long long j = 1, res = 0;
  for(int i = 0 ; i < v.size() ; i++) {
    res += (j * v[i]);
    j *= 10;
  }
  return res;
}

int main() {
  int decimal;
  while(cin >> decimal, decimal != -1) {
    cout << Quaternary(decimal) << endl; // 10 -> 4
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  ull n; cin >> n;
  ull ans = n * (n-1) / 2;
  cout << ans << endl;
  return 0;
}


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

int dp[30005][3005];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string a, b;
    cin>>a>>b;
    
    int lena = a.length(), lenb = b.length();
    for(int i = 0; i< lena; ++i){
        for(int j = 0; j < lenb; ++ j){
            if(a[i] == b[j]){
                dp[i+1][j+1] = dp[i][j] +1;
            }
            else{
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }


    string c;
    int i = lena,j = lenb;
    while (dp[i][j]!=0) {
        if(a[i-1] == b[j-1]){
            c = a[i-1] + c;
            --i;
            --j;
        }else if(dp[i][j] == dp[i-1][j]){
            --i;
        }
        else if(dp[i][j] == dp[i][j-1]) --j;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 37120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

int main(){
    ll a,b,n;
    cin>>n>>a>>b;
    ll d=b-a;
    if(d%2==0){
        cout<<d/2<<endl;
    }
    else{
        cout<<min(d/2+a-1+1,d/2+n-b+1)<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
using namespace std;

int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int difx=tx-sx;
    int dify=ty-sy;
    string ret;
    for(int i=0;i<dify;i++) ret+='U';
    for(int i=0;i<difx;i++) ret+='R';
    for(int i=0;i<dify;i++) ret+='D';
    for(int i=0;i<difx;i++) ret+='L';
    
    ret+='L';
    for(int i=0;i<dify+1;i++) ret+='U';
    for(int i=0;i<difx+1;i++) ret+='R';
    ret+='D';

    ret+='R';
    for(int i=0;i<dify+1;i++) ret+='D';
    for(int i=0;i<difx+1;i++) ret+='L';
    ret+='U';
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
int main(){
    int n;
    cin >> n;
    int v[n],c[n];
    rep(i,n){
        cin >> v[i];
    }
    rep(i,n){
        cin >> c[i];
    }
    int a[n];
    rep(i,n){
        a[i] = v[i]-c[i];
    }
    sort(a,a+n,greater<int>());
    int ans = 0;
    rep(i,n){
        if(a[i]>0){
            ans+=a[i];
        }
        else{
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n;

void solve()
{
    int d, res = 0;

    for (int i = 1; i <= n; i++)
    {
        d = to_string(i).length(); //桁数
        // 桁数が奇数のとき
        if (d % 2 == 1)
        {
            res++;
        }
    }

    cout << res << endl;
}

int main()
{
    cin >> n;

    solve();
}


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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = ((int)b); i <= ((int)e); i++)
#define RPT0(i, n) RPT(i, 0, ((int)n) - 1)
#define RPT1(i, n) RPT(i, 1, (n))
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    int S, W;
    cin >> S >> W;

    cout << (W >= S ? "unsafe" : "safe") << endl;
}

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


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	i64 a, b; scanf("%lld%lld", &a, &b);
	
	std::function<i64 (i64)> solve = [](i64 x) {
		switch(x % 4) {
			case 0: return x;
			case 1: return 1LL;
			case 2: return x ^ 1LL;
			case 3: return 0LL;
		}
	};
	printf("%lld\n", solve(b) ^ solve(a - 1));
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x=0;
	int max=x;
	string S;
	int N;
	scanf("%i",&N);
	
	getline(cin,S);
	getline(cin,S);
	if(N>=1 && N<=100 && S.length()==N){
		for(int i=0;i<N;i++){
			if(S[i]=='I'){
				x++;
				if(x>max)
					max=x;
			}
			else if(S[i]=='D'){
				x--;
				if(x>max)
					max=x;
			}
			else
				return 0;
		}
	}
	printf("%i",max);
}

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

using namespace std;

int m, n, p;
int a[10][10][10];
int h[10][10];
int b[10][10][10];

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

vector<int> vec;

int check2()
{
  int cnt = 0, pre = 0;
  for(int i = 0; i < vec.size(); i++){
    if(vec[i] == 0){
      cnt = 0;
      continue;
    }
    if(vec[i] == pre) cnt++;
    else cnt = 1;
    if(cnt >= m) return vec[i];
    pre = vec[i];
  }
  return 0;
}

int check(int sx, int sy, int sz)
{
  for(int d = 0; d < 13; d++){
      vec.clear();
      int x = sx, y = sy, z = sz, nx, ny, nz;
      while(1){
        nx = x + dx[d], ny = y + dy[d], nz = z + dz[d];
        if(nx < 1 || nx > n || ny < 1 || ny > n || nz < 1 || nz > n) break;
        vec.insert(vec.begin(), a[nz][nx][ny]);
        x = nx, y = ny, z = nz;
      }
      x = sx, y = sy, z = sz;
      vec.push_back(a[z][x][y]);
      while(1){
        nx = x - dx[d], ny = y - dy[d], nz = z - dz[d];
        if(nx < 1 || nx > n || ny < 1 || ny > n || nz < 1 || nz > n) break;
        vec.push_back(a[nz][nx][ny]);
        x = nx, y = ny, z = nz;
      }
      int res = check2();
      if(res) return res;
  }
  return 0;
}

int main(void)
{
  while(1){
    cin >> n >> m >> p;
    if(m == 0 && n == 0 && p == 0) break;

    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= n; j++){
        for(int h = 1; h <= n; h++){
          a[h][i][j] = 0;
        }
        h[i][j] = 0;
      }
    }

    int x, y; bool flag = false;
    for(int q = 0; q < p; q++){
      cin >> x >> y;
      if(flag) continue;
      int c = 1;
      if(q % 2) c = -1;
      a[++h[x][y]][x][y] = c;

      int res = check(x, y, h[x][y]);
      if(res == 1){
        cout << "Black " << q+1 << endl;
        flag = true;
      }
      if(res == -1){
        cout << "White " << q+1 << endl;
        flag = true;
      }
    }
    if(!flag) cout << "Draw" << endl;
    end:;
  }

  return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

vll prime_list(0);

void make_prime_list(int N){
    int plsz=0;
    for(int i=2;i<=N;i++){
        int sqi=(int)sqrt(i)+1;
        bool p=true;
        for(int j=0;j<plsz;j++){
            if(i%prime_list[j]==0){
                p=false;break;
            }
            if(sqi<prime_list[j])break;
        }
        if(p){
            prime_list.push_back(i);
            plsz++;
        }
    }
}

//Nは2以上 1を与えてはいけない
void pdec(ll N,vector<pii> &rt){
    rt.clear();
    vll pd;
    int idx=0;
    const int plsz=prime_list.size();
    while(idx<plsz){
        if(N%prime_list[idx]==0){
            N/=prime_list[idx];
            pd.push_back(prime_list[idx]);
            if(N==1)break;
        }else{
            idx++;
        }
    }
    if(N>1){
        pd.push_back(N);
    }
    assert(pd.size()>0);
    rt.push_back(make_pair(pd[0],1));
    int rtsz=1;
    int pdsz=pd.size();
    for(int i=1;i<pdsz;i++){
        if(pd[i]==rt[rtsz-1].first){
            rt[rtsz-1].second++;
        }else{
            rt.push_back(make_pair(pd[i],1));
            rtsz++;
        }
    }
}

int main(){
    ll N;
    cin>>N;
    if(N==1){
        cout<<0<<endl;return 0;
    }
    make_prime_list(1000000);
    vector<pii> pp;
    pdec(N,pp);
    // for(int i=0;i<pp.size();i++){
    //     cout<<"["<<pp[i].first<<","<<pp[i].second<<"] ";
    // }
    // cout<<endl;
    int ans=0;
    for(int i=0;i<pp.size();i++){
        int x=pp[i].second;
        int dec=1;
        while(x>=dec){
            x-=dec;dec++;ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4324
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  unordered_map<long, long> mp;
  rep (i, N) {
    long a;
    cin >> a;
    mp[a]++;
  }
  long ans = 0;
  for (auto it: mp) {
    if (it.second >= it.first) ans += it.second - it.first;
    else ans += it.second;
  }
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 4260
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

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

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

	ll n,k; cin >> n >> k;

	vector<ll> pos, neg;
	rep(i,n) {ll a; cin >> a; if (a > 0) pos.push_back(a); else neg.push_back(a);  }

	sort(all(pos)); sort(all(neg));
	debug(pos);
	debug(neg);

	auto f = [&](vector<ll>& a, vector<ll>& b){
		ll ng = -1000000000000000000, ok = 1000000000000000001;
		while (ng + 1 < ok) {
			ll mid = (ng + ok) / 2, cnt = 0;

			int ixb = 0;
			rep(ixa, a.size()) {
				while (ixb < b.size() && b[ixb] * a[ixa] <= mid) {
					ixb++;
				}
				cnt += ixb;
			}

			cerr << ng << " " << ok << " " << mid << " " << cnt << endl;

			if (cnt < k) ng = mid;
			else ok = mid;
		}

		return ok;
	};

	auto g = [](vector<ll>& v, ll mid){
		int r = v.size()-1;
		ll cnt = 0;
		for(int l = 0; l < r; ++l) {
			while (l < r && v[l] * v[r] > mid) {
				r--;
			}
			cnt += r - l;
		}
		return cnt;
	};

	if (pos.size() * neg.size() >= k) {
	  cout << f(pos,neg) << endl;
	}
	else {
	  reverse(all(neg));
		k -= pos.size() * neg.size();
		ll ng = -1000000000000000000, ok = 1000000000000000001;
		while (ng + 1 < ok) {
			ll mid = (ng + ok) / 2, cnt = 0;

			cnt += g(pos, mid);
			cnt += g(neg, mid);

			if (cnt < k) ng = mid;
			else ok = mid;
		}
    cout << ok << endl;
	}

}



Measured memory_bytes: 5340
def power(base,exp,op=lambda x,y:x*y,ie=1):
    res = ie
    while exp:
        if exp & 1:
            res = op(res,base)
        base = op(base,base)
        exp >>= 1
    return res

def fibonacci(n):
    I = [1,0,0,1]
    A = [1,1,1,0]
    mmul = lambda P,Q: [P[0]*Q[0]+P[1]*Q[2],P[0]*Q[1]+P[1]*Q[3],P[2]*Q[0]+P[3]*Q[2],P[2]*Q[1]+P[3]*Q[3]]
    return power(A,n+1,mmul,I)[2]

print(fibonacci(int(input())))


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

using namespace std;

int main(void){
  long long int N, M;
  cin >> N >> M;
  //ここまで入力

  //縦か横が1マスであれば，両端以外が裏になる
  if(N == 1)
    cout << abs(M-2) << endl;
  else if(M == 1)
    cout << N-2 << endl;
  //それ以外ならば，周を除いた中心部分が裏になる
  else{
    //周のマスの数
    long long int lap = 2*N + 2*M - 4;
    //合計のますの数
    long long int sum = N*M;
    cout << sum - lap << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
program main
      implicit none
      integer(4) :: k, a, b, i

      read *, k
      read *, a, b

      do i = a, b
        if ( mod(i,k) == 0 ) then
          print *, 'OK'
          stop
        end if
      end do
          print *, 'NG'
end program main


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

int main() {
 	int N,Ts=0;
  cin>>N;
  vector<int> T(N);
	for (int i = 0; i < N; i++) {
	  cin >> T[i];
      Ts+=T[i];
	}
  int M,P,c;
 	 cin>>M;
 	 for(int i=0;i<M;i++){
    cin>>P>>c;
 	int S=0;
 	  S=Ts-T[P-1]+c;
      cout<<S<<endl;
  }
}
    

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (){
while (1){
int a[10001],b[10001],c[501]={0},n,m,d=0;
cin>>n>>m;
if (n==0&&m==0)break;
c[1]=1;
for (int s=0;s<m;s++){
        cin>>a[s]>>b[s];
        if (a[s]==1){
                c[b[s]]=2;
        }
}
for (int s=0;s<m;s++){
        if (c[a[s]]==2&&c[b[s]]==0){
                c[b[s]]=3;
        }
        if (c[a[s]]==0&&c[b[s]]==2){
                c[a[s]]=3;
        }
}
for (int s=2;s<=n;s++){
        if (c[s]!=0){
                d++;
        }
}
cout<<d<<endl;
}
return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main()
{ char a[100][100];
int i, j, r, c;
cin>>r>>c;
for(i=0;i<r;i++)
{
    for(j=0;j<c;j++)
    {
        cin>>a[i][j];
    }
}

for(i=0;i<(r+2);i++)
{
    for(j=0;j<(c+2);j++)
    {
    
        if((i==0)||(j==0)||(i==r+1)||(j==c+1))
        {
            cout<<"#";
            
        }
        else
       {
           cout<<a[i-1][j-1];
           
       }
    }
    cout<<endl;
}

return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

def LI():
  return [int(s) for s in input().split()]

H = int(input())
"""2
def attack(x,n):
  if x == 1:
    return 2**n
  else:
    return attack(x//2,n+1) + 2**n

print(attack(H,0))

exit()
"""

attack_count = 0
attack_time = 0

while(H > 0):
  H = H // 2
  attack_count += 2**attack_time
  attack_time+=1

print(attack_count)




Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned long;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    void Solve() {
        while (true) {
            int m, f, r; cin >> m >> f >> r;
            if (m == -1 && f == -1 && r == -1) return;
            if (m == -1 || f == -1) { cout << "F" << endl; }
            else if (m + f >= 80) { cout << "A" << endl; }
            else if (m + f >= 65) { cout << "B" << endl; }
            else if (m + f >= 50) { cout << "C" << endl; }
            else if (m + f >= 30) {
                if (r >= 50) cout << "C" << endl;
                else cout << "D" << endl;
            }
            else cout << "F" << endl;
        }
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



Measured memory_bytes: 3108
def Findsumofdigits(i):
    c = 0
    while i > 0:
        c = c + i % 10
        i = (i - i % 10)/10
    return c
L = input().split()
N = int(L[0])
A = int(L[1])
B = int(L[2])
count = 0
for value in range(N + 1):
    if Findsumofdigits(value) >= A and Findsumofdigits(value) <= B:
        count = count + value
    else:
        pass
print(count)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
	int n, m, l, A[100][100], B[100][100];
	long long c;

	scanf("%d %d %d\n", &n, &m, &l);
	for (int i = 0; i < n; i++) {
		for (int k = 0;k < m;k++) {
			scanf("%d ", &A[i][k]);
		}
		scanf("\n");
	}
	for (int k = 0; k < m; k++) {
		for (int j = 0; j < l; j++) {
			scanf("%d ", &B[k][j]);
		}
		scanf("\n");
	}

	for (int i = 0; i < n; i++) {
		
		for (int j = 0;j < l;j++) {
			c = 0;
			for (int k = 0; k < m; k++) {
				c += (A[i][k] * B[k][j]);
			}
			printf("%lld", c);
			if (j < l - 1) printf(" ");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2756
/* ALDS1_9_C: Priority Queue */

#include <iostream>
#include <string>

const int MAX_N_NODES = 2000000;

class PriorityQueue {
    int size;
    int *heap;
    void max_heapify(int heap[], int i);
    public:
        PriorityQueue();
        ~PriorityQueue();
        void insert(int key);
        int extract_max();
};

PriorityQueue::PriorityQueue() {
    size = 0;
    heap = new int[ MAX_N_NODES + 1 ];
}

PriorityQueue::~PriorityQueue() {
    delete [] heap;
}

void PriorityQueue::insert(int key) {
    size++;
    heap[size] = key;

    int i = size;
    int i_parent = i / 2;
    while (1 < i && heap[i_parent] < heap[i]) {
        std::swap(heap[i_parent], heap[i]);
        i = i_parent;
        i_parent = i / 2;
    }
}

int PriorityQueue::extract_max() {
    int max = heap[1];

    heap[1] = heap[size];
    max_heapify(heap, 1);
    size--;

    return max;
}

void PriorityQueue::max_heapify(int heap[], int i) {
    int il = i * 2;
    int ir = i * 2 + 1;

    int max_i = i;
    if (il <= size && heap[i] < heap[il])
        max_i = il;
    if (ir <= size && heap[max_i] < heap[ir])
        max_i = ir;

    if (max_i != i) {
        std::swap(heap[i], heap[max_i]);
        max_heapify(heap, max_i);
    }
}

int main() {
    std::ios::sync_with_stdio(false);

    PriorityQueue pq;
    int key;
    std::string command;

    while(true) {
        std::cin >> command;
        if (command == "insert") {
            std::cin >> key;
            pq.insert(key);
        }
        else if (command == "extract") {
            std::cout << pq.extract_max() << "\n";
        }
        else if (command == "end") {
            break;
        }
    }
    return 0;
}

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

int main()
{
    string s , t ;
    cin >> s >> t ;
    bool flag = false ;
    for(int i = 0 ; i < s.length() ; i++)
    {
        if(!flag)
        {
            if(s[i] == t[0])
            {
                int I = i ;
                for(int j = 0 ; j < t.length() ; j++)
                {
                    if(s[I] != t[j]) break ;
                    else if(j == t.length() - 1 && s[I] == t[j])
                    {
                        flag = true ;
                        break ;
                    }
                    I = (I + 1)%s.length() ;
                }
            }
        }
        else break ;
    }
    if(flag) cout << "Yes" << endl ;
    else cout << "No" << endl ;
}


Measured memory_bytes: 3220
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int t = 0, x = 0, y = 0;
  for(int i = 0; i < N; ++i){
    int t_, x_, y_;
    cin >> t_ >> x_ >> y_;
    if(abs(x_-x)+abs(y_-y) > t_-t ||
       ((abs(x_-x)+abs(y_-y)) - (t_-t))%2 != 0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
n,a,b=map(int,input().split())

 
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = (numer*(n1-i)) % mod
        denom = (denom*i) % mod
    return numer * pow(denom, mod-2, mod) % mod

mod=10**9+7

print((pow(2,n,mod)- 1 - combination(n,a,mod) - combination(n,b,mod))%mod)

Measured memory_bytes: 3064
import collections

N = int(input())
W = [input() for i in range(N)]
c = collections.Counter(W)

for i in range(N-1):
    if W[i][-1] != W[i+1][0]:
        print("No")
        exit()
if len(c) != N:
    print("No")
    exit()
print("Yes")

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 4e5 + 5;

int n,k,h[maxn];

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

  cin>>n>>k;
  for (int i=0; i<n; i++) {
    cin>>h[i];
  }

  sort(h,h+n);
  int ans = 1e9;
  for (int i=0; i+k-1<n; i++) {
    ans = min(ans, h[i+k-1]-h[i]);
  }
  cout<<ans<<endl;
  return 0;
}


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

char convert(char c)
{
  if (c >= 'A' && c <= 'Z')
  {
    return c + 0x20;
  }
  else if (c >= 'a' && c <= 'z')
  {
    return c - 0x20;
  }
  else
  {
    return c;
  }
}

int main()
{
  string s;
  getline(cin, s);
  for (int i = 0; i < s.size(); i++)
  {
    cout << convert(s.at(i));
  }
  cout << endl;
}


Measured memory_bytes: 3200
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long[] a=new long[n];
		long[] b=new long[n];
		for(int i=0; i<n; i++){
			a[i]=sc.nextLong();
		}
		for(int i=0; i<n; i++){
			b[i]=sc.nextLong();
		}
		long[] fig=new long[29];
		long ans=0;
		for(int i=0; i<30; i++){
			long t=1<<i;
			long count=0;
			long[] aa=new long[n];
			long[] bb=new long[n];
			for(int j=0; j<n; j++){
				aa[j]=a[j]%(2*t);
				bb[j]=b[j]%(2*t);
			}
			Arrays.sort(bb);
			for(int k=0; k<n; k++){
				count+=lowerBounds(bb,2*t-aa[k])-lowerBounds(bb,t-aa[k]);
				count+=n-lowerBounds(bb,3*t-aa[k]);
			}
			ans|=(count & 1)<<i;
		}
		System.out.println(ans);
	}
	public static int lowerBounds(long[] arr,long value){
	int low=0;
	int high=arr.length;
	int mid;
	while(high>low){
		mid=((high - low) >>> 1) + low;    
		if(arr[mid]<value){
			low=mid+1;
		}else{
			high=mid;
		}
	}
	return low;
}
}


Measured memory_bytes: 156996
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,0,-1,1,-1,-1,1};
const int dy[]={0,1,-1,0,1,1,-1,-1};
const int INF = 1e8;
const double EPS = 1e-8;
#define PB push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> Pii;
typedef pair<int,vi > P;
typedef unsigned long long ll;
int main(){
	int A,B,C,D,P;
	cin >> A >> B >> C >> D >> P;
	int X = P*A;
	int Y = B;
	if(P > C){
		int Z = P-C;
		Y += Z*D;
	}
	cout << min(X,Y) << "\n";		
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
 
using namespace std;
 
int main()
{
    char c;
 
    int a[26] = {0};
    for (;cin >> c;)
    {
        if ('a' <= c && c <= 'z')
        {
            a[c - 'a'] ++;
        }
        if ('A' <= c && c <= 'Z')
        {
            a[c - 'A'] ++;
        }
    }
 
    for (int i = 0; i < 26; i++)
    {
        cout << (char)('a' + i) << " : " << a[i] << endl;
    }
}


Measured memory_bytes: 3076
#include <stdio.h>

int main(void) {
    int n, j;
    scanf("%d", &n);
    for (int i = 3; i <= n; i++) {
        j = i;
        if (j % 3 == 0) {
            printf(" %d", i);
        } else {
            for (; j > 0; j /= 10) {
                if (j % 10 == 3) {
                    printf(" %d", i);
                    break;
                }
            }
        }
    }
    puts("");
}



Measured memory_bytes: 2120
#include<cstdio>
#include<iostream>
#include<cctype>
using namespace std;

int main() {
	char ch;
	int counter[26] = {};

	while (cin >> ch) {
		ch = tolower(ch);
		if (isalpha(ch) ){
			counter[ch - 'a']++;
		}
	}

	for (int i = 0; i < 26; i++) {
		printf("%c : %d\n",i + 'a' , counter[i]);
	}

	return 0;
}


Measured memory_bytes: 3212