akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;
    static int[] num = { 1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049 };

    static void Main(string[] args)
    {
        Solve();
    }




    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        int[] N = sc.intarr;
        int A = N[0];
        int B = N[1];

        if (Math.Max(A, B) <= 8)
        {
            wr.wri("Yay!");
        }
        else wr.wri(":(");
    }
}
    




class Scan
{
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
    public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;

const int N = (int) 3e5 + 100;
int a[N];


int main(int,  char **)
{
#ifdef LOCAL
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

	int n;
	scanf("%d", &n);
	n *= 3;
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i] );

	sort(a, a + n);
	long long ans = 0;
	for (int i = 0; i < n / 3; i++)
		ans += a[n - 2 - 2 * i];

	printf("%lld\n", ans);

	return 0;
}



Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    int d=a;
    FOR(i,1,b+1){
        a=d*i;
        if(a%b==c) {
            cout<<"YES"<<endl;
            return 0;
        }    
    }
    cout<<"NO"<<endl;
    return 0;
}

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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    while (cin >> n and n) {
        vector<Int> a(n);
        for (Int i = 0; i < (Int)n; i++) {
            cin >> a[i];
        }
        vector<Int> b(n + 1, -INF);
        b[0] = 0;
        for (Int i = 0; i < (Int)n; i++) {
            b[i + 1] = max(b[i] + a[i], a[i]);
        }
        Int res = -INF;
        for (Int i = 0; i < (Int)n; i++) {
            res = max(res, b[i + 1]);
        }
        print(res);
    }
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  string s; cin >> s;
  if(s.length()<=2) {cout << 0 << "\n"; return 0;}
  int x;
  long long ans=0;
  for(int i=0; i<s.length()-2; i++) {
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      x=1;
      int j=i-1;
      while(j>=0){
        if(s[j]=='A') {x++;j--;}
        else break;
      }
      ans += x;
      j=i+3;
      while(j<=s.length()-2){
        if(j<s.length()-2&&s[j]=='A'&&s[j+1]=='B'&&s[j+2]=='C') {x++;ans+=x;j+=3;}
        else if(s[j]=='B'&&s[j+1]=='C')  {ans+=x;j+=2;}
        else if(s[j]=='A')  {x++;j++;}
        else break;
      }
      i=j;
    }
  }
  cout << ans << "\n"; 
}

Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());

using ll = long long int;

int main(){
    vector<bool> a(3, true);
    rep(i, 2) {
        int b;
        cin >> b;
        a[b - 1] = false;
    }

    rep(i, 3) {
        if(a[i]) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  printf("%d\n", a[n / 2] - a[n / 2 - 1]);
  return 0;
}


Measured memory_bytes: 640
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val N = rd.readInt()
    val AB = rd.readListLongCols(N)
    val A = AB.map{ it[0] }.reversed().toLongArray()
    val B = AB.map{ it[1] }.reversed()

    var sum = 0L
    for (i in 0 until N) {
        val C = B[i] * ((A[i] + B[i]-1)/B[i])
        val press = C - A[i]
        sum += press

        if (i>=N-1) break

        A[i+1] += sum
    }

    val ans = sum
    println(ans)
}


//val rd = debug.Reader("agc", "009", "a", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListIntCols: (Int) -> List<List<Int>> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val readListLongCols: (Int) -> List<List<Long>> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 70720
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N, T;

