akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][][] room = new int[5][4][11];
        int n = sc.nextInt();

        for(int i = 1; i <= 4; i++) {
            for(int j = 1; j <= 3; j++) {
                for(int k = 1; k <= 10; k++) {
                    room[i][j][k] = 0;
                }
            }
        }

        for(int i = 0; i < n; i++) {
            int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            room[b][f][r] += sc.nextInt();
        }

        for(int i = 1; i <= 4; i++) {
            for(int j = 1; j <= 3; j++) {
                for(int k = 1; k <= 10; k++) {
                    System.out.print(" " + room[i][j][k]);
                }
                System.out.println();
            }
            if(i == 4) break;
            System.out.println("####################");
        }
    }
}


Measured memory_bytes: 29352
package main

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

func main() {
	L, R, d := getStdinInt3()
	cnt := 0
	for i := 0; i <= R; {
		if L <= i && i <= R {
			cnt++
		}
		i += d
	}
	fmt.Printf("%d\n", cnt)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt4() (int, int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2], list[3]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2160
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> x(n),y(n);
    vector<int64_t> h(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> x[i] >> y[i] >> h[i];
    }
    
    for(int cx = 0; cx <= 100; ++cx)
    {
        for(int cy = 0; cy <= 100; ++cy)
        {
            int64_t H = 0;
            for(int i = 0; i < n; ++i)
            {
                if(h[i] > 0)
                {
                    H = h[i] + abs(x[i]-cx) + abs(y[i]-cy);
                    break;
                }
            }
            if(H < 1L) continue;
            bool ok = true;
            for(int i = 0; i < n; ++i)
            {
                if( max(H - abs(x[i]-cx) - abs(y[i]-cy), 0L) != h[i] )
                {
                    ok = false;
                    break;
                }
            }
            if(ok)
            {
                cout << cx << ' ' << cy << ' ' << H;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int num[maxn];
 
int main(int argc, char const *argv[])
{
	int n;
	while(~scanf("%d",&n)){
		int temp,two=0,four=0;
		for(int i=0;i<n;i++){
			scanf("%d",&temp);
			if(temp%4==0){
				four++;
			}
			else if(temp%4!=0&&temp%2==0){
				two++;
			}
		}
		int flag=0;
		if(2*four+two>=n||(2*four+1==n)){
			flag=1;
		}
		if(flag){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	return 0;
}

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

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

    ll modulo = n % k;

    cout << min(modulo%k, (k-modulo)%k) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long

using namespace std;

void solve() {
    int n;
    cin >> n;
    int ac=0, wa=0, tle=0, re=0;
    for(int i=0; i<n; i++) {
        string s;
        cin >> s;
        if (s=="AC") ac++;
        else if (s=="WA") wa++;
        else if (s=="TLE") tle++;
        else re++;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

}

int main() {
    FAST_INPUT;

    solve();
    return 0;
}


Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define rep1(i,x) for(int i=1;i<=(x);++i)

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

int N, L;
int icicles[100002];
int memo[100002];

int rec(int i)
{
	if (memo[i] >= 0) return memo[i];

	int res = 0;

	if (icicles[i] < icicles[i + 1]) chmax(res, rec(i + 1));
	if (icicles[i] < icicles[i - 1]) chmax(res, rec(i - 1));

	res += L - icicles[i];

	return memo[i] = res;
}

signed main()
{
	memset(memo, -1, sizeof(memo));

    scanf("%d %d", &N, &L);

    rep1(i, N) scanf("%d", &icicles[i]);

	int ma = 0;

	rep1(i, N) chmax(ma, rec(i));

    printf("%d\n", ma);
}

Measured memory_bytes: 3180
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

// number一個取得
// eslint-disable-next-line no-unused-vars
const next = () => +cin[cid++];

// 文字列一個取得
// eslint-disable-next-line no-unused-vars
const nextstr = () => cin[cid++];

// BigInteger一個取得
// eslint-disable-next-line no-unused-vars
const nextbig = () => BigInt(cin[cid++]);

// 長さnの配列として取得。aは文字列フラグ
// eslint-disable-next-line no-unused-vars
const nexts = (n, a) =>
    a ? cin.slice(cid, (cid += n)) : cin.slice(cid, (cid += n)).map((a) => +a);

// w個ずつを組にして長さhの配列。aは文字列フラグ。
// eslint-disable-next-line no-unused-vars
const nextm = (h, w, a) => {
    var r = [],
        i = 0;
    if (a) for (; i < h; i++) r.push(cin.slice(cid, (cid += w)));
    else for (; i < h; i++) r.push(cin.slice(cid, (cid += w)).map((a) => +a));
    return r;
};
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
// eslint-disable-next-line no-unused-vars
const xArray = (...args) => {
    var a = args,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + a[0] + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
};

console.log(main());

function main() {
    let n = next();
    let a = nexts(n).sort((a, b) => a - b);
    let ans = 0;
    if (n == 1) return 1;
    //let b = Array.from(new Set(a));
    let dp = Array(a[n - 1] + 1).fill(true);
    //let nums = Array(a[n - 1] + 1).fill(0);
    //for (let i = 0; i < n; i++) nums[a[i]]++;
    let alength = a.length;
    a.push(0);
    for (let i = 0; i < alength; i++) {
        let x = a[i];
        if (dp[x]) {
            let jougen = Math.floor(a[n - 1] / x);
            //console.log({ x, jougen }, x * jougen);
            for (let j = 2; j <= jougen; j++) {
                dp[x * j] = false;
            }
            dp[x] = false;
            if (a[i] != a[i + 1]) ans++;
        }
    }

    return ans;
}


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

#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define ll long long
#define int ll

using namespace std;

signed main() {
    fast;
    //freopen("input.txt", "r", stdin);
    int n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr.rbegin(), arr.rend());
    auto check = [&](int val, int pos) {
        int good = 0;
        for (int i = p-1; i < n; i++) {
            if (i == pos) {
                continue;
            }
            if (arr[i] < val) {
                good += min(m, val - arr[i]);
            }
        }
        return good;
    };
    int L = 0, R = n - 1;
    int mid;
    while (R - L > 0) {
        mid = (L + R + 1) / 2;
        int val = arr[mid] + m;
        int pos = mid;
        int good = check(val, pos);
        int curP = 0;
        for (int i = 0; i < n; i++) {
            if (arr[i] <= val) {
                curP = i;
                break;
            }
        }
        if (good >= m * (v - p) && curP + 1 <= p) {
            L = mid;
        } else {

            R = mid - 1;

        }
    }
    int answer = L + 1;
    int val = arr[L] + m;
    int pos = L;
    int good = check(val, pos);
    if (good < m * (v - p)) {
        answer--;
    }
    cout << answer << endl;
    /* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?), set tle
        * do smth instead of nothing and stay organized
    */
    return 0;
}

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

using namespace std;
using vec = vector<int>;
using mat = vector<vec>;

void init(vec & parent)
{
	for (int i = 0; i < parent.size(); ++i)
	{
		parent[i] = i;
	}
}

int find(vec & parent, int x)
{
	if (parent[x] == x)return x;
	return parent[x] = find(parent, parent[x]);
}

void unite(vec & parent, int x, int y)
{
	x = find(parent, x);
	y = find(parent, y);
	if (x == y)return;
	parent[y] = x;
}

int change(int y, int x, int W)
{
	return y*W + x;
}


int main()
{
	while (true)
	{
		int w, h;
		cin >> w >> h;

		if (w == 0 && h == 0)return 0;

		mat c(h, vec(w));
		vec parent(h*w);

		init(parent);

		for (int y = 0; y < h; ++y)
		{
			for (int x = 0; x < w; ++x)
			{
				cin >> c[y][x];

				if (x != 0 && c[y][x] == c[y][x - 1])
				{
					unite(parent, change(y, x, w), change(y, x - 1, w));
				}
				if (y != 0 && c[y][x] == c[y - 1][x])
				{
					unite(parent, change(y, x, w), change(y - 1, x, w));
				}
				if (x != 0 && y != 0 && c[y][x] == c[y - 1][x - 1])
				{
					unite(parent, change(y, x, w), change(y - 1, x - 1, w));
				}
				if (x != w - 1 && y != 0 && c[y][x] == c[y - 1][x + 1])
				{
					unite(parent, change(y, x, w), change(y - 1, x + 1, w));
				}
			}
		}

		int ans = 0;
		for (int y = 0; y < h; ++y)
		{
			for (int x = 0; x < w; ++x)
			{
				int i = change(y, x, w);
				ans += parent[i] == i && c[y][x] == 1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
#include<vector>
using namespace std;
const int maxn=1e6+10;
long double n,m;
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>m;
    long long  ans=(long long)(n*m);
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 3736
arr = [1,  1,  1,  2,  1,  2,  1,  5,  2,  2,  1,  5,  1,  2,  1,  14,
       1,  5,  1,  5,  2,  2,  1,  15,  2,  2,  5,  4,  1,  4,  1,  51]

K = int(input())
print(arr[K - 1])

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

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

    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    sort(v.begin(), v.end());
    int ans = v[n/2] - v[n/2 - 1];
    cout << ans << endl;
}


Measured memory_bytes: 640
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* It does not matter how slowly you go as long as you do not stop.*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 1e18;
const int N = 1005;



int32_t main(){
    FAST;

  string s; cin >> s;
  cin >> s;
  cout << "A" << s[0] << "C" << endl;
  cin >> s;

    return 0;
}




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

using namespace std;

int N, M;

int main(void) {

	cin >> N >> M;

	if (N % 2 == 1) {
		for (int i = 1; i <= M; i++) {
			cout << i << " " << N - i << endl;
		}
	}
	else {


		int q = 0;
		for (int i = 1; i <= M; i++) {
			if (N-i-i<=N/2) { q=1; }
			cout << i+q << " " << N-i << endl;;
		}
	}

	return 0;
}

Measured memory_bytes: 3196
fn sum(n: u32) -> u32 {
    n * (n - 1) / 2
}
 
fn read_stdin() -> String {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    s
}
 
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}
 
fn split_whitespace(line: &str) -> Vec<u32> {
    line.split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}
 
fn as_u32(line: String) -> u32 {
    line.parse().unwrap()
}
 
fn as_player_indices(line: &str) -> Vec<usize> {
    split_whitespace(line)
        .iter()
        .map(|i| (i - 1) as usize)
        .collect::<Vec<_>>()
}
 
struct Player {
    destinations: Vec<usize>,
}
 
fn make_player(destinations: Vec<usize>) -> Player {
    Player { destinations: destinations.to_owned() }
}
 
struct State {
    no: usize,
    index: usize,
    s: bool
}
 
struct Schedule<'a> {
    players: &'a Vec<Player>,
    states: Vec<State>
}
 
impl<'a> Iterator for Schedule<'a> {
    type Item = usize;
    fn next(&mut self) -> Option<Self::Item> {
        
        let destination_count = self.players[0].destinations.len();
        let mut destinations = self.states.iter()
            .filter(|s| self.states[s.no].s)
            .map(|s| self.players[s.no].destinations[s.index])
            .collect::<Vec<_>>();
        destinations.sort();
        destinations.dedup();  
        
        let count = destinations.len() / 2;
        
        for &d in &destinations {
            self.states[d].index += 1;
        }
        for d in destinations {
            if self.states[d].index >= destination_count {
                self.states[d].s = false;
                continue;
            }
            let d1 = self.players[d].destinations[self.states[d].index];
            self.states[d].s = self.players[d1].destinations[self.states[d1].index] == d;
            if self.states[d].s { self.states[d1].s = true;}
        }
        
        if count > 0 { Some(count) } else { None }
    }
}
 
fn schedule<'a>(players: &'a Vec<Player>) -> Schedule<'a> {
    Schedule {
        states: (0..(players.len())).map(|i| State{ no: i, index: 0, s: {
                let d1 = players[i].destinations[0];
                players[d1].destinations[0] == i
        }}).collect(),
        players: players
    }
}
 
fn main() {
    let n = as_u32(read_line());
    let players = read_stdin().lines()
        .map(as_player_indices)
        .map(make_player)
        .collect::<Vec<_>>();
        
    let s = schedule(&players).map(|i| i).collect::<Vec<_>>();
    let count = {
        if s.iter().sum::<usize>() == sum(n) as usize { s.len() as i32 } else { -1 }
    };
 
    println!("{}", count);
}

Measured memory_bytes: 16504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s[3];
  cin >> s[0];
  cin >> s[1];
  cin >> s[2];
  cout << s[0][0] << s[1][1] << s[2][2] << endl;
    
  return 0;
    

}


Measured memory_bytes: 256
#!/usr/bin/env python3
import math


def main():
    a, b, x = map(int, input().split())

    if a * a * b / 2 <= x:
        ans = math.atan(2 * (a * a * b - x) / (a * a * a))
    else:
        ans = math.pi / 2 - math.atan(2 * x / (a * b * b))

    print(math.degrees(ans))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9356
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    REP(i, n) cin >> a[i];
    int sign = 1;
    ll sum=0, ans_plus=0, ans_minus=0;
    REP(i,n){
        sum += a[i];
        //cout << i << " " << sum <<endl;;
        if(sum * sign <=0){
            //cout << "hai" << endl;
            ans_plus += abs(sum) +1;
            sum = sign;
        }
        sign *= -1;
    }
    //cout << ans_plus << "\nkoko\n";

    sum = 0;
    sign = -1;
    REP(i, n){
        sum += a[i];
        //cout << i << " " << sum <<endl;;
        if(sum * sign <=0){ 
            //cout << "hai" << endl;
            ans_minus += abs(sum) +1;
            sum = sign;
        }
        sign *= -1;

    }

    //cout << ans_minus <<endl;

    cout << min(ans_plus, ans_minus) << "\n";
    return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 03 11:58:46 2015

@author: hirose
"""

n = map(int, raw_input().split())

a = n[0]
b = n[1]

#print a/b, a%b, float(a)/b
print '%d %d %f' %(a/b, a%b, float(a)/b)

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


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

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
typedef vector<vector<Edge>> Graph;

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

ll facmemo[200000] = {};

ll factorial(ll n) {//階乗
	if (facmemo[n] != 0) return facmemo[n];
	if (n == 0) return 1;
	ll ret = n * factorial(n - 1);
	ret %= MODU;
	return facmemo[n] = ret;
}

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %mod;
		x = x * x%mod;
		n >>= 1;
	}
	return res;
}
ll divmod(ll a, ll b, ll m) { // a/b(mod m)
								  // a/b (mod m)
								  // a*b^-1
								  // b^-1 * b = 1
								  // b^(m-1) = 1 
								  // b^(m-2) * b = 1
								  // b^-1 = b^(m-2)

								  // a/b = a * b^(m-2)

	return (a * 1LL * mod_pow(b, m - 2, m)) % m;
}
ll ncr(ll n, ll r) {
	if (r == 0) return 1;
	if (n < r) return 1;
	return divmod(factorial(n), (factorial(r) * (factorial(n - r))) % MODU, MODU);
}

bool sankaku(int a, int b, int c) {
	return a <= b + c && b <= a + c && c <= b + a;
}
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}

signed main() {
	int a, b;
	cin >> a >> b;
	string sa, sb;
	REP(i,a) {
		sb += to_string(b);
	}
	REP(i, b) {
		sa += to_string(a);
	}

	if (sa < sb) cout << sa;
	else cout << sb;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repin(Array,n) for(int z=0;z<n;z++){cin>>Array[z];}
using namespace std;

using ll = long long;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
using Graph = vector<vector<int>>;

int main() {

	string s;
	cin >> s;

	while (!s.empty()) {
		s.erase(s.size() - 1);

		bool flag = true;
		if (s.size() % 2 == 0)
			for (int i = 0; i <= (s.size() - 1) / 2; i++) {
				if (s[i] != s[s.size()/2 + i]) {
					flag = false;
					break;
				}
			}
		else
			flag = false;

		if (flag) {
			cout << s.size() << endl;
			break;
		}
	}

	return 0;
}

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

char const * direct_text[] = {"R", "D", "L", "U"};

bool can_move(int a[10][6], int x, int y, int d)
{
    if ( (d == 0 && a[2*x-1][y  ] == 1) ||
         (d == 1 && a[2*x  ][y  ] == 1) ||
         (d == 2 && a[2*x-1][y-1] == 1) ||
         (d == 3 && a[2*x-2][y  ] == 1) )
        return 1;
    else 
        return 0;
}

int main(void) {
    int a[10][6] = {{}};
    char c;

    for (int i = 1; i <= 9; ++i)
        for (int j = 1; j <= 5; ++j)
            if (j <= 4 || i%2==0) {
                cin >> c;
                a[i][j] = c - '0';
            }

    int x = 1, y = 1, d = 0;

    while (true) {
        for (int i = 0; i < 4; ++i) {
            if (can_move(a, x, y, (d+3+i)%4)) {
                d = (d+3+i)%4;
                if (d == 0)
                    y += 1;
                else if (d == 1)
                    x += 1;
                else if (d == 2)
                    y -= 1;
                else
                    x -= 1;
                cout << direct_text[d];
                break;
            }
        }
        if (x == 1 && y == 1)
            break;
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 2952
#include<stdio.h>
int main( )
{
    int n , a , sum ; 
    scanf("%d%d" , &n , &a);
    
    if( n%500 == 0)
        printf("Yes\n");
        
    else if( a != 0)
    {
        sum = n%500 ;
        if( sum <= a)
            printf("Yes\n");
            
        else 
            printf("No\n");
    }
    else 
        printf("No\n");
        
        return 0;
}

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

string N;
string symbol("+++");

void rec(int count = 0, int ans = N[0] - '0'){
    
    if(count == 3){
        if(ans == 7){
            cout << N[0] << symbol[0] << N[1] << symbol[1] << N[2] << symbol[2] << N[3] << "=" << 7 << endl;
            exit(0);
        }
        return;
    }
    
    symbol[count] = '+';
    rec(count + 1, ans + (N[count + 1] - '0'));
    
    symbol[count] = '-';
    rec(count + 1, ans - (N[count + 1] - '0'));
    
    return;
}

int main(void){
    
    cin >> N;
    
    rec();
    
    return 0;
}


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

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

  int ans = 1e9;
  for (int i = 0; i < (int)S.size()-2; i++) {
    int num = stoi(S.substr(i,3));
    ans = min(ans, abs(753-num));
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y;
  Point(){x=0;y=0;}
  Point(double d_x,double d_y){x=d_x,y=d_y;}
  double operator*(Point obj){return obj.x*x+obj.y*y;}
  double operator%(Point obj){return obj.y*x-obj.x*y;}
  Point operator*(double b){Point tmp;tmp.x=x*b;tmp.y=y*b;return tmp;}
  Point operator/(double b){Point tmp;tmp.x=x/b;tmp.y=y/b;return tmp;}
  Point operator+(Point obj){Point tmp;tmp.x=x+obj.x;tmp.y=y+obj.y;return tmp;}
  Point operator-(){Point tmp;tmp.x=-x;tmp.y=-y;return tmp;}
  Point operator-(Point obj){Point tmp;tmp.x=x-obj.x;tmp.y=y-obj.y;return tmp;}
  Point operator-=(Point obj){x-=obj.x;y-=obj.y;return *this;}
  Point operator+=(Point obj){x+=obj.x;y+=obj.y;return *this;}
  Point operator/=(double b){x=x/b;y=y/b;return *this;}
  Point operator*=(double b){x=x*b;y=y*b;return *this;}
  double size(){return hypot(x,y);}
  Point unit(){return Point(x/size(),y/size());}
  Point normal(){return Point(y,-x);}
  double atan(){return atan2(y,x);}
};

bool operator<(Point a,Point b){return a.x!=b.x?a.x<b.x:a.y<b.y;}
bool operator>(Point a,Point b){return b<a;}
bool operator<=(Point a,Point b){return !(b<a);}
bool operator>=(Point a,Point b){return !(a<b);}
bool operator==(Point a,Point b){return (a-b).size()<eps;}
bool operator!=(Point a,Point b){return !(a==b);}

bool equal(double a,double b){return abs(a-b)<eps;}
double cross(Point a,Point b){return a%b;}
double dot(Point a,Point b){return a*b;}

int ccw(Point a,Point b,Point c)
{
  b=b-a;
  c=c-a;
  if(b%c>0) return +1;
  else if(b%c<0)return -1;
  else if(b*c<0) return +2;
  else if(b.size()<c.size()) return -2;
  else return 0;
}

int w,d;
vector<int> h1(15);
vector<int> h2(15);

string cmp(string a,string b)
{
  if(a.size()>b.size()) return a;
  if(b.size()>a.size()) return b;
  return max(a,b);
}

int main(int argc,char const* argv[])
{
  while(1)
    {
      cin >> w >> d;
      if(!w) break;
      int ans=0;
      vector<int> h1(w);
      vector<int> h2(d);
      for(int i=0;i<w;i++)
	{
	  cin >> h1[i];
	  ans+=h1[i];
	}
      for(int i=0;i<d;i++)
	{
	  cin >> h2[i];
	}

      for(int i=0;i<d;i++)
	{
	  for(int j=0;j<w;j++)
	    {
	      if(h2[i]==h1[j])
		{
		  h1[j]=0;
		  h2[i]=0;
		}
	    }
	}
      for(int i=0;i<d;i++) ans+=h2[i];
      cout << ans << endl; 
    }
  return 0;
}



Measured memory_bytes: 3080
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

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

int N,a[11234];

int main() {

	scanf("%d", &N);
	rep(i, N) scanf("%d", &a[i]);

	int c = 0;
	rep(i, N) {
		while (!(a[i] & 1)) {
			a[i] >>= 1;
			c++;
		}
	}

	printf("%d\n", c);

	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::io::{stdin, stdout, Read, Write};
use std::str::FromStr;

#[derive(Default)]
struct Scanner<R: Read> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner {
            reader,
        }
    }

    fn scan<T: FromStr>(&mut self) -> Option<T> {
        let s = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        s.parse::<T>().ok()
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.scan() {
            s
        } else {
            std::process::exit(1);
        }
    }
}

fn dfs(pre_order: &[usize], in_order: &[usize]) -> Vec<usize> {
    assert_eq!(pre_order.len(), in_order.len());
    if pre_order.len() == 0 {
        return Vec::new();
    }
    let r = pre_order[0];
    let i = in_order.iter().position(|&x| x == r).unwrap();
    let mut v = Vec::<usize>::new();
    if i > 0 {
        let mut ret = dfs(&pre_order[1..i+1], &in_order[0..i]);
        v.append(&mut ret);
    }
    if i < pre_order.len() {
        let mut ret = dfs(&pre_order[i+1..], &in_order[i+1..]);
        v.append(&mut ret);
    }
    v.push(r);
    v
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let out = stdout();
    let mut out = out.lock();

    let n = sc.next();
    let pre_order = (0..n).map(|_| sc.next()).collect::<Vec<usize>>();
    let in_order = (0..n).map(|_| sc.next()).collect::<Vec<usize>>();

    let v = dfs(&pre_order[..], &in_order[..]);
    writeln!(out, "{}", v.iter().map(ToString::to_string).collect::<Vec<String>>().join(" ")).ok();
}


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

ans=0
for i in range(n):
    if a[i]>=b[i]:
        ans+=b[i]
    else:
        b[i]-=a[i]
        ans+=a[i]
        num = min(b[i],a[i+1])
        a[i+1]-=num
        ans+=num
print(ans)

Measured memory_bytes: 18476
using System;
using System.Collections.Generic;
class some
{
	public static void Main()
	{
		int n=int.Parse(Console.ReadLine());
		string[]ss=Console.ReadLine().Split();
		int[]arr=new int[ss.Length];
		for(int i=0;i<arr.Length;i++)
		{
			arr[i]=int.Parse(ss[i]);
		}
		Array.Sort(arr);
		int sum=0;
		for(int i=arr.Length-2;i>=0;i-=2)
		{
			sum+=arr[i];
			
		}
		Console.WriteLine(sum);
	}
}


Measured memory_bytes: 11220
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	v := make([]int, n)
	xy := 0

	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
	}
	for i := 0; i < n; i++ {
		var c int
		fmt.Scan(&c)
		if v[i] - c > 0 {
			xy += v[i] - c
		}
	}

	fmt.Println(xy)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s, t;
    cin >> s >> t;
    rep(i, s.size())
    {
        if (s == t)
        {
            cout << "Yes" << endl;
            return 0;
        }
        s = s[s.size() - 1] + s.substr(0, s.size() - 1);
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	char s[101];
	int n;
	cin >> s >> n;
	int len = strlen(s);
	if(len == 1) cout << s[0] << endl;
	else {
		char ans;
		for(int i = 0; i < len; i++){
			ans = s[i];
			if(ans != '1' || i + 1 >= n) break;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

A = list(map(int, input().split()))

A = sorted(A, reverse=True)

S = sum(A)

x = S / (4 * M)

cnt = 0
for i in range(N):
    if A[i] >= x:
        cnt += 1

if cnt >= M:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 38384
from bisect import bisect_left, bisect_right
from random import randint

class Set(): #BinaryIndexedTree
    def __init__(self, valuelist, INF=10**18+1):
        self.n = len(valuelist) + 1
        self.value = sorted(valuelist) + [INF]
        self.comp = {v : k for k, v in enumerate(self.value, 1)}
        self.bit = BinaryIndexedTree(self.n)

    def insert(self, x, k=1):
        self.bit.add(self.comp[x], k)

    def delete(self, x, k=1):
        self.bit.add(self.comp[x], -k)

    def count(self, x):
        return self.bit.get(self.comp[x])

    def sum(self, x):
        return self.bit.sum(self.comp[x])

    def get(self, k): #k個以下のときはINFを返す
        return self.value[self.bit.bisect_left(k) - 1]

class BinaryIndexedTree(): #1-indexed
    def __init__(self, n):
        self.n = n
        self.tree = [0 for _ in range(n + 1)]

    def sum(self, idx):
        res = 0
        while idx:
            res += self.tree[idx]
            idx -= idx & -idx
        return res

    def get(self, idx):
        return self.sum(idx) - self.sum(idx - 1)

    def add(self, idx, x):
        while idx <= self.n:
            self.tree[idx] += x
            idx += idx & -idx

    def bisect_left(self, x):
        if x <= 0: return 0
        res, tmp = 0, 2**((self.n).bit_length() - 1)
        while tmp:
            if res + tmp <= self.n and self.tree[res + tmp] < x:
                x -= self.tree[res + tmp]
                res += tmp
            tmp >>= 1
        if res >= self.n:
            return self.n
        return res + 1

D = int(input())
C = tuple(map(int, input().split()))
S = [tuple(map(int, input().split())) for _ in range(D)]

res = 0
last = [0 for _ in range(26)]
T = [0 for _ in range(D)]
used = [Set(list(range(D))) for i in range(26)]

for d in range(D):
    maxtmp = -10**18
    for i in range(26):
        tmp = 0
        lasttmp = last[:]
        tmp += S[d][i]
        lasttmp[i] = d + 1
        for j in range(26):
            tmp -= C[j] * ((d + 1) - lasttmp[j])
        if maxtmp <= tmp:
            maxtmp = tmp
            contest = i
    res += S[d][contest]
    last[contest] = d + 1
    used[contest].insert(d)
    for j in range(26):
        res -= C[j] * ((d + 1) - last[j])
    T[d] = contest + 1

for i in range(500000):
    tmp = res
    d = randint(1, D - 1)
    q = randint(1, 25)
    if T[d - 1] == q:
        continue
    tmp -= S[d - 1][T[d - 1] - 1]
    tmp += S[d - 1][q - 1]
    k = used[T[d - 1] - 1].sum(d - 1)
    l = used[T[d - 1] - 1].get(k - 1) if k != 1 else -1
    r = used[T[d - 1] - 1].get(k + 1)
    if r == 1000000000000000001:
        r = D
    tmp -= (d - 1 - l) * C[T[d - 1] - 1] * (r - d + 1)
    used[T[d - 1] - 1].delete(d - 1)
    used[q - 1].insert(d - 1)
    k = used[q - 1].sum(d - 1)
    l = used[q - 1].get(k - 1) if k != 1 else -1
    r = used[q - 1].get(k + 1)
    if r == 1000000000000000001:
        r = D
    tmp += (d - 1 - l) * C[q - 1] * (r - d + 1)
    if tmp >= res:
        res = tmp
        T[d - 1] = q
    else:
        used[T[d - 1] - 1].insert(d - 1)
        used[q - 1].delete(d - 1)

for t in T:
    if t >= 27 or t <= 0:
        print('hoge')
        break
    print(t)

Measured memory_bytes: 98812
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll n,q;cin >> n >>q;
    string s;cin >> s;
    vector<pair<char,char>> que(q);
    rep(i,q){
        cin >> que[i].fi >> que[i].se;
    }
    ll ok=-1,ng=n;
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        ll pos=mid;
        bool check=false;
        rep(i,q){
            if(s[pos]==que[i].fi){
                if(que[i].se=='L'){
                    pos--;
                }
                else pos++;
            }
            if(pos==-1){
                check=true;
                break;
            }
            if(pos==n)break;
        }
        if(check)ok=mid;
        else ng=mid;
    }
    ll ans=ok+1;
    ok=n,ng=-1;
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        ll pos=mid;
        bool check=false;
        rep(i,q){
            if(s[pos]==que[i].fi){
                if(que[i].se=='L'){
                    pos--;
                }
                else pos++;
            }
            if(pos==n){
                check=true;
                break;
            }
            if(pos==-1)break;
        }
        if(check)ok=mid;
        else ng=mid;
    }
    cout << ok-ans <<endl;
}

Measured memory_bytes: 900
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll m,k;
    cin>>m>>k;
    if(m==1){
        if(k==0){
            printf("0 0 1 1\n");
        }else cout<<-1<<endl;
    }else{
        if(k>=(1<<m)) cout<<-1<<endl;
        else{
            V<ll> a((1<<(m+1)));
            a[0]=k;
            ll cnt=(1<<m+1);
            a[(1<<m)]=k;
            for(ll i=1;i<(1<<m);i++){
                if(i<=k){
                    a[i]=a[cnt-i]=i-1;
                }else{
                    a[i]=a[cnt-i]=i;
                }
            }
            rep(i,(1<<(m+1))) cout<<a[i]<<' ';
            cout<<endl;
        }
    }
}

Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
//ll mod = 1000000007;
//ll mod = 998244353;

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	vector<ll> p(n);
	for (int i = 0; i < n; i++) cin >> p[i];
	vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, LINF));
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= n; j++) {
			if (j < p[i]) {
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + a);
				dp[i + 1][p[i]] = min(dp[i + 1][p[i]], dp[i][j]);
			}
			if (j > p[i]) {
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + b);
			}
		}
	}
	ll ans = LINF;
	for (int i = 0; i <= n; i++) ans = min(ans, dp[n][i]);
	cout << ans << endl;
}

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


typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vll;

#define kill(N) cout<<N<<'\n';
#define forn(N) for(int i=0; i<N; i++)

int H,W,K,row[7],column[7],gabungan[7][7],total=0,solve=0;
string arr[7];

vector<pi> v;
void dp(int i, int j){
	if(j==0){
		if(i==H-1){
			dp(0,1);
			v.push_back(make_pair(i,0));
			dp(0,1);
			v.pop_back();
		}else{
			dp(i+1,0);
			v.push_back(make_pair(i,0));
			dp(i+1,0);
			v.pop_back();
		}
	}else if(j==1){
		if(i==W-1){
			dp(0,2);
			v.push_back(make_pair(i,1));
			dp(0,2);
			v.pop_back();
		}else{
			dp(i+1,1);
			v.push_back(make_pair(i,1));
			dp(i+1,1);
			v.pop_back();
		}
	}else{
		int curr=0;
		for(int i=0; i<v.size(); i++){
			if(v[i].second==0){
				curr+=row[v[i].first];
				for(int j=i+1; j<v.size(); j++){
					if(v[j].second==1){
						curr-=gabungan[v[i].first][v[j].first];
					}
				}
			}else{
				curr+=column[v[i].first];
			}
		}
		if(curr==(total-K)){
			solve++;
		}
	}
}

int main(){
	cin>>H>>W>>K;
	memset(column,0,sizeof column);
	memset(row,0,sizeof row);
	memset(gabungan,0,sizeof gabungan);
	for(int i=0; i<H; i++){
		cin>>arr[i];
		for(int j=0; j<W; j++){
			if(arr[i][j]=='#'){
				row[i]++;
				column[j]++;
				gabungan[i][j]++;
				total++;
			}
		}
	}
	dp(0,0);
	cout<<solve<<'\n';
}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProblemC
{
    class Program
    {
        static void Main()
        {
            var buff = GetIntArray();
            int X = buff[0];
            int N = buff[1];
            int[] p = new int[N];
            if (N != 0)
            {
                p = GetIntArray();
            }
            var number = new bool[102];
            for(int i = 0; i < N; i++)
            {
                number[p[i]] = true;
            }

            for(int i = 0; true; i++)
            {
                if(number[X - i] == false)
                {
                    Console.WriteLine(X - i);
                    return;
                }
                else if(number[X + i] == false)
                {
                    Console.WriteLine(X + i);
                    return;
                }
            }
        }

        //入力関係のメソッド
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static int[] GetIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static double[] GetDoubleArray() => Console.ReadLine().Split().Select(double.Parse).ToArray();
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static long[] GetLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray();
        //出力関係のメソッド
        public static void OutIntArray(int[] values)
        {
            foreach (var value in values)
            {
                Console.WriteLine(value);
            }
        }
        public static void OutLongArray(long[] values)
        {
            foreach (var value in values)
            {
                Console.WriteLine(value);
            }
        }
        public static void OutList(List<object> list)
        {
            foreach (var value in list)
            {
                Console.WriteLine(value);
            }
        }

    }
}


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

const int MOD = 2019;

int main() {
  string S;
  cin >> S;
  reverse(S.begin(), S.end());
  ll power = 1;
  ll answer = 0;
  ll cur = 0;
  vector<int> remain(MOD);
  remain[0] = 1;
  for (auto s : S) {
    cur += (s-'0') * power;
    cur %= MOD;
    answer += remain[cur];
    remain[cur]++;
    power = power * 10 % MOD;
  }
  cout << answer << '\n';
  return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  vector<int> a(n),b(n),c(n-1);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  for(int i=0;i<n-1;i++){
    cin>>c[i];
  }
  int res=0;
  for(int i=0;i<n;i++){
    int t = a[i]-1;
    res += b[t];
    if(i)
      if(a[i-1]==t)
        res += c[t-1];
  }
  cout<<res<<endl;

  return 0;
}


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

int main()
{
	long int n,k,i;
	cin>>n>>k;
	long int a[n];
	for(i=0;i<n;i++)
	  cin>>a[i];
	for(i=0;i<n;i++)
	  {
	  	  if(a[i]==1)
	  	    break;
	  }
	double ans=i,ans1=n-1;
             //cout<<ans<<" "<<ans1<<'\n';
	cout<<ceil(ans1/(k-1))<<'\n';
	return 0;
}

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

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	vector<ll> B(N, 0);
	for (int i = 0;i < N;i++)
		cin >> A[i];
	//まず全てがN-1以下になるまで何回必要かを考える
	//一つだけN減って他全て1増えるなら
	//N+1減って水準となるnが1下がったことにすればよい
	ll cnt = 1, ans = 0;
	while (cnt) {
		cnt = 0;
		for (int i = 0;i < N;i++) {
			B[i] = A[i] / N;//回かかる
			A[i] %= N;
			cnt += B[i];
		}
		for (int i = 0;i < N;i++) {
			A[i] += (cnt - B[i]);
			B[i] = 0;
		}
		ans += cnt;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define INF 1e9
 
 
 
int main(){
    int a,b; cin >> a >> b;
    a--; b--;
    bool h[3];
    rep(i, 3){
        h[i] = false;
    }
    
    h[a] = true;
    h[b] = true;
    
    rep(i,3){
        if(h[i] == false){
            cout << ++i << endl;
            return 0;
        }
    }
 
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios_base::sync_with_stdio(0);
    int n, m; cin >> n >> m;

    int l = 1, r = n;

    for (int i=0;i<m;i++) {
        int a, b; cin >> a >> b;
        l = max(l, a);
        r = min(r, b);
    }

    cout << max(0, r-l+1) << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;

constexpr int MAXL = 2000000000;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> total(N, vector<int>(N));
    vector<vector<int>> road(N, vector<int>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            scanf("%d", &(total[i][j]));
            if (i == j) {
                total[i][j] = MAXL;
            }
            road[i][j] = total[i][j];
        }
    }

    for (int via = 0; via < N; via++) {
        for (int start = 0; start < N; start++) {
            if (road[start][via] == MAXL) continue;
            for (int goal = 0; goal < N; goal++) {
                if (road[via][goal] == MAXL || road[start][goal] == MAXL) continue;

                if (total[start][goal] > road[start][via] + road[via][goal]) {
                    cout << "-1" << endl;
                    return 0;
                } else if (total[start][goal] == road[start][via] + road[via][goal]) {
                    road[start][goal] = MAXL;
                    road[goal][start] = MAXL;
                }
            }
        }
    }

    long lsum = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (road[i][j] != MAXL) {
                lsum += road[i][j];
            }
        }
    }

    cout << lsum << endl;
}


Measured memory_bytes: 1656