akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{

		var input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int L = input[0];
		int R = input[1];
		int ans = 0;
		int f = R - L;
		int rL = L % 2019;
		int rR = R % 2019;

		List<int> r = new List<int>();
		if (L % 2019 == 0 || R % 2019 == 0)
		{
			ans = 0;
		}
		else if (f >= 2018)
		{
			ans = 0;
		}
		else if(rL<=rR)
		{
           for(var i = rL; i < rR; i++)
			{
                for(var j = i + 1; j <= rR; j++)
				{
					r.Add((i * j) % 2019);
				}
			}
			r.Sort();
			ans = r[0];
		}
		else
		{
			ans = 0;
		}
		Console.WriteLine(ans);

		

	}
}

//var input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
//入力用

public class Calculation //各種値の計算メソッド
{
	public int GetGcd(int a, int b) //最大公約数(２数)
	{
		if (a * b == 0)
		{
			return 0;
		}
		if (a < b)
		{
			int c = a;
			a = b;
			b = c;
		}

		int r = a % b;
		while (r > 0)
		{
			a = b;
			b = r;
			r = a % b;
		}
		return b;
	}
	public int GetGcdOfSortedArray(int[] array) //最大公約数(ソート済み数列)
	{
		if (array.Length == 0) { return 1; }
		else if (array.Length == 1) { return array[0]; }
		else
		{
			int n = 0;
			int g = -1;
			while (n <= array.Length - 2)
			{

				int a = array[n + 1];
				int b = array[n];
				int r = a % b;
				while (r > 0)
				{
					a = b;
					b = r;
					r = a % b;
				}
				g = b;
				array[n + 1] = g;
				n++;
			}

			return g;

		}
	}
	public long GetGcdOfSortedArrayL(long[] array) //最大公約数(ソート済み配列[long型])
	{
		if (array.Length == 0) { return 1; }
		else if (array.Length == 1) { return array[0]; }
		else
		{
			int n = 0;
			long g = -1;
			while (n <= array.Length - 2)
			{

				long a = array[n + 1];
				long b = array[n];
				long r = a % b;
				while (r > 0)
				{
					a = b;
					b = r;
					r = a % b;
				}
				g = b;
				array[n + 1] = g;
				n++;
			}

			return g;

		}
	}

	public long GetNCR(int n, int r) //二項係数(生の値)
	{
		if (n == 1) { return 1; }
		long[] nC = new long[n + 1];
		nC[0] = 1;
		for (var i = 0; i <= r - 1; i++)
		{
			nC[i + 1] = nC[i] * (n - i) / (i + 1);
		}
		return nC[r];
	}


}

class Modulo //1000000007で割る問題用
{
	private const int M = 1000000007;
	private readonly int[] m_facs;
	public int Mul(int a, int b) //掛け算
	{
		return (int)(Math.BigMul(a, b) % M);
	}
	public Modulo(int n)
	{
		m_facs = new int[n + 1];
		m_facs[0] = 1;
		for (int i = 1; i <= n; ++i)
		{
			m_facs[i] = Mul(m_facs[i - 1], i);
		}
	}
	public int Fac(int n)
	{
		return m_facs[n];
	}
	public int Pow(int a, int m) //累乗
	{
		switch (m)
		{
			case 0:
				return 1;
			case 1:
				return a;
			default:
				int p1 = Pow(a, m / 2);
				int p2 = Mul(p1, p1);
				return ((m % 2) == 0) ? p2 : Mul(p2, a);
		}
	}
	public int Div(int a, int b) //除算
	{
		return Mul(a, Pow(b, M - 2));
	}
	public int Ncr(int n, int r) //二項係数
	{
		if (n < r) { return 0; }
		if (n == r) { return 1; }
		int res = Fac(n);
		res = Div(res, Fac(r));
		res = Div(res, Fac(n - r));
		return res;
	}
	public Modulo() { }
}