void solve(){
	int ans = INF;
	while(N--){
		int c, t;
		cin >> c >> t;
		if(t <= T)
			chmin(ans, c);
	}
	if(ans == INF)
		cout << "TLE" << endl;
	else
		cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
#define MAX 1005

int h, w, n;
char city[MAX][MAX];
struct node{
	int x,y,time;
} start;
int direc1[4] = { -1,0,1,0 }, direc2[4] = { 0,1,0,-1 };
map<int,int>visited;

void dfs(char end) {
	queue<node> que;
	que.push(start);
	visited[start.x*w+start.y]=1;
	int nextx,nexty;
	while (que.size()!=0)
	{
		node now=que.front();
		que.pop();
		for (int i = 0; i < 4; i++) {
			nextx=now.x + direc1[i];
			nexty=now.y+direc2[i];
			if (nextx >= 0 && nextx< h&&nexty>= 0 && nexty < w && city[nextx][nexty]!='X' && !visited[nextx*w+nexty]) {	

				if (city[nextx][nexty]==end)
				{
					start.x=nextx;
					start.y=nexty;
					start.time=now.time+1;
					return ;
				}
				else{
					visited[nextx*w+nexty]=1;
					node now1;
					now1.x=nextx;
					now1.y=nexty;
					now1.time=now.time+1;
					que.push(now1);
				}
			}
		}
	}

}



int main() {
	cin >> h >> w >> n;	
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> city[i][j];
			if (city[i][j] == 'S') {
				start.x= i;
				start.y = j;
				start.time=0;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		visited.clear();
		dfs(i+'1');
	}
	cout << start.time << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 23360
#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<(int)to; ++i)
#define REP(i, from, to) for(int i=from; i<=(int)to; ++i)
using namespace std;
static const int INF = INT_MAX;
static const int MAX_N = 100010;
vector<vector<int>> g; //隣接リストによるグラフ表現
vector<int> dist_1, dist_N; //dist_1[i]: 頂点1から頂点iへの距離
bool vis[MAX_N]; //vis[i]: 頂点iは訪問済(1)か否(0)か
int n;
void bfs(int start, vector<int>& dist) {
	fill(all(dist), INF);
	fill(vis, vis + MAX_N, false);
	dist[start] = 0;
	queue<int> que;
	que.push(start);
	while (!que.empty()) {
		int now = que.front();
		que.pop();
		vis[now] = true;
		rep(i,0,g[now].size())
		{
			int next = g[now][i];
			if (!vis[next]) {
				dist[next] = dist[now] + 1;
				que.push(next);
			}
		}
	}

}
void solve() {
	cin >> n;
	g = vector<vector<int> >(n + 1, vector<int>());
	dist_1 = vector<int>(n + 1);
	dist_N = vector<int>(n + 1);
	rep(i,0,n-1)
	{
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	bfs(1, dist_1);
	bfs(n, dist_N);
	int fennec = 0, sunuke = 0;
	REP(i,1,n)
	{
		if (dist_1[i] <= dist_N[i]) {
			fennec++;
		} else {
			sunuke++;
		}
	}
	cout << (fennec > sunuke ? "Fennec" : "Snuke") << endl;
}
int main() {
	solve();
}


Measured memory_bytes: 6656
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int total = 0;

        for(int i=1; i<=num; i++){
            if (i < a) continue;
            String line = String.valueOf(i);
            char[] charline = line.toCharArray();
            int sum = 0;
            for(char j: charline){
                String k = String.valueOf(j);
                int s = Integer.parseInt(k);
                sum += s;
            }
            if (sum >= a && sum <= b){
                total += i;
            }
        }

        System.out.println(total);
    }
}


Measured memory_bytes: 24276
fun main(args: Array<String>) {
    val (N, A, B, C) = listOfInt()
    val L = (0 until N).map { nextInt() }
    var ans = Int.MAX_VALUE
    fun calc(V: IntArray) {
        var mp = 0
        val abc = Array(4) { 0 }
        for (n in 0 until N) {
            if (V[n] == 3) continue
            if (abc[V[n]] > 0) mp += 10
            abc[V[n]] += L[n]
        }
        mp += Math.abs(abc[0] - A) + Math.abs(abc[1] - B) + Math.abs(abc[2] - C)
        if (abc[0] > 0 && abc[1] > 0 && abc[2] > 0) ans = Math.min(ans, mp)
    }
    fun dfs(d: Int, v: IntArray) {
        if (d == N) calc(v)
        else for (n in 0 until 4) {
            v[d] = n
            dfs(d + 1, v)
        }
    }
    dfs(0, IntArray(N))
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

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

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

    vector<int> divided = {64, 32, 16, 8, 4, 2, 1};
    for(size_t i = 0; i < divided.size(); i++){
        if(n >= divided[i]){
            cout << divided[i] << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back
#define pp pair<int,int>
#define rep(i,l,r) for(int i=l;i<r;i++)
int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt.txt","r",stdin);
	// freopen("output.txt.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	vi a(n),b(n),c(n);
	rep(i,0,n) cin>>a[i]>>b[i]>>c[i];
	int dp[n][3];
	rep(i,0,n)
	{
		if(i==0)
		{
			dp[i][0] = a[i],dp[i][1] = b[i],dp[i][2] = c[i];
		}
		else
		{
			dp[i][0] = max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
			dp[i][1] = max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
			dp[i][2] = max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));


}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const int N=1010;
// const LL INF=1e18;
LL A[N][3], dp[N][N][3];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n,m;
    cin >> n >> m;
    REP(i,n) REP(j,3) cin >> A[i][j];

    LL ans=0;
    REP(mask, 8) {
        vector<LL> v;
        REP(i,n) {
            LL a=0;
            REP(j,3) {
                if(mask>>j&1) a+=A[i][j]*-1;
                else a+=A[i][j];
            }
            v.push_back(a);
        }
        sort(ALL(v));

        LL res=0;
        REP(i,m) res+=v[n-i-1];
        chmax(ans, res);
    }
    cout << ans << '\n';
    return 0;
}

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

int main()
{
	int N, W;
	cin >> N >> W;
	vector<long long> dp(W+1, 0);
	for (int i = 0; i < N; ++i)
	{
		long long w, v;
		cin >> w >> v;
		for (int w_old = W - w; w_old >= 0; w_old--)
			dp[w_old+w] = max(dp[w_old+w], dp[w_old]+v);
	}
	cout << *max_element(dp.begin(), dp.end());
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,K;
  cin >> N >> K;
  vector<ll> h;
  ll t;
  ll ans=1000000001;
  for(int i=0;i<N;i++){
    cin >> t;
    h.push_back(t);
  }
  sort(h.begin(),h.end());
  for(int i=0;i<N-K+1;i++){
    ll x=h[K+i-1]-h[i];
    ans=min(ans,x);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
string s;
int main(){
  cin >> s;
  bool can=true;
  for (size_t i = 0; i < 3; i++) {
    if(s[i] == s[i+1]) can =false;
  }
  cout << (can ? "Good":"Bad");
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

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

    LL ans = k;
    REP(i, n-1){
        ans = ans * (k - 1);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main() {
    int n[3];

    REP(i, 3) cin >> n[i];

    REP(i, 3) {
        REP(j, 2 - i) {
            if (n[j] > n[j + 1]) swap(n[j], n[j + 1]);
        }
    }

    cout << n[0];
    REP(i, 2) cout << ' ' << n[i + 1];
    cout << endl;

    return 0;
}

Measured memory_bytes: 3072
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		//?????°?¨????
		int num = 0; //??\??????????????°???????´???¨
		Deque<Integer> stac = new ArrayDeque<Integer>(); //??????????????????
		
		while(sc.hasNext()) {
			//??\????????????????????°??????1???????????????
			num = sc.nextInt();
			
			if(num == 0) { //??°??????0?????¨???
				System.out.println(stac.peekLast()); //??¨?????????
				stac.pollLast(); //????????????????????????
			} else {
				//?????????????????????
				stac.add(num);
			}
		}

	}

}

Measured memory_bytes: 26088
#include <stdio.h>
#include <stdint.h>
typedef int64_t i64;

int main(void){
    i64 n, sum = 0;
    scanf("%lld", &n);
    for(i64 i=1; i<=n; i++) sum += (i + (n/i)*i)*(n/i)/2;
    printf("%lld", sum);
    return 0;
}

Measured memory_bytes: 1692
/*
 Input
 1sÚ ¶kÌni®j
 2sÚ 1lÚÌg·iÀF¬æ1ÊÜÅj
 3sÚ 2lÚÌg·iÀF¬æ1ÊÜÅj
 F
 n+1sÚ nlÚÌg·iÀF¬æ1ÊÜÅj
 Output
 1sÚ ©oµu1:vÉÂÃ¢Ä165.0cm¢ÌlªÌ*i¼pj
 2sÚ ©oµu2:vÉÂÃ¢Ä165.0cmÈã`170.0cm¢ÌlªÌ*i¼pj
 3sÚ ©oµu3:vÉÂÃ¢Ä170.0cmÈã`175.0cm¢ÌlªÌ*i¼pj
 4sÚ ©oµu4:vÉÂÃ¢Ä175.0cmÈã`180.0cm¢ÌlªÌ*i¼pj
 5sÚ ©oµu5:vÉÂÃ¢Ä180.0cmÈã`185.0cm¢ÌlªÌ*i¼pj
 6sÚ ©oµu6:vÉÂÃ¢Ä185.0cmÈãÌlªÌ*i¼pj
*/

#include <cstdio>

int main(void)
{
    int number;
    scanf("%d", &number);
    
    int data[6];
    for (int i = 0; i < 6; i++){
        data[i] = 0;
    }
    
    while(number != 0){
        float tmp;
        scanf("%f", &tmp);
        if (tmp < 165.0){
            data[0]++;
        }
        else if (tmp < 170){
            data[1]++;
        }
        else if (tmp < 175){
            data[2]++;
        }
        else if (tmp < 180){
            data[3]++;
        }
        else if (tmp < 185){
            data[4]++;
        }
        else {
            data[5]++;
        }
        number--;
    }
    
    for (int i = 0; i < 6; i++){
        printf("%d:", i + 1);
        while (data[i] != 0){
            printf("*");
            data[i]--;
        }
        printf("\n");
    }
    
    return (0);
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void){

  int i;
  char a;

  scanf("%c", &a);

  if((a>= 'a') && (a<='z')){
    printf("a\n");
  }
  if ((a>= 'A') && (a<='Z')){
    printf("A\n");
  }
  return 0;
}


Measured memory_bytes: 1568
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

vi h(100010);
vector<long long> dp(100010);
int N, K;

long long int dfs(int k) {

	if (k >= N)return INFL;
	if (k >= N - 1)return 0;

	if (dp[k] < INFL)return dp[k];

	REP(i, K) {
		dp[k] = min(dp[k], dfs(k + i + 1) + abs(h[k + i + 1] - h[k]));
	}

	return dp[k];
}


int main() {




	cin >> N >> K;

	REP(i, N)cin >> h[i];

	REP(i, N)dp[i] = INFL;

	
	cout << dfs(0) << endl;

	return 0;
}

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

const int maxn = 1010;
int n, a[maxn];

int main() {
    scanf("%d", &n);
    bool flag = 1;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        if (a[i] >= 0) flag = 0;
    }
    if (flag) {
        int mx = INT_MIN, pos;
        for (int i = 1; i <= n; i++) {
            if (a[i] > mx) mx = a[i], pos = i;
        }
        vector<int> ans;
        for (int i = n; i > pos; i--) {
            ans.push_back(i);
        }
        for (int i = pos - 1; i; i--) {
            ans.push_back(1);
        }
        printf("%d\n%d\n", mx, ans.size());
        for (int x : ans) printf("%d\n", x);
        exit(0);
    }
    auto solve = [&](int x) {
        long long sum = 0;
        vector<int> S, ans;
        for (int i = x; i <= n; i += 2) {
            if (a[i] >= 0) sum += a[i], S.push_back(i);
        }
        for (int i = n; i > S.back(); i--) {
            ans.push_back(i);
        }
        for (int i = (int)S.size() - 2; ~i; i--) {
            for (int j = (S[i] + S[i + 1]) / 2; j > S[i]; j--) {
                ans.push_back(j);
            }
        }
        for (int i = S[0] - 1; i; i--) {
            ans.push_back(1);
        }
        return make_pair(sum, ans);
    };
    auto p1 = solve(1), p2 = solve(2);
    if (p1.first < p2.first) swap(p1, p2);
    printf("%lld\n%d\n", p1.first, p1.second.size());
    for (int x : p1.second) printf("%d\n", x);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <math.h>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
string a,s;
int i;
int main() {
	cin >> a;
	while (true)
	{
		if (*(a.end()-1)=='m'&&a.size()>=5)
		{
			i++;
			s = a.substr(a.size() - 5);
			if (s == "dream")
			{
				for (size_t i = 0; i < 5; i++)
				{
					a.pop_back();
				}
			}
			else {
				cout << "NO" << endl; goto p;
			}
		}
		else 	if (*(a.end()-1) == 'e'&&a.size() >= 5)
		{
			s = a.substr(a.size() - 5);
			if (s == "erase")
			{
				for (size_t i = 0; i < 5; i++)
				{
					a.pop_back();
				}
			}
			else
			{
				cout << "NO" << endl; goto p;
			}
		}
		else if (*(a.end() - 1) == 'r'&&a.size() >= 6)
		{
			s = a.substr(a.size() - 6);
			if (s == "eraser")
			{
				for (size_t i = 0; i < 6; i++)
				{
					a.pop_back();
				}
			}
			else  if (s == "reamer"&&a.size() >= 7) {
				if (*(a.end() - 7) == 'd')
				{
					for (size_t i = 0; i < 7; i++)
					{
						a.pop_back();
					}
				}
				else
				{

					cout << "NO" << endl; goto p;
				}
			}
			else {
				cout << "NO" << endl; goto p;
			}
		}
		if (a.size() == 0) { cout << "YES" << endl; goto p; }
	}
	p:
	return 0;
}

Measured memory_bytes: 512
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    cout<<"ABC"<<s<<"\n";
;}


Measured memory_bytes: 256
h,w = map(int, input().split())
l = [input() for _ in range(h)]
l.insert(0,'#'*(w+2))
l.append('#'*(w+2))

for i in range(1,h+1):
    l[i] = '#' +l[i] + '#'

for j in range(h+2):
    print(l[j])


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

int main(){
	int m,nmax,nmin;
	while(cin >> m >> nmin >> nmax , m){
		int num[210];
		for(int i=0;i<m;i++){
			cin >> num[i];
		}
		sort(num,num+m,greater<int>() );
		int mgap=-1;
		int ans = 0;
		for(int i=nmax;i>=nmin;i--){
			if(num[i-1]-num[i] > mgap){
				mgap = num[i-1] - num[i];
				ans = i;
			}
		}
		cout << ans << endl;
	}
}

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

int main()
{
  string S;
  cin>>S;
  set<char> st;
  for(int i=0;i<S.size();i++){
    st.insert(S[i]);
  }
  cout<<( (S.size()==st.size())? "yes":"no");
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        System.out.println(Math.min(A, B) + " " + Math.max(Math.min(A, B) - (N - Math.max(A, B)), 0));
    }
}

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

int main(void)
{
    long long int a,b,c,i,j,k,n;

    cin >> a;


    switch(a){
        case 25:
        cout << "Christmas";
        break;
        case 24:
        cout << "Christmas Eve";
        break;
        case 23:
        cout << "Christmas Eve Eve";
        break;
        case 22:
        cout << "Christmas Eve Eve Eve";
        break;
    }

    return 0;
}


Measured memory_bytes: 256
S = input()
n = len(S)
ans = [0] * n

check = 'R'
index = 0
num = 0
S = S+'R'
for i in range(n+1):
    if S[i] == check:
        num += 1
    else:
        if check == 'R':
            ans[i-1] += num // 2 + num % 2
            ans[i] += num // 2
            index = i
        else:
            ans[index-1] += num // 2
            ans[index] += num // 2 + num % 2
        check = S[i]
        num = 1

print(*ans)


Measured memory_bytes: 6400
//Priyanshu Kumar : IIIT Allahabad
#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define MAX 100005
#define MOD 1000000007
#define sz size()
#define ln length()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) printf("%d",n)
#define pin(n) printf("%d\n",n);
#define pl(n) printf("%lld",n)
#define pln(n) printf("%lld\n",n);
#define FUCK_YEAH ios_base::sync_with_stdio(false);cin.tie(NULL)
inline ll gcd(ll x,ll y){return x%y==0?y:gcd(y,x%y);}
inline ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
inline ll powmod(ll a,ll b,ll mod) 
{
	ll res=1;
	a%=mod; 
	assert(b>=0); 
	for(;b;b>>=1)
	{
		if(b&1)res=res*a%mod;
		a=a*a%mod;
	}
	return res;
}
inline ll mulmod(ll a, ll b, ll c)
{
	if(!b)return 0;
	ll x = mulmod(a, b/2, c);
	if (b & 1)return (x+x+a)%c;
	return (x+x)%c;
}

int main()
{
	FUCK_YEAH;
	ll n;
	cin >> n;
	n = 48 - n;
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
import bisect
import collections
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

N,M,Q = map(int,(input().split()))
s = [[0]*(N+1) for _ in range(N+1)]
L = [0]*M
d = defaultdict(int)
for i in range(M):
    L,R = map(int,(input().split()))
    d[(L,R)] += 1
for i in range(1,N+1):
    for j in range(1,N+1):
        s[i][j] = s[i][j-1] + d[(i,j)]
for i in range(Q):
    p,q = map(int,(input().split()))
    ans = 0
    for j in range(p,q+1):
        ans += s[j][q]-s[j][p-1]
    print(ans)

Measured memory_bytes: 90960
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

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

  vector<int> lef(N+2,0),rig(N+2,0);
  for(int i=0;i<N;i++){
    lef[i+1]=max(lef[i],A[i]);
  }
  for(int i=N-1;i>=0;i--){
    rig[i]=max(rig[i+1],A[i]);
  }

  vector<int> ans;
  for(int i=0;i<N;i++){
    ans.push_back(max(lef[i],rig[i+1]));
  }
  for(int i=0;i<N;i++) cout<<ans[i]<<endl;


  return 0;
}


Measured memory_bytes: 4852
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define si set<int>
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define sq(x) ((x) * (x))
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    cout << (1000 - n % 1000) % 1000 << endl;
    GAME_OVER;
}

Measured memory_bytes: 3616
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>

using namespace std;

int N;
vector<long double> A;
void solve() {
	cin >> N;
	A.resize(N);
	for (int n = 0; n < N; n++)cin >> A[n];
	long double s = 0, e = 1e14;
	while (e - s > 1e-6) {
		long double x0 = (e + s) / 2;
		long double x = x0;
		for (int n = 0; n < N - 1; n++)x = A[n] - x;
		if (A[N - 1] < x + x0)e = x0;
		else s = x0;
	}
	vector<int> x;
	x.resize(N);
	x[0] = (int)round(s);
	for (int n = 1; n < N; n++)x[n] = A[n - 1] - x[n - 1];
	for (int n = 0; n < N; n++) {
		cout << 2*x[n] << endl;
	}
	return;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>

using namespace std;
int main()
{
	int n;
	long long sum[200010], a;
	cin >> n;
	sum[0] = 0;
	for(int i=1; i<=n; i++){
		cin >> a;
		sum[i] = sum[i-1] + a;
	}
	sort(sum,sum+n+1);
	long long ans = 0;
    long long now = sum[0];
  	long long cnt = 1;
	for(int i=1; i<=n; i++){
		if(now == sum[i]){
			cnt++;
		}
		else{
			ans += (cnt * (cnt-1)) / 2;
			now = sum[i];
			cnt = 1;
		}
	}
	cout << ans + (cnt * (cnt-1)) / 2 << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
using namespace std;

int main() {
  int n;
  int count=0;
  cin >> n;
  for(int k=1;k<=n; k+=2) {
    int c=0;
    for(int i=1;i<=k;i++) {
      if(k%i==0) c++;
    }
    if(c==8) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import time
import random


class TreapNode:
    def __init__(self, key, pri):
        self.left = None
        self.right = None
        self.key = key
        self.pri = pri


class Treap:
    def __init__(self):
        self.root = None

    def search_lower(self, key):
        if key == None:
            return None
        ptr = self.root
        ret = None
        while ptr is not None:
            pk = ptr.key
            if pk < key:
                ret = pk
                ptr = ptr.right
            else:
                ptr = ptr.left
        return ret

    def search_higher(self, key):
        if key == None:
            return None
        ptr = self.root
        ret = None
        while ptr is not None:
            pk = ptr.key
            if pk > key:
                ret = pk
                ptr = ptr.left
            else:
                ptr = ptr.right
        return ret

    def insert(self, key):
        pri = random.randrange(0, 2**10)
        ptr = self.root
        elem = TreapNode(key, pri)
        if ptr is None or ptr.pri < pri:
            self.root = elem
        else:
            while True:
                if key < ptr.key:
                    left = ptr.left
                    if left is None or left.pri < pri:
                        ptr.left = elem
                        ptr = left
                        break
                    ptr = left
                else:
                    right = ptr.right
                    if right is None or right.pri < pri:
                        ptr.right = elem
                        ptr = right
                        break
                    ptr = right
        left = elem
        right = elem
        while ptr is not None:
            if key < ptr.key:
                right.left = ptr
                right = ptr
                ptr = ptr.left
            else:
                left.right = ptr
                left = ptr
                ptr = ptr.right
        left.right = None
        right.left = None
        elem.left, elem.right = elem.right, elem.left

# デバッグ用
    def dump(self):
        self.__dump(self.root, 0)

    def __dump(self, idx, dep):
        if idx is not None:
            self.__dump(idx.right, dep + 1)
            for _ in range(0, dep):
                print("   ", end="")
            print([idx.key, idx.pri])
            self.__dump(idx.left, dep + 1)

def main():
    n = int(input())
    p = list(map(int, input().split()))
    idx = [0] * n
    for i in range(0, n):
        idx[i] = i
    idx.sort(key=lambda i: - p[i])
    t = Treap()
    t.insert(-1)
    t.insert(n)
    ans = 0
    for i in idx:
        nex = t.search_higher(i)
        nexnex = t.search_higher(nex)
        pre = t.search_lower(i)
        prepre = t.search_lower(pre)
        if prepre != None:
            ans += p[i] * (pre - prepre) * (nex - i)
        if nexnex != None:
            ans += p[i] * (i - pre) * (nexnex - nex)
        t.insert(i)
    print(ans)


main()


Measured memory_bytes: 83944
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		long a;
		long b;

		while(sc.hasNext()) {
			a = sc.nextInt();
			b = sc.nextInt();

			System.out.println(gcd(a, b) + " " + lcm(a, b));
		}
	}

	public static long gcd(long a, long b) {
		long gcd = a;
		while(b % a != 0) {
			gcd = b % a;
			b = a;
			a = gcd;
		}
		return gcd;
	}

	public static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}


}

Measured memory_bytes: 25976
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<vector<i64>> A(N, vector<i64>(N));
    vector<vector<bool>> used(N, vector<bool>(N, true));
    priority_queue<tuple<i64, int, int>> p;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            cin >> A[i][j];
            p.emplace(A[i][j], i, j);
        }
    }
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if(A[i][j] > A[i][k] + A[k][j]) {
                    cout << -1 << endl;
                    return 0;
                }
                if (A[i][j] == A[i][k] + A[k][j] && used[i][j]) {
                    used[i][j] = used[j][i] = false;
                    used[i][k] = used[k][i] = true;
                    used[k][j] = used[j][k] = true;
                }
            }
        }
    }
    i64 sum = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            if(used[i][j]) {
                sum += A[i][j];
            }
        }
    }
    cout << sum / 2 << endl;
    return 0;
}


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