Measured memory_bytes: 27232
#include<iostream>
using namespace std;
int main(){
	int a,b,c,x;
	cin>>a>>b>>c;
	if(b>c){
		x=b;
		b=c;
		c=x;
	}
	if(a>b){
		x=a;
		a=b;
		b=x;
	}
	if(b>c){
		x=b;
		b=c;
		c=x;
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

const int INF = 1 << 30;

struct Edge {
    int to; int cap; int rev;
    Edge(int t, int c, int r) : to(t), cap(c), rev(r) {}
};

struct Flow {
    vector <vector<Edge>> G;
    vector<bool> used;
    Flow(int n) : G(n), used(n, false) {}
    void add_edge(int from, int to, int cap) {
        G[from].push_back(Edge(to, cap, G[to].size()));
        G[to].push_back(Edge(from, 0, G[from].size() - 1));
    }
    int dfs(int v, int t, int f) {
        if (v == t) return f;
        used[v] = true;
        for (int i = 0; i < G[v].size(); i++) {
            Edge &e = G[v][i];
            if (!used[e.to] && e.cap > 0) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    int max_flow(int s, int t) {
        int flow = 0;
        while (1) {
            fill(used.begin(), used.end(), false);
            int f = dfs(s, t, INF);
            if (f == 0) return flow;
            flow += f;
        }
    }
};

int main() {
    int H, W;
    cin >> H >> W;

    Flow fl(H+W+2);
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++) {
            if (s[j] == 'S') {
                fl.add_edge(H+W, i, INF);
                fl.add_edge(H+W, H+j, INF);
            } else if (s[j] == 'T') {
                fl.add_edge(i, H+W+1, INF);
                fl.add_edge(H+j, H+W+1, INF);
            } else if (s[j] == 'o') {
                fl.add_edge(i, H+j, 1);
                fl.add_edge(H+j, i, 1);
            }
        }
    }

    int ret = fl.max_flow(H+W, H+W+1);
    if (ret >= INF) ret = -1;

    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	int c=0;
	for(int i=a;i<=b;i++){
		if(i/10000==i%10){
			if(i/1000-(i/10000)*10==(i%100)/10){
				c++;
			}
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 256
my ($n, $m, $k) = split / /, <STDIN>;

for(my $p = 0; $p <= $m; $p++){
    for(my $q = 0; $q <= $n; $q++){
        if($p * $n + $q * $m - 2 * $p * $q == $k){
            print "Yes";
            exit;
        }
    }
}
print "No";
exit;

Measured memory_bytes: 512
N = gets.to_i
xm,xM,ym,yM=2e9,0,2e9,0
XY = []

N.times do |i|
  a = gets.split.map &:to_i
  x, y = a.minmax
  XY << [x, y]
  xm = [x, xm].min
  xM = [x, xM].max
  ym = [y, ym].min
  yM = [y, yM].max
end
XY.sort!

k, l, yl = 2e9, XY[-1][0], 2e9;
N.times do |i|
  x, y = XY[i]
  if x > yl
      k = [k, l - yl].min
      break
  end
  yl = [yl, y].min
  k = [k, l - x].min
  l = [l, y].max
end

p [(yM - ym) * (xM - xm), (yM - xm) * k].min


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

using namespace std;

#define MN 10001

int arr[MN];

int main(){
    int n;
    cin >>n;
    for(int i=1;i<MN;i++){
        int r=i*i;
        if(r>n)break;
        for(int j=1;j<=i;j++){
            int r1=r+j*j;
            if(r1>n)break;
            for(int k=1;k<=j;k++){
                int r2=r1+k*k+i*j+j*k+k*i;
                if(r2<=n){
                    arr[r2]+=6;
                    if(i==k||k==j||i==j){
                        arr[r2]-=3;
                        if(i==k&&j==i){
                            arr[r2]-=2;
                        }
                    }

                }else break;
            }
        }
    }
    for(int i=1;i<=n;i++)
        cout <<arr[i]<<endl;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int i,c=0;
 	string s,a;
 	cin>>s>>a;
 	for(i=0;i<3;i++)
 		{
 			if(s[i]==a[i])
 				c++;
		 }
 	cout<<c<<endl;
	 	  	
 	return 0;
}
 	
 					

Measured memory_bytes: 3508
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<string> vs(n);
  for(Int i=0;i<n;i++) cin>>vs[i];
  map<string, Int> cnt;
  Int ans=0;
  for(auto s:vs){
    sort(s.begin(),s.end());
    ans+=cnt[s];
    cnt[s]++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

#include <vector>
#include <queue>
#include <climits>
using edge_to = std::pair<long long, long long>;	// {weight, to}
using edge = std::vector<long long>;				// {weight, from, to}

/*	verified : 2020/07/17
		AOJ, Single Source Shortest Path
		http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
*/

std::vector<edge> edges(0); // 選んだ順に辺を格納　逆順に辿って経路復元
std::vector<long long> dijkstra(
	long long V,
	//long long E,
	long long r,
	std::vector<std::vector<edge_to>>& adj_list
) {
	std::vector<long long> ret(V, LLONG_MAX);
	ret[r] = 0;
	using P = std::pair<long long, edge>;
	std::priority_queue<P, std::vector<P>, std::greater<P>> pq;
	for (auto i : adj_list[r]) {
		pq.push({i.first, {i.first, r, i.second}});
	}
	while (pq.size()) {
		while (pq.size() && ret[pq.top().second[2]] < LLONG_MAX) pq.pop();
		if (pq.empty()) break;
		long long w = pq.top().first; edge e = pq.top().second;
		pq.pop();
		ret[e[2]] = w;
		edges.push_back(e);
		for (auto i : adj_list[e[2]]) {
			if (ret[i.second] < LLONG_MAX) continue;
			long long next_w = ret[e[2]] + i.first;
			edge next_e = {i.first, e[2], i.second};
			pq.push({next_w, next_e});
		}
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll h, w, sy, sx, gy, gx;
	cin >> h >> w >> sy >> sx >> gy >> gx;
	sy--; sx--; gy--; gx--;
	vector<string> s(h);
	for (ll i = 0; i < h; i++) cin >> s[i];

	auto idx = [&] (ll i, ll j) {return i * w + j;};

	ll n = h * w;
	vector<vector<edge_to>> v(n);
	for (ll i = 0; i < h; i++) {
		for (ll j = 0; j < w; j++) {
			if (s[i][j] == '#') continue;
			ll a = idx(i, j);
			for (ll ii = -2; ii <= 2; ii++) {
				if (i + ii < 0 || h <= i + ii) continue;
				for (ll jj = -2; jj <= 2; jj++) {
					if (j + jj < 0 || w <= j + jj || (ii == 0 && jj == 0) || s[i + ii][j + jj] == '#') continue;
					ll b = idx(i + ii, j + jj), d;
					if (abs(ii) + abs(jj) == 1) d = 0;
					else d = 1;
					v[a].push_back({d, b});
				}
			}
		}
	}

	vector<ll> dist = dijkstra(n, idx(sy, sx), v);
	if (dist[idx(gy, gx)] < INF) cout << dist[idx(gy, gx)] << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 196476
n,m=map(int,input().split())
P=[i-1 for i in list(map(int,input().split()))]

class UnionFind():
    def __init__(self,num):
        self.n = num         #class内変数nに、外部から入力した値numを代入
        self.parents = [-1 for i in range(self.n)]
          #parentsは要素の親(1こ上のやつ)番号0~n-1を格納、自分が最親なら-(要素数)を格納(初期値は-1)

    #xの最親は誰？
    def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x]) #再帰して1番上までいってる
                #調べながらparentsの値を更新してる！（経路圧縮）
            return self.parents[x]

    #結合せよ
    #xの親とyの親をくっつける
    def union(self,x,y):
        xx=self.find(x)  #xxはxの最親
        yy=self.find(y)  #yyはyの最親
        if xx==yy:
            return     #同じ屋根の下にあった場合は何もしない
        else:
            size_xx=abs(self.parents[xx]) #xが含まれる木のサイズ
            size_yy=abs(self.parents[yy]) #yが含まれる木のサイズ
            if size_xx>size_yy:
                xx,yy=yy,xx  #yyの方が大きい木、ってことにする

            self.parents[yy]+=self.parents[xx] #大きい木のサイズ更新
            self.parents[xx]=yy   #サイズが小さい木を大きい木に接ぐ

    #xの属する木の大きさ（まあunionでも使ったけど）
    def size(self,x):
        xx=self.find(x)
        return abs(self.parents[xx])

    #xとyはこの空の続く場所にいますか　いつものように笑顔でいてくれますか　今はただそれを願い続ける
    def same(self,x,y):
        return 1 if self.find(x)==self.find(y) else 0

    #xと　同じ木にいる　メンバーは？
    def members(self,x):
        xx=self.find(x)
        return [i for i in range(self.n) if self.find(i)==xx]
             #ifの条件式に漏れたら無視

    #最親だけを並べあげる
    def roots(self):
        return [i for i,x in enumerate(self.parents) if x < 0]
        #いやこれは天才すぎる、basisのenumerate.py参照

    #すべての最親について、メンバーを辞書で
    def all_group_members(self):
        return {r:self.members(r) for r in self.roots()}

    #グループ分けどうなりましたか、２重リストで
    def state_grouping(self):
        return list(self.all_group_members().values())


uf=UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    uf.union(a,b)
ans=0
for i in range(n):
    ans+= uf.same(i,P[i])
print(ans)

Measured memory_bytes: 20416
if __name__ == '__main__':
    input_list = list(map(int, input().split()))
    H = input_list[0]
    W = input_list[1]
    input_list = list(map(int, input().split()))
    h = input_list[0]
    w = input_list[1]

    answer = H * W - H * w - h * W + h * w

    print(answer)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long t;
int cou;
void DFS(long long n,bool r3,bool r5,bool r7){
	if(n>t){
		return;
	}
	if(r3&&r5&&r7){
		cou++;
	}
	DFS(n*10+3,true,r5,r7);
	DFS(n*10+5,r3,true,r7);
	DFS(n*10+7,r3,r5,true);
}
int main(){
	
	cin>>t;
	cou=0;
	DFS(0,false,false,false);
	cout<<cou<<endl;
}

Measured memory_bytes: 256
package main

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

type TupleInt struct {
	first  int
	second int
}

func main() {
	sc := NewScanner()
	N, X, M := sc.NextInt(), sc.NextInt(), sc.NextInt()

	sm := 0
	mp := map[int]TupleInt{}
	v := X
	sm += v
	mp[v] = TupleInt{sm, 1}
core:
	for i := 2; i <= N; i++ {
		v = v * v

		v %= M
		sm += v
		if a, ok := mp[v]; ok {
			cycle := i - a.second
			k := (N - i) / cycle
			p := sm - a.first
			sm += k * p

			for j := i + cycle*k + 1; j <= N; j++ {
				v = v * v
				v %= M
				sm += v
			}
			break core
		}
		mp[v] = TupleInt{sm, i}
	}
	fmt.Println(sm)

}

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) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

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

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	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: 6068
#include <stdio.h>

int main() {
 	int a, b, c;
  	scanf("%d %d %d", &a, &b, &c);
  	if (a % b == 0) printf("%d\n", a / b * c);
  	else printf("%d\n", (a / b + 1) * c);
  	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug(x)   cerr<<#x<<": "<<x<<endl;
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
typedef long long int ll;
using namespace std;

const ll mod = 1e9+7;





void solve(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    ll total=1;
    ll a=0,  b=0, c=0;
    for(char i:s){
        a+=(i=='R');
        b+=(i=='B');
        c+=(i=='G');
    }
    total=(a*b);
    total=(total*c);
    debug(total);

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(j+j-i < n && s[i] != s[j] && s[j+j-i]!=s[i] && s[j+j-i]!=s[j])total--;
        }
    }
    cout<<total;
}




int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int read() {
    int x = 0, fh = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')
            fh = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = (x << 1) + (x << 3) + c - '0';
        c = getchar();
    }
    return x * fh;
}
LL a, b, c, d;
LL kmax(LL a, LL b, LL c, LL d) { return max(max(max(a, b), c), d); }
int main() {
	a = read(); b = read(); c = read(); d = read();
	cout << kmax(a * c, a * d, b * c, b * d);
	return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    string ans = "NG";
    for (int i = k; i <= b; i += k) {
        if (a <= i && i <= b) {
            ans = "OK";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll n;
    string s;
    cin>>s;
    int ok=1;
    while(ok){
        if(s[0]=='h'&&s[1]=='i'){
            s.erase(0,2);
        }
        else ok=0;
    }
    if(s=="")cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main(void) {
	int N, L;
	cin >> N >> L;

	int all_t = N * (N - 1) / 2 + N * L;
	int tl = L;
	int tr = L + N - 1;
	int min_t;
	if (tr < 0)
		min_t = tr;
	else if (tl > 0)
		min_t = tl;
	else
		min_t = 0;

	int ans = all_t - min_t;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a <= b) {
		for (int i = 0; i < b; i++) {
			cout << a;
		}
		cout << endl;
		return 0;
	}
	else {
		for (int j = 0; j < a; j++) {
			cout << b;
		}
		cout << endl;
		return 0;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        System.out.println((W-w)*(H-h));
    }}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast
    ll a,b,i;
    cin>>a>>b;

    a--;
    ll bb=b;
    b = b-a;
    a=a+bb;
    for(i=b;i<=a;i++)
    {
        cout<<i<<" ";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define data lol
const int maxn = 2e5 + 10;
const int inf = 1e8;
struct data {
  int l, r, value;
  data(int l, int r, int value) : l(l), r(r), value(value) {}
  data() {}
};
int a[maxn];
vector <data> dp[maxn];
int getValue(int i, int j) {
  for(auto k : dp[i]) {
    if(k.l <= j && j <= k.r) {
      return k.value;
    }
  }
  return inf;
}
int makeValue(int i, int j) {
  vector <int> interesting;
  interesting.push_back(0);
  interesting.push_back(j);
  interesting.push_back(a[i - 1] - a[i] + j);
  interesting.push_back(a[i - 1]);
  int ans = inf;
  for(int k : interesting) {
    int add = 0;
    if(k > j) ++add;
    if(a[i - 1] - k < a[i] - j) ++add;
    ans = min(ans, add + getValue(i - 1, k));
  }
  return ans;
}
// b_{i - 1} > b_{i}
// b_{i} < b_{i - 1}
// a_{i - 1} - b_{i - 1} < a_{i} - b_{i}
// a_{i - 1} - a_{i} + b_{i} < b_{i - 1} 

// [b_{i} + 1, a_{i - 1}] => +1
// [a_{i - 1} - a_{i} + b_{i} + 1, a_{i - 1}] => +1

int getRange(int i, int start) {
  int l = start, r = a[i];
  int value = makeValue(i, start);
  while(l < r) {
    int mid = (l + r + 1) >> 1;
    if(makeValue(i, mid) == value) {
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  dp[i].emplace_back(start, l, value);
  return l;
}

int main() {
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> a[i];
  dp[0].emplace_back(0, 0, 0);
  a[0] = a[n + 1] = 0;
  for(int i = 1; i <= n + 1; i++) {
    int cur = 0;
    while(cur <= a[i]) {
      cur = getRange(i, cur) + 1;
    }
  }
  cout << getValue(n + 1, 0) << endl;
  return 0;
}


Measured memory_bytes: 21584
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;
int n, m;
int w[100500];
int c[100500];
long long ans[150][100500];
int main(){
    cin >> n >> m;
    for (int i = 1; i <= n; i++){
        cin >> w[i] >> c[i];
    }
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            if (w[i] <= j){
               ans[i][j] = max(ans[i - 1][j], ans[i - 1][j - w[i]] + c[i]);
            }else{
               ans[i][j] = ans[i - 1][j];
            }
        }
    }
    cout << ans[n][m] << endl;
}

Measured memory_bytes: 79360
from itertools import accumulate
N=int(input())
a=[int(i) for i in input().split()]
dp=[[float("inf")]*(N+1) for i in range(N+1)]
S=[0]+list(accumulate(a))
for i in range(N):
  dp[i][i+1]=0
for d in range(2,N+1):
  for i in range(N+1-d):
    for k in range(i+1,i+d):
      dp[i][i+d]=min(dp[i][i+d],dp[i][k]+dp[k][i+d]+S[i+d]-S[i])
print(dp[0][N])

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

int n,deg[26];
bool v[26];
vector<int> e[26];
string in;

void dfs(int c) {
  v[c] = true;
  for(int i=0; i<e[c].size(); ++i) {
    if(!v[e[c][i]]) dfs(e[c][i]);
  }
}

int main() {
  while(cin>>n, n) {
    for(int i=0; i<26; ++i) {
      e[i].clear();
      deg[i]=0;
      v[i]=true;
    }
    int a,b;
    for(int i=0; i<n; ++i) {
      cin>>in;
      a = in[0]-'a'; b = in[in.length()-1]-'a';
      e[a].push_back(b);
      deg[a]++,deg[b]--;
      v[a] = v[b] = false;
    }
    dfs(a);
    for(int i=0; i<26; ++i)
      if(!v[i] || deg[i]!=0) {
	//cout<<(char)(i+'a')<<" "<<v[i]<<" "<<deg[i]<<endl;
	cout<<"NG"<<endl;
	goto NEXT;
      }

    cout<<"OK"<<endl;
  NEXT:;
  }
}

Measured memory_bytes: 964
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String[] b = a.split("");
        int count = 0;
        for (int i = 0; i < (b.length) / 2; i++) {
            if (!(b[i].equals(b[b.length - 1 - i]))) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22604
n=int(input())
s=input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

ans = r_cnt * g_cnt * b_cnt

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:
            break 
#        logging.debug("{},{},{}".format(s[i],s[j],s[k]))
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
#            logging.debug("☆")
            ans -= 1
print(ans)

Measured memory_bytes: 9120
program sample
implicit none

character(len=2*10**5) :: S, T
integer :: a, i, sum, ans
character(1), allocatable :: p(:), q(:)

read(*,*) S, T
a = len_trim(S)
allocate(p(a))
allocate(q(a))

do i = 1, a
p(i)=S(i:i)
enddo

do i = 1, a
q(i)=T(i:i)
enddo

sum=0
do i =1, a
if(p(i) == q(i))then
sum = sum+1
endif
enddo 
ans = a - sum
write(*,*) ans

deallocate(p)
deallocate(q)

stop
end program sample

Measured memory_bytes: 3720
#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]-'A'<=2){
			s[i]+=23;
		}
		else{
			s[i]-=3;
		}		
	}
	for(int i=0;i<s.size();i++){
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}					


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1000 + 20, inf = 1e9 + 2;
int n, m, a[N], mark[N], ch[N], mm;
long long ans;
vector<int> gr[N], vl;
pair<int, int> mn = {inf, inf};
void dfs(int v) {
	mn = min(mn, {a[v], v});
	mark[v] = 1;
	for (auto u : gr[v])
		if (!mark[u])
			dfs(u);
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		gr[x].push_back(y); gr[y].push_back(x);
	}
	for (int i = 0; i < n; i++) {
		if (!mark[i]) {
			dfs(i);
			mm++;
			ch[mn.second]++; ans += mn.first;
			mn = {inf, inf};
		}
	}
	for (int i = 0; i < n; i++) 
		if (!ch[i])
			vl.push_back(a[i]);
	if (mm == 1) {
		cout << 0;
		return 0;
	}
	if (vl.size() < mm - 2) {
		cout << "Impossible";
		return 0;
	}
	sort(vl.begin(), vl.end());
	for (int i = 0; i < mm - 2; i++)
		ans += vl[i];
	cout << ans;
	return 0;
}

Measured memory_bytes: 7420
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -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やllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int a,b;
  cin >> a >> b;
  cout << (a+b)/2 << endl;
  return 0;
}



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

int main () {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    int ac, wa, tle, re;
    ac = wa = tle = re = 0;

    rep(i, n) {
        if (s[i] == "AC") ac++;
        else if(s[i] == "WA") wa++;
        else if(s[i] == "TLE") tle++;
        else if(s[i] == "RE") re++;
    }
    
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}


Measured memory_bytes: 6440
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int n;
int arr[N];
int pw[N];
int zero;
int two;
int main(){
	scanf("%d" , &n);
	zero = 0;
	two = 0;
	for(int i = 1 ; i <= n ; ++i){
		scanf("%d" , arr + i);
		pw[i] = 0;
		while(!(arr[i] & 1)){
			++pw[i];
			arr[i] >>= 1;
		}
		if(pw[i] == 0){
			++zero;
		}
		if(pw[i] >= 2){
			++two;
		}
	}
	if(zero == two + 1 && zero + two == n){
		printf("Yes\n");
	}
	else if(zero <= two){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
}

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

int main() {
  long long int ans,k,a,b; cin >> k >> a >> b;

  if(k-(a-1) <= 0) { cout << k+1 << endl; return 0; }

  if(b-a >= 2) {
    ans = a;
    ans += (b-a)*((k-(a-1))/2);
    ans += (k-(a-1)) %2;
  } else {
    ans = k+1;
  }

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

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX], n;

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;
    return 0;
}


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

div=set()
for x in range(1, int(N**0.5)+1):
	if N % x == 0:
		div.add(x)
		div.add(N//x)

print(sum(d-1 for d in div if d-1 > 0 and N//(d-1) == N%(d-1)))


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
//typedef pair<double, double> dd;
#define mp make_pair
#define pb push_back
#define debug(x) cerr << #x << " = " << x << " "



int main()
{
  ll h, w;
  while (cin >> h >> w)
    {
      ll ans = (h*w+1)/2;
      if (h == 1 || w == 1) ans = 1;
      cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
typedef struct seito{
  int no;  
  int count;
}seito;
main(){
  double kg;
  double m;
  double BMI;
  int i=0,j;
  seito s[125];
  while(scanf("%d,%lf,%lf",&s[i].no,&kg,&m)!=EOF){
    BMI=kg/(m*m);
    if(BMI>=25) s[i].count=1;
    i++;
  }
  for(j=0;j<i;j++){
    if(s[j].count==1)
      printf("%d\n",s[j].no);
  }
  return 0;
}

Measured memory_bytes: 0
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    string S;
    cin >> S;

    int ans = INT_MAX;
    for (int i = 0; i < S.size() - 2; i++) {
        string s = S.substr(i, 3);
        int a = abs(stoi(s) - 753);
        ans = min(a, ans);
    }

    cout << ans << endl;

    return 0;
}





























































Measured memory_bytes: 256
N,Time = map(int,input().split())
C = []
T = []
for i in range(N):
    c,t = map(int,input().split())
    if t <= Time:
        C.append(c)
        T.append(t)
if len(C) == 0:
    print("TLE")
else:
    print(min(C))


Measured memory_bytes: 2940
a = list(map(int,input().split()))
a.sort(reverse = True)
if a[0] % 2 == 0 or a[1] % 2 == 0 or a[2] % 2 == 0:
    print(0)
    exit(0)
block = a[0] * a[1] * a[2]
a[0] = a[0] // 2
x = a[0] * a[1] * a[2]
y = block - x
print(abs(x - y))

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  string s;
  cin>>n>>k;
  cin>>s;
  k--;
  if(s[k]=='A'){
    s[k]='a';
  }
  if(s[k]=='B'){
    s[k]='b';
  }
  if(s[k]=='C'){
    s[k]='c';
  }
  cout<<s<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> v(m);
    vector<ll> vs;
    rep(i,m){
        cin>>v[i];
    }
    if(n>=m){
        cout<<0<<endl;return 0;
    }
    sort(v.begin(),v.end());
    
    for(int i=0;i<m-1;i++){
        vs.push_back(v[i+1]-v[i]);
    }
    ll ans=0;
    sort(vs.begin(),vs.end());
    for(int i=0;i<m-n;i++){
        ans+=vs[i];
    }
    cout<<ans<<endl;
    
return 0;
}


Measured memory_bytes: 2168
#include <iostream>
using namespace std;
int main(void){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int dx=tx-sx;
  int dy=ty-sy;
  for(int i=0; i<dy; i++)cout << 'U';
  for(int i=0; i<dx; i++)cout << 'R';
  for(int i=0; i<dy; i++)cout << 'D';
  for(int i=0; i<dx; i++)cout << 'L';
  cout << 'L';
  for(int i=0; i<dy+1; i++)cout << 'U';
  for(int i=0; i<dx+1; i++)cout << 'R';
  cout << 'D';
  cout << 'R';
  for(int i=0; i<dy+1; i++)cout << 'D';
  for(int i=0; i<dx+1; i++)cout << 'L';
  cout << 'U';
  cout << endl;
  return 0;

}


Measured memory_bytes: 256
from fractions import Fraction
import math

n,m = [int(x) for x in input().split()]
tle = m
ac = n-m

p_ok = Fraction(1, 2)**tle
p_ng = 1 - p_ok

time = 0
p_sum = 0

i = 1
while True:
    p = (p_ng**(i-1))*p_ok
    time += i*(100*ac+1900*tle)*p
    p_sum += p
    if 1-p_sum < 0.00000001:
        break
    i += 1

print(math.ceil(time))


Measured memory_bytes: 5688
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);++i)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()

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

	int a = (N+2-1)/2;
	double ans = (double)a/N;
	printf("%.10f\n", ans);
}


Measured memory_bytes: 256
N, MOD = int(input()), 10**9+7
memo = [{} for _ in range(N+1)]

def DFS(i, w):
    if w in memo[i]:
        return memo[i][w]
    if i == N:
        return 1
    
    ans = 0
    for c in 'ACGT':
        if w + c not in NG:
            ans = (ans + DFS(i+1, w[1:] + c)) % MOD
    memo[i][w] = ans
    return ans

if N == 3:
    print(61)
else:
    ans, NG = 0, set(['AGGC', 'ATGC', 'AGTC'])
    for w in ['AGC', 'GAC', 'ACG']:
        for c in 'ACGT':
            NG.add(c+w)
            NG.add(w+c)
    for w in [x+y+z for x in 'ACGT' for y in 'ACGT' for z in 'ACGT' if x+y+z not in ['AGC', 'GAC', 'ACG']]:
        ans = (ans + DFS(3, w)) % MOD
    print(ans)

Measured memory_bytes: 3820
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
using namespace std;

struct Node{
  int key;
  Node *parent, *left, *right;
};

Node *nil;

class BinaryTree{
public:
  BinaryTree(){root = new Node; root = nil;}
  ~BinaryTree(){delete root;}
  void Preorder(Node *x);
  void Inorder(Node *x);
  void Postorder(Node *x);
  void insert(int key);
  Node * find(int key);

  Node *root;
};

void BinaryTree::insert(int key){
  Node *y = nil;
  Node *x = root;
  Node *z = new Node;
  // Node *z;
  // z = (Node *)malloc(sizeof(Node));
  z->key = key;
  z->left = nil;
  z->right = nil;

  while(x != nil){
    y = x;
    if(key > x->key){
      x = x->right;
    }
    else{
      x = x->left;
    }
  }
  z->parent = y;
  if(y == nil) root = z;
  else{
    if(key > y->key) y->right = z;
    else y->left = z;
  }
}

Node * BinaryTree::find(int key){
  Node *u = root;
  while(u != nil && u->key != key){
    if(key < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void BinaryTree::Preorder(Node *x){
  if(x == nil) return;
  cout << " " << x->key;
  Preorder(x->left);
  Preorder(x->right);
}

void BinaryTree::Inorder(Node *x){
  if(x == nil) return;
  Inorder(x->left);
  cout << " " << x->key;
  Inorder(x->right);
}

void BinaryTree::Postorder(Node *x){
  if(x == nil) return;
  Postorder(x->left);
  Postorder(x->right);
  cout << " " << x->key;
}

int main(){
  int n;
  cin >> n;
  string com;
  BinaryTree BT;
  int k;
  for(int i=0;i<n;i++){
    cin >> com;
    if(com == "insert"){
      // scanf("%d", &k);
      cin >> k;
      BT.insert(k);
    }
    else if(com == "find"){
      cin >> k;
      Node *t = BT.find(k);
      if(t != nil) cout << "yes" << endl;
      else cout << "no" << endl;
    }
    else if(com == "print"){
      BT.Inorder(BT.root);
      cout << endl;
      BT.Preorder(BT.root);
      cout << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 21904
# -*- coding: utf-8 -*-
# IMPORT ###############################################################################################################
import sys                                                      # システム
sys.setrecursionlimit(10**6)                                    # 再帰処理の上限変更
from collections import deque, Counter                          # キュー・個数カウント
from itertools   import accumulate, permutations, combinations  # 累積和・順列・組み合わせ
from operator    import itemgetter                              # ソート補助
from bisect      import bisect_left, bisect_right, bisect       # 二分探索
from heapq       import heappop, heappush                       # プライオリティキュー
from fractions   import gcd                                     # 最大公約数
from math        import ceil, floor, sqrt, cos, sin, tan, pi    # 数学処理
from copy        import deepcopy                                # オブジェクトコピー
import numpy         as np                                      # 数値計算

# MAIN #################################################################################################################
def main():
    # Init #############################################################################################################
    im = InputManager()
    # Input ############################################################################################################
    n, m = im.inputMultiple()
    xyz = im.input2D(h=n)
    # Logic ############################################################################################################
    scores = []
    for kx in [1, -1]:
        for ky in [1, -1]:
            for kz in [1, -1]:
                tmpScores = []
                for i in range(n):
                    tmpScores.append(kx * xyz[i][0] + ky * xyz[i][1] + kz * xyz[i][2])
                tmpScores.sort(reverse=True)
                scores.append(sum(tmpScores[0:m]))
    # Output ###########################################################################################################
    print(max(scores))
    # Return ###########################################################################################################
    return

# INPUT MANAGER ########################################################################################################
class InputManager(object):
    def __init__(self):
        pass

    @staticmethod
    def inputSingle(dtype=int):
        return dtype(input())
    
    @staticmethod
    def inputMultiple(dtype=int, aslist=False):
        if aslist:
            return list(map(dtype, input().split()))
        else:
            return map(dtype, input().split())

    @staticmethod
    def input2D(h, dtype=int):
        return [list(map(dtype, input().split())) for i in range(h)]

# CALL MAIN ############################################################################################################
main()

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

robots = []
for i in range(N):
    x, l = map(int, input().split())
    robots.append([x-l, x+l])

robots.sort(key=lambda x: x[1])

count = 0
max_arm = -float("inf")
for robo in robots:
    if robo[0] < max_arm:
        count += 1
    else:
        max_arm = robo[1]

print(N - count)

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

#define forn(n) for(int i = 0; i < (int)(n); ++i);
using namespace std;

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

	int counter = 0;
	for(int i = 0; i < n - 2; ++i){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ++counter;
	}

	cout << counter << "\n";
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/agc035/tasks/agc035_d
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const INF: i64 = 1e18 as i64;

struct Solver {
    n: usize,
    a: Vec<i64>,
    memo: Vec<Vec<HashMap<i64,i64>>>
}

impl Solver {
    fn new(a: Vec<i64>) -> Self {
        let n = a.len();
        Solver {
            n: n,
            a: a,
            memo: dvec!(HashMap::new(); n, n)
        }
    }

    fn solve(&mut self, l: usize, r: usize, al: i64, ar: i64) -> i64 {
        let key = (al<<16)+ar;
        if self.memo[l][r].contains_key(&key) {
            return *self.memo[l][r].get(&key).unwrap();
        }
        let mut ans = INF;
        if l + 1 == r {
            ans = 0;
        } else {
            for i in l+1..r {
                let left = self.solve(l, i, al, al+ar);
                let right = self.solve(i, r, al+ar, ar);
                ans = min(ans, self.a[i] * (al + ar) + left + right);
            }
        }
        self.memo[l][r].insert(key, ans);
        ans
    }
}


fn main() {
    input! {
        n: usize,
        a: [i64; n],
    };

    let ini = a[0] + a[n-1];
    let mut solver = Solver::new(a);
    println!("{}", solver.solve(0, n-1, 1, 1) + ini);
}


Measured memory_bytes: 28168
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, u32, u64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let (n, t): (usize, i32) = read();
    let mut routes: Vec<(i32, i32)> = readn(n);

    routes.retain(|&(a, b)| b <= t);
    routes.sort();

    if routes.len() == 0 {
        println!("TLE");
    } else  {
        println!("{}", routes[0].0);
    }
}


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

int main() {
	int A,B,Ans;
	float Ave;
	cin >> A >> B;
	Ave = (A + B) / 2.0;
	Ans = (A + B) / 2.0;
	if (Ave > Ans) {
		Ans++;
	}
	cout << Ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
  int n;
  string words[100], w;
  cin >> n;
  cin >> words[0];
  for(int i=1; i<n; i++) {
    cin >> w;
    for(int j=0; j<i; j++) {
      if (words[j]==w) {
        cout << "No" << endl;
        return 0;
      }
    }
    if (words[i-1][words[i-1].length()-1]!=w[0]) {
      cout << "No" << endl;
      return 0;
    }
    words[i] = w;
  }
  cout << "Yes" << endl;
  return 0;
}

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

#define ll long long
#define pb push_back
#define INF 1e9+7
#define cases int t;cin>>t;while(t--)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ff first
#define ss second

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	ll n;
	cin>>n;
	ll h[n+1];
	rep(i,1,n+1){
		cin>>h[i];
	}

	ll dp[n+1]={0};
	dp[1]=0;
	dp[2]=abs(h[1]-h[2]);
	rep(i,3,n+1){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n];
	return 0;
}

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

int main(int argc, char const *argv[])
{
  int W, a, b;
  cin >> W >> a >> b;
  if(a + W < b)
    cout << b - (a + W) << flush;
  else if(b + W < a)
    cout << a - (b + W) << flush;
  else
    cout << 0 << flush;

  return 0;
}


Measured memory_bytes: 256