int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int cnt =0;
    for(int i=A; i<=B-1; i++){
        if(i>= C && i<= D-1) cnt++;
    }
    cout << cnt << endl;
}   

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	var l0, l1, l2 int64
	l0, l1, l2 = 2, 1, 3
	if n < 2 {
		if n == 0 {
			fmt.Println(l0)
		} else {
			fmt.Println(l1)
		}
		return
	}

	for i := 0; i < n-2; i++ {
		l0, l1 = l1, l2
		l2 = l1 + l0
	}
	fmt.Println(l2)
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  int N;
  int count = 0;
  cin >> N;
  vector<int> d(N);
  rep(i,N)
    cin >> d.at(i);
  
  vector<int> zeros(N,0);
  while(d!=zeros){
  	int max = 0;
  	rep(i,N){
      if(max<d.at(i))
        max = d.at(i);
  	}
	rep(i,N){
      if(d.at(i)==max)
        d.at(i) = 0;
    }
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
template<class T>inline bool chmax(T& a, T b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T& a, T b){if(a > b){a = b; return 1;}return 0;}
const ll INF = 1LL<<60;
const int dy[4] = {0, 1, 0, -1};
const int dx[4] = {1, 0, -1, 0};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

queue<pair<ll, ll>> que;
ll h, w; 

void bfs(vector<string>& vs, vector<vector<ll>>& seen){
    ll nowy, nowx;
    if(!que.empty()){
        nowy = que.front().fi, nowx =que.front().se;
        que.pop();
    }
    else{
        cout << -1 << endl;
        exit(0);
    }
    if(nowy == h-1 && nowx == w-1){
        return;
    }
    ll ncnt = seen[nowy][nowx];
    for(int i=0; i<4; i++){
        ll nxty = nowy + dy[i], nxtx = nowx + dx[i];
        //cout << seen << endl;

        if(nxty >= 0 && nxty < h && nxtx >= 0 && nxtx < w){
            //cout << nxty << ' ' << nxtx << 'z' << endl;
            if(vs[nxty][nxtx] == '.' && seen[nxty][nxtx] == -1){
                seen[nxty][nxtx] = ncnt+1;
                //else seen[nxty][nxtx] = min(ncnt+1, seen[nxty][nxtx]);
                que.push({nxty, nxtx});
            }
        }
    }
    bfs(vs, seen); 
}

void solve(){
    cin >> h >> w;
    vector<string> vs;
    REP(i, h){
        string s; cin >> s;
        vs.pb(s);
    }
    ll bcnt = 0;
    REP(i, h){
        REP(j, w){
            if(vs[i][j] == '#') bcnt++;
        }
    }
    vector<vector<ll>> seen(h, vector<ll>(w, -1));
    que.push({0, 0});
    seen[0][0] = 1;
    bfs(vs, seen);
    ll saitan = seen[h-1][w-1];
    cout << h*w - saitan - bcnt << endl;
}

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

Measured memory_bytes: 3900
package main

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

func main() {
	sc := NewScanner()
	a := sc.NextInt()
	b := sc.NextInt()
	c := sc.NextInt()
	if a%2 != 0 || b%2 != 0 || c%2 != 0 {
		fmt.Printf("%v\n", 0)
		return
	}

	if a == b && b == c {
		fmt.Printf("-1\n")
		return
	}
	ans := 0
	for true {
		if a%2 != 0 || b%2 != 0 || c%2 != 0 {
			fmt.Printf("%v\n", ans)
			return
		}
		ta := a
		tb := b
		tc := c
		a = tb/2 + tc/2
		b = ta/2 + tc/2
		c = ta/2 + tb/2
		ans++
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main(){
   int n, a,b,c,d;
   cin >> n >> a >> b >> c >> d;

   bool isGotoA = true, isGotoB = true, isSkip = false;

   int* map = new int[n];
   char ch;
   for(int i=0;i<n;i++){
      cin >> ch;
      map[i] = ch == '#' ? 1 : 0;
   }

   int scont = 0;
   for(int i=a;i<c;i++){
      if(map[i]){
         scont++;
         if(scont >= 2){
            isGotoA = false;
            break;
         }
      }
      else{
         scont=0;
      }
   }

   scont = 0;
   for(int i=b;i<d;i++){
      if(map[i]){
         scont++;
         if(scont >= 2){
            isGotoB = false;
            break;
         }
      }
      else{
         scont=0;
      }
   }

   scont = 0;
   for(int i=b-2;i<=d;i++){
      if(map[i]){
         scont = 0;
      }
      else{
         scont++;
         if(scont>=3){
            isSkip = true;
            break;
         }
      }
   }

   bool ans = c < d ? isGotoA & isGotoB : isGotoA & isGotoB & isSkip;
   cout << (ans ? "Yes" : "No") << endl;
}

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

int n;
string s;
int res = 0;

int main(){
  cin >> n >> s;
  for(int i = 1; i < n; i++){
    string a = s.substr(0, i);
    string b = s.substr(i, n - i);
    //cerr << a << " "<< b<< endl;
    int la = a.size(), lb = b.size();
    bool cha[30], chb[30];
    rep(i, 30){
      cha[i] = false; chb[i] = false;
    }
    rep(i, la){
      cha[a.at(i) - 'a'] = true;
      //cerr << a.at(i) - 'a' << endl;
    }
    rep(i, lb){
      chb[b.at(i) -'a'] = true;
    }
    int ans = 0;
    rep(i, 30){
      if(cha[i] && chb[i]){
        ans++;
      }
    }
    cerr << ans << endl;
    res = max(ans, res);
      
  }
  cout << res << endl;
  return 0;
}

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

void insertionsort(vector<int>& a, int n, int g, int &count) {
  for(int i = g;i < n;i++){
    int v = 0;
    v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j + g] = a[j];
      j = j - g;
      count++;
    }
    a[j + g] = v;
  }
}

void shellsort(vector<int>& a, int n, vector<int>& g, int &m, int &count){
  int i = 0;
  while(3 * i + 1 <= n){
    i = 3 * i + 1;
    g.push_back(i);
  }
  reverse(g.begin(), g.end());
  m = g.size();
  for (int j = 0;j < m;j++) {
    insertionsort(a, n, g[j], count);
  }
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
      cin >> a[i];
    }
    vector<int> g(0);
    int m;
    int count;
    shellsort(a, n, g, m, count);
    cout << m << endl;
    for(int i = 0;i < m;i++){
      cout << g[i];
      if(i != m - 1){
        cout << " ";
      }
    }
    cout << endl << count << endl;
    for(int i = 0;i < n;i++){
      cout << a[i] << endl;
    }
}



Measured memory_bytes: 6692