akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	n, _ := sc.NextInt()
	m, _ := sc.NextInt()
	x, _ := sc.NextInt()
	c, a := []int{}, [][]int{}
	for i := 0; i < n; i++ {
		ci, _ := sc.NextInt()
		c = append(c, ci)
		ai, _ := sc.NextInts(m)
		a = append(a, ai)
	}
	ans := solve(n, m, x, c, a)
	fmt.Println(ans)
}

func solve(n, m, x int, c []int, a [][]int) (minCost int) {
	// i: combination
	// j: book
	// k: algorithm
	minCost = math.MaxInt64
	for i, maxIter := 0, 1<<n; i < maxIter; i++ {
		progress := make([]int, m)
		cost := 0
		for j := 0; j < n; j++ {
			if i>>j&1 == 1 {
				for k := 0; k < m; k++ {
					progress[k] += a[j][k]
				}
				cost += c[j]
			}
		}
		if !isOk(x, progress) {
			continue
		}
		if cost < minCost {
			minCost = cost
		}
	}
	if minCost == math.MaxInt64 {
		return -1
	}
	return minCost
}

func isOk(x int, progress []int) bool {
	for _, v := range progress {
		if v < x {
			return false
		}
	}
	return true
}

// Scanner is a wrapper of bufio.Scanner which is customized for competitive programing.
type Scanner struct {
	bufio.Scanner
}

// NewScanner is a constructor for Scanner.
func NewScanner(r io.Reader) *Scanner {
	sc := Scanner{*bufio.NewScanner(r)}
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
	return &sc
}

// NextInt reads a integer from io stream.
func (sc *Scanner) NextInt() (int, error) {
	if !sc.Scan() {
		return -1, errors.New("failed to scan")
	}
	return strconv.Atoi(sc.Text())
}

// NextInts reads n integers from io stream.
func (sc *Scanner) NextInts(n int) (arr []int, e error) {
	arr = make([]int, n)
	for i := 0; i < n; i++ {
		v, e := sc.NextInt()
		if e != nil {
			return nil, e
		}
		arr[i] = v
	}
	return arr, nil
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

string base(int N, string S){
    if(N == 0){
        if(S == "") return "0";
        else return S;
    }

    if(N % 2 == 0){
        return base(N / (-2), "0" + S);
    } else {
        N--;
        return base(N / (-2), "1" + S);
    }
}

int main(){
    int N;
    cin >> N;
    cout << base(N, "") << endl;
}

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

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

  ll ans = 0;
  for (ll j = 1; j <= n; j++) {
    ll d = n / j;
    ans += d * (d + 1) * j / 2;
  }

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

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long

const LL INF = (LL)1e18;


// Bellman - Ford (JMBook - Shortestpath(p.941))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	int n, m;
    cin >> n >> m;
 
	VI a(m), b(m), c(m);
	REP(i, 0, m){
		cin >> a[i] >> b[i] >> c[i];
		c[i] = ~c[i] + 1;
	}

	VL upper(n + 1, INF);
	VB neg(n + 1, false);
	upper[1] = 0;
	REP(i, 0, n)
	{
		REP(j, 0, m)
		{
			if(upper[b[j]] > upper[a[j]] + c[j])
			{
				upper[b[j]] = upper[a[j]] + c[j];
				if(i == n - 1)
					neg[b[j]] = true;
			}
		}
	}

	if(neg[n])
		cout << "inf" << endl;
	else
		cout << -upper[n] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define rep1(i, n) for(int i = 1; i <= (int) n; i++)
#define all(v) v.begin(),v.end()

int main() {
    string s;
    cin >> s;
    if (s[1] == 'B') cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

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

int A[100005], dp[100005];

int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N;
    cin >> N;

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

    for(int i=N; i>=1; i--)
    {
        dp[i] = 1;

        if(i < N && A[i] >= A[i+1])
            dp[i] = dp[i+1] + 1;
        
        ans = max(ans, dp[i]);
    }

    cout << ans - 1 << "\n";
    return 0;
}


Measured memory_bytes: 1024
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
D = lines[0][1]

ans = 0
for i in 1..N do
  if lines[i][0] ** 2 + lines[i][1] ** 2 <= D ** 2 then
    ans += 1
  end
end
  
puts ans

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);
const ll MOD = (ll)(1e9 + 7);

string s;

int n;
int tenpow[MAX_N];
ll dp[MAX_N][13];

ll ans;

int main(void) {
  // Here your code !
  cin >> s;

  n = s.size();

  tenpow[0] = 1LL;
  for (int i = 1; i < n + 3; ++i) {
    tenpow[i] = (tenpow[i - 1] * 10 % 13) % 13;
  }

  reverse(s.begin(), s.end());

  if (s[0] == '?') {
    for (int i = 0; i <= 12; ++i) {
      dp[0][i] = (i < 10) ? 1LL : 0LL;
    }
  } else {
    for (int i = 0; i <= 12; ++i) {
      int tmp = (int)(s[0] - '0');
      dp[0][i] = (tmp == i) ? 1LL : 0LL;
    }
  }

  for (int i = 0; i < n - 1; ++i) {
    int base = tenpow[i + 1];

    if (s[i + 1] != '?') {
      int tmp = (int)(s[i + 1] - '0');
      for (int d1 = 0; d1 <= 12; ++d1) {
        int key = (tmp * base + d1) % 13;
        dp[i + 1][key] += dp[i][d1];
        dp[i + 1][key] %= MOD;
      }
    } else {
      for (int d1 = 0; d1 <= 12; ++d1) {
        for (int d2 = 0; d2 <= 9; ++d2) {
          int key = (d2 * base + d1) % 13;
          dp[i + 1][key] += dp[i][d1];
          dp[i + 1][key] %= MOD;
        }
      }
    }
  }

  ans = dp[n - 1][5];

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

  return 0;
}


Measured memory_bytes: 11136
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int len=s.length()-1;
    if(s[len]=='2'||s[len]=='4'||s[len]=='5'||s[len]=='7'||s[len]=='9')
        cout<<"hon"<<endl;
    else if(s[len]=='0'||s[len]=='1'||s[len]=='6'||s[len]=='8')
        cout<<"pon"<<endl;
    else
        cout<<"bon"<<endl;
    return 0;
}


Measured memory_bytes: 3628
import math

def concentration(water, sugar):
    if water + sugar == 0:
        return -1
    else:
        return 100 * sugar / (water + sugar)


if __name__ == "__main__":
    A, B, C, D, E, F = map(int, input().split(' '))
    res_water = 0
    res_sugar = 0
    for ia in range(math.ceil(F / (100 * A))):
        for ib in range(math.ceil(F / (100 * B))):
            water = 100 * (ia * A + ib * B)
            rest = F - water
            if rest < 0:
                break
            for ic in range(math.ceil(rest / C)):
                for id in range(math.ceil(rest / D)):
                    sugar = ic * C + id * D
                    if rest - sugar < 0:
                        break
                    if (water / 100) * E >= sugar and \
                       concentration(res_water, res_sugar) < concentration(water, sugar):
                        res_water = water
                        res_sugar = sugar
    print(res_water + res_sugar, res_sugar)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>
// #include "prettyprint.hpp"

using namespace std;
using ll = long long;

int main()
{
    int N;
    cin >> N;
    vector<int> d(N);

    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }

    sort(d.begin(), d.end());
    // cout << d << endl;

    if (N % 2 == 0 && d[N / 2 - 1] == d[N / 2])
    {
        cout << 0 << endl;
    }
    else
    {
        cout << d[N / 2] - d[N / 2 - 1] << endl;
    }
}

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

//-std=c++11
// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::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...);
}
#else
#define trace(...)
#endif

#define LL long long
#define FI ios_base::sync_with_stdio(0); cin.tie(NULL);
#define PREC cout << setprecision(10) << fixed;

#define int long long

const int MOD = 1e9 + 7;
const int INF = 1e9 + 9;
const int MX = 2e5 + 5;

int procV[MX], procH[MX];

struct BIT {
	int n;
	vector<int> ft;

	BIT(int n) {
		this->n = n;
		ft.resize(n+1);
	}

	void update(int p, int v) {
		for (; p <= n; p += p&(-p)) {
			ft[p] += v;
		} 	
	}

	void update(int a, int b, int v) {
		update(a, v);
		update(b+1, -v);
	}

	int query(int p) {
		int sum = 0;
		for(; p > 0; p -= p&(-p)) {
			sum += ft[p];	
		}
		return sum;
	}
};

#undef int
int main()
{
	#define int long long
	int n, q;
	cin >> n >> q;
	n = n-2;

	int blacks = n * n;
	int minx = n + 1;
	int miny = n + 1;

	BIT bitV(n), bitH(n);

	// trace(blacks);

	int t,x;
	while(q--) {
		cin >> t >> x;
		x--;
		if(t == 1) {
			//vertical
			if(procV[x] == 1) {
				//
			} else {
				if(x > minx) {
					int l = bitV.query(x) - 1;
					blacks = blacks - l;
				} else {
					bitV.update(x+1, minx - 1, miny);
					int l = miny - 1;
					blacks = blacks - l;
					minx = x; 
				}
				procV[x] = 1;
			}
		} else {
			//horizontal
			if(procH[x] == 1) {
				//
			} else {
				if(x > miny) {
					int l = bitH.query(x) - 1;
					blacks = blacks - l;
				} else {
					bitH.update(x+1, miny - 1, minx);
					int l = minx - 1;
					blacks = blacks - l;
					miny = x;
				}
				procH[x] = 1;
			}
		}
		// trace(t, x, blacks);
	}
	cout << blacks << endl;
	
	return 0;
}


Measured memory_bytes: 9656
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int n;
int dp[32];

int main() {
  dp[0] = dp[1] = 1;
  for (int i = 2; i < 31; ++i) {
    for (int j = 1; j <= 3; ++j) {
      if (i - j >= 0) {
        dp[i] += dp[i - j];
      }
    }
  }
  while (cin >> n, n) {
    int nums = dp[n];
    int days = nums / 3650;
    if (nums % 3650) days++;
    cout << days << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG: {} -> {}'.format(name, val), file=sys.stderr)
            return None

x = int(input())

btm = 0
top = 10 ** 15

while top - btm > 1:
    mid = (top + btm) // 2
    if mid % 2 == 0:
        score = (mid // 2) * 11
    else:
        score = (mid // 2) * 11 + 6

    if score >= x:
        top = mid
    else:
        btm = mid

print(top)

Measured memory_bytes: 3064
///Thu Thaoo

#include <bits/stdc++.h>

#define ll long long
#define int ll


using namespace std;

float n;
float start;

main()
{
    cin>>n;
    start = n / 105;
    if (start - (int)start >= 0.5)
        start = (int)start + 1;
    int dau1 = 100 * (int)start;
    int cuoi1 = 105 * (int)start;
    int dau2 = 100 * ((int)start - 1);
    int cuoi2 = 105 * ((int)start - 1);
    int dau3 = 100 * ((int)start + 1);
    int cuoi3 = 105 * ((int)start + 1);
    if ((n >= dau1 && n <= cuoi1) || (n >= dau2 && n <= cuoi2) || (n >= dau3 && n <= cuoi3)) cout<<1;
    else cout<<0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char a[5];
	scanf("%s",a);
	int aa=0,i;
	for(i=0;i<4;i++){
		aa+=(a[i]-'0');
		if(i!=3)aa*=10;
	}
	int yy=aa/100;
	int mm=aa%100;
	int y=0,ym=0;
	if(yy<=12&&yy>0)ym=1;
	if(mm<=12&&mm>0)y=1;
	if(ym+y==2)puts("AMBIGUOUS");
	else if(y==1)puts("YYMM");
	else if(ym==1)puts("MMYY");
	else puts("NA");
	return 0;
}


Measured memory_bytes: 128
package main

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

var N int
var K int

func main() {
	N = nextInt()
	K = nextInt()
	if N >= K*2-1 {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func MaxIn2Values(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinIn2Values(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
from collections import defaultdict
def main(n):
    m = int(input())
    d = defaultdict(int)
    k = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            d[k] = (i, j)
            k += 1
    p = defaultdict(int)
    for i in range(m):
        x, y = map(int, input().split())
        p[(x, y)] = 1
        p[(y, x)] = -1
    ans = defaultdict(int)
    tmp = [0] * n
    ans[tuple(tmp)] = 1
    for i in range(k):
        nd = defaultdict(int)
        for key, value in ans.items():
            key = list(key)
            x, y = d[i]
            if p[(x, y)]:
                if p[(x, y)] == 1:
                    if key[x - 1] == n//2: continue
                    key[x - 1] += 1
                    nd[tuple(key)] += value
                else:
                    if key[y - 1] == n//2: continue
                    key[y - 1] += 1
                    nd[tuple(key)] += value
            else:
                    if key[y - 1] != n//2: 
                        key[y - 1] += 1
                        nd[tuple(key)] += value
                        key[y - 1] += -1
                    if key[x - 1] != n//2:
                        key[x - 1] += 1
                        nd[tuple(key)] += value
        ans = nd
    print(ans[tuple([n // 2] * n)])

if __name__ == "__main__":
    while 1:
        n = int(input())
        if n:
            main(n)
        else:
            break


Measured memory_bytes: 17288
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (a * b % 2 == 0) {
                out.println("Even");
            } else {
                out.println("Odd");
            }
        }

    }
}



Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
int main(){
  	string s; cin >> s;
  	long long k; cin >> k;
  	for(auto i : s){
    	if(i == '1'){
        	if(k == 1) {
              cout << i << endl;
              break;
            }
          	k--;
        } else {
          cout << i << endl;
          break;
        }
    }
	return 0;
}

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

int main (){
    int n;
    cin >> n;
    int a[n];
    for (int i=0 ; i<n  ; i++)
        cin >> a[i];
    vector <int> v;
    for (int i=0 ; i<n ; i++){
        for (int j=i+1 ; j<n ; j++){
            v.push_back(a[i]*a[j]);
        }
    }
    ll sum=0;
    sum = accumulate (v.begin() , v.end() , 0.0);
    cout << sum;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int a,b;
  cin >> N;
  bool ans = false;
  int cnt =0;
  
  for(int i = 0; i <= N-1; i++){
     cin >> a >> b;
  	 if(a == b){
       cnt +=1;
       if(cnt == 3){
	       ans = true;
       }
     }else {
       cnt =0;
     }

  }
 
  if(ans){
   cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

char a[52][52];

int main() {
	int n,m,i,j,t;
	cin >> n >> m;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			cin >> a[i][j];
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			t=0;
			if(a[i][j]=='.')
			{
				if(a[i-1][j]=='#')
				  t++;
				if(a[i-1][j-1]=='#')
				  t++;
				if(a[i-1][j+1]=='#')
				  t++;
				if(a[i][j+1]=='#')
				  t++;
				if(a[i][j-1]=='#')
				  t++;
				if(a[i+1][j-1]=='#')
				  t++;
				if(a[i+1][j]=='#')
				  t++;
				if(a[i+1][j+1]=='#')
				  t++;
				a[i][j]=t+'0';
			}
		}
	}
	
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			cout << a[i][j];
		}
		cout << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 3660
A=[0 for i in range(2)]
A=input().split()
n=int(A[0])
m=int(A[1])
max=[]
k=0

while n>0 and m>0:
    B=[0 for i in range(n)]
    B=input().split()
    for i in range(n):
        B[i]=int(B[i])
    max1=0
    for i in range(n):
        for j in range(i+1,n):  
            x=0 
            x=B[i]+B[j]
            if max1<x and x<=m:
                max1=x
    max.append(max1)
    A=input().split()
    n=int(A[0])
    m=int(A[1])
    k+=1
for i in range(k):
    if max[i]>0:
        print(max[i])
    else:
        print("NONE")


Measured memory_bytes: 5720
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,m,x,y,cnt[N],used[N];

int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++)cnt[i]=1;
  used[0]=1;
  for(int i=0;i<m;i++){
    cin>>x>>y;
    x--,y--;
    cnt[x]--,cnt[y]++;
    if(used[x]&&cnt[y]>=1)used[y]=1;
    if(!cnt[x])used[x]=0;
  }
  int ans=0;
  for(int i=0;i<n;i++)
    if(used[i])ans++;
  cout<<ans<<endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    double ans = 0;
    for(int i=0; i<n; i++){
        double x;
        string s;
        cin >> x >> s;
        if(s == "BTC") ans += x *  380000.0;
        else ans += x;
    }
    cout << ans << endl;
    return 0;
}

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

#define FAST {ios::sync_with_stdio(false); cin.tie(NULL);}
#define pb push_back
#define fi first
#define se second
#define ll long long int
#define f(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007

ll dp[3005][3005] = {0};

int main(){

    FAST
	
    int n;
    cin>>n;

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

    for(int i=n-1;i>=0;i--){
    	for(int j=i;j<n;j++){
    		if(i == j){
    			dp[i][j] = arr[i];
    		}
    		else{
    			dp[i][j] = max(arr[i] - dp[i+1][j], arr[j] - dp[i][j-1]);
    		}
    	}
    }
    cout<<dp[0][n-1]<<"\n";
    return 0;
}


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

using namespace std;

typedef long long ll;

ll mod;

ll powimod(ll x,ll n,ll mod){
    ll res=1;
    while(n){
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res;
}

ll powi(ll x,ll n){
    ll res=1;
    while(n){
        if(n&1) res*=x;
        x*=x;
        n>>=1;
    }
    return res;
}

vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    a=max(0,a-2*b);
    cout<<a;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<char> A(W+2,'#');
  for(int i=0;i<W+2;i++){
    cout << A.at(i);
  }
  cout << endl;
  for(int i=0;i<H;i++){
    vector<string> B(3);
    string x;
    cin >> x;
    B.at(0)="#";
    B.at(1)=x;
    B.at(2)="#";
    
    for(int j=0;j<3;j++){
      cout << B.at(j);
    }
    cout << endl;
  }
  
  for(int i=0;i<W+2;i++){
    cout << A.at(i);
  }
} 

  

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n;
	cin >> n;
	int co = 0;
	for (int i = 2; i < 55555; i++) {
		bool b = true;
		for (int j = 2; j * j <= i; j++) {
			if (i % j == 0) {
				b = false;
			}
		}
		if (b == true) {
			if (i % 5 == 1) {
				co++;
				if (co <= n) {
					cout << i;
					if (co != n) {
						cout << " ";
					}
				}
			}
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <stack>
typedef long long int llint;

int main(void){

  int n;
  std::cin >> n;
  int kakaku1 = (100 * n)/108;
  int kakaku2 = kakaku1 + 1;
  if(int(kakaku1*1.08) == n){
    std::cout << kakaku1 << std::endl;
  }else if(int(kakaku2*1.08) == n){
    std::cout << kakaku2 << std::endl;
  }else{
    std::cout << ":(" << std::endl;
  }

  
  return 0;
}


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

#define ll long long

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n;
    cin >> n;
    set<ll> s;
    bool flag=true;
    for(int i=0; i<n; i++){
        ll x;
        cin >> x;
        if(flag && s.find(x)==s.end()) s.insert(x);
        else flag=false;
    }

    if(flag) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

Measured memory_bytes: 9600
//
//  frog1.cpp
//  
//
//  Created by David Sarpong on 4/24/20.
//

#include <stdio.h>
#include <iostream>
#include <climits>
using namespace std;

int solve(int cost[], int N) {
    int dp[N + 1];
    dp[N] = 1e6;
    dp[N - 1] = 0;
    
    for (int i = N - 2; i >= 0; i--) {
        dp[i] = min(abs(cost[i + 1] - cost[i]) + dp[i + 1], abs(cost[i + 2] - cost[i]) + dp[i + 2]);
    }
    
    return dp[0];
}

int main(int argc, char** argv) {
    int N = 0;
    cin >> N;
    
    int arr[N + 1];
    for (int i = 0; i < N; i++) {
        cin >> arr[i];
    }
    
    cout << solve(arr, N) << endl;
    return 0;
}


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

using namespace std;

int main() {
	int n, m, a;
	cin >> n >> m;
	rep (i, m) {
		cin >> a;
		n -= a;
	}
	if (n < 0) n = -1;
	cout << n << endl;
	return 0;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

   bool is_prime(ll n){
     if(n == 1) return false;
     for(ll i = 2; i * i <= n; i++){
       if(n % i == 0) return false;
     }
     return true;
   }
int main(){
  //verify.
  ll n; cin >> n;
  Vi a(n);
  REP(i, n) cin >> a[i];
  ll cnt = 0;
  REP(i, n){
    cnt += is_prime(a[i]);
  }
  cout << cnt <<endl;

}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,a,b;
	cin>>x>>a>>b;
	int m1,m2;
	m1=fabs(x-a);
	m2=fabs(x-b);
	if(m1<m2)
	cout<<"A"<<"\n";
	else
	cout<<"B"<<"\n";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
errerN=1

while errerN:
    try:
        a=list(map(int, input().split()))
        gcdN=math.gcd(a[0],a[1])
        print(gcdN, int(a[0]*a[1]/gcdN))
    except :
        errerN=0


Measured memory_bytes: 5664
import java.util.Scanner;
class Main {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  while(true) {
   int H = sc.nextInt();
   int W = sc.nextInt();
   if( H == 0 && W == 0 ) break;
   for ( int i = 1; i <= H; i++ ) {
    for( int j = 1; j <= W; j++ ) {
     if( i == 1 || i == H || j == 1 || j == W) {
       System.out.printf("#");
     }else{
       System.out.printf(".");
     }
    }
    System.out.println();
   }
   System.out.println();
  }
 }
} 


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];

	int r = 0;
	ll res = 0;
	int sum = 0;
	
	rep(l,n){
		while(r < n && (sum ^ a[r]) == (sum + a[r])){
			sum += a[r];
			r++;
		}
		
		res += r-l;
        sum -= a[l];
	}
	
	cout << res << endl;
	
	
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int d, i, result;
    while(1) {
        if(scanf("%d", &d) != 1) {
            break;
        }
        result = 0;
        for(i = 0; i < 600; i += d) {
            result += d * (i * i);
        }
        printf("%d\n", result);
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)
typedef long long ll;

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

	vector<pair<ll, int>> D(N);
	rep(i, N)
		cin >> D.at(i).first >> D.at(i).second;
	sort(D.begin(), D.end());
	// rep(i, N) cout << D.at(i).first << " " << D.at(i).second << endl;;
	ll cost = 0;
	rep(i, N){
		if (M <= D.at(i).second){
			cost += M * D.at(i).first;
			break ;
		}
		M -= D.at(i).second;
		cost += D.at(i).second * D.at(i).first;
	}
	cout << cost << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main()
{
	char s[10]="Sunny", c[10]="Cloudy", r[10]="Rainy", S[10];
	gets(S);
	if(strcmp(S,s)==0)
		puts(c);
	else if(strcmp(S,c)==0)
		puts(r);
	else
	puts(s);
return 0;
}

Measured memory_bytes: 128
// inputに入力データ全体が入る
function Main(input) {
  var s;
  s = input.split('\n')[0];
  
  for(var i = 0; i < s.length - 1; i++){
    if(s.charAt(i) === s.charAt(i + 1)){
      console.log('Bad');
      return;
    }
  }
  
  console.log('Good');
  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int k;

bool f(int a, int b, int c, int x){
    for(int i = 0; i < k; i++){
        int d = x / 3;
        int r = x % 3;
        if(r == 0){
            a *= 2;
        } else if (r == 1){
            b *= 2;
        } else {
            c *= 2;
        }
        x = d;
    }
    return (b > a && c > b);
}

int main(void){
    int a, b, c;
    cin >> a >> b >> c >> k;
    for(int i = 0; i < pow(3, k); i++){
        if(f(a, b, c, i)){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 4040
n=int(input())
h=list(map(int,input().split()))
hm=max(h)
s=['']*hm
for k in range(1,hm+1):
  for i in range(n):
    if h[i]>=k:
      s[k-1]+='#'
    else:
      s[k-1]+=' '

#print(s)
ans=0
for k in range(hm):
  ans+=len(list(s[k].split()))
print(ans)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
	
def main():
	N, K = map(int, input().split(" "))
	V = list(map(int, input().split(" ")))
	
	V_tmp = copy.deepcopy(V)
	ans = 0
	for L in range(K+1):
		for R in range((K+1)-L):
			V = copy.deepcopy(V_tmp)
			gets = []
			tmp = 0
			
			for i in range(L):
				if len(V) > 0:
					tmptmp = V.pop(0)
					tmp += tmptmp
					if tmptmp < 0:
						gets.append(tmptmp)
					
			for i in range(R):
				if len(V) > 0:
					tmptmp = V.pop(-1)
					tmp += tmptmp
					if tmptmp < 0:
						gets.append(tmptmp)
					
			#print(gets)
			for i in range(K-L-R):
				if len(gets) == 0:
					break
				gets.sort()
				tmp = tmp + (-1 * gets.pop(0))
				
			if tmp > ans:
				ans = tmp
				
	print(ans)
	
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 3700
// D - Wide Flip
#include <bits/stdc++.h>
using namespace std;

int main(){
	string S; cin>> S;
	int K = S.size();
	for(int N=K, i=1; i<N; ++i)
		if(S[i-1] != S[i]) K = min(K, max(i, N-i));
	cout<< K <<endl;
}

Measured memory_bytes: 512
//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second

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

const int N = 1e6 + 5;

/***************************************************************************/

typedef tree<
pii,
null_type,
less<pii>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

pii train[N];
pair<pii, int> Q[N];
int ans[N];

ordered_set S;

int main() {

	boost;
	int n, m, q; cin>>n>>m>>q;
	for(int i=1; i<=m; i++) {
		cin>>train[i].fi>>train[i].se;
	}
	sort(train+1, train+m+1, greater<pii>());

	for(int i=1; i<=q; i++) {
		cin>>Q[i].fi.fi>>Q[i].fi.se;
		Q[i].se = i;
	}
	sort(Q+1, Q+q+1, greater<pair<pii, int> >());

	int at = 1;
	for(int i=1; i<=q; i++) {
		while(at <= m and train[at].fi >= Q[i].fi.fi) {
			S.insert(pii(train[at].se, at));
			at++;
		}
		ans[Q[i].se] = S.order_of_key(pii(Q[i].fi.se+1, 0));
	}

	for(int i=1; i<=q; i++) {
		cout<<ans[i]<<"\n";
	}
	
	return 0;
}

Measured memory_bytes: 22016
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod = 1000000007;
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

int main(void){
    int h,w,a,b;
    cin >> h >> w >> b >> a;

    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(i<=a && j<=b) cout << 0;
            else if(i>a && j<=b) cout << 1;
            else if(i>a && j>b) cout << 0;
            else if(i<=a && j>b) cout << 1;
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 1280
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
U_MAP mp;

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

  cin >> a >> b >> c;
  mp[a]++;
  mp[b]++;
  mp[c]++;
  if (mp[a] == 2 || mp[b] == 2 || mp[c] == 2)
    Cout("Yes");
  else
    Cout("No");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

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

int main(){
  fastIO();
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max({a*c,a*d,b*c,b*d})<<endl;
  return 0;
}


Measured memory_bytes: 3576
def main():
    N = int(input())
    A = list(map(int,input().split()))
    money = 1000
    stock = 0
    for i in range(N-1):
        if A[i] >= A[i+1]:
            money += stock * A[i]
            stock = 0
        else:
            stock += money // A[i]
            money = money % A[i]
    money += stock * A[N-1]
    print(money)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
// scanf
#pragma warning(disable: 4996)
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// vector 要素の総和算出
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// vector 最大値( return ite )
#define _max_element(v) max_element(v.begin(),v.end())
// vector 最大値が格納されている要素値
#define _max_element_number(v) distance(v.begin(),max_element(v.begin(),v.end()))
// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値
#define _ceil(x) ceil(x)
// 指定された要素以上の値が現れる最初の位置のイテレータを取得する
#define _lower_bound(v,min) lower_bound(v.begin(), v.end(), min)
// 指定された要素より大きい値が現れる最初の位置のイテレータを取得する
#define _upper_bound(v,min) upper_bound(v.begin(), v.end(), min)

// 順列 n個の数が与えられる
// 0,1,2,...,n-1
// 全ての並べ方を1行ごとに出力する
// ex 0 1 2 / 0 2 1 / 1 0 2 / 1 2 0 / 2 0 1 / 2 1 0
#define _next_permutation(v) do {   \
	for (auto num : v) {            \
		printf("%d ", num);         \
	}                               \
	printf("\n");                   \
} while (next_permutation(v.begin(), v.end()))

// 絶対値
static int32_t _abs(const int32_t x) { return  (x > 0 ? x : -x); }


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

	vector<uint32_t> a(n);
	vector<uint32_t> b(n);
	vector<uint32_t> c(n);

	for (size_t i = 0; i < a.size(); i++) {
		cin >> a[i];
	}
	for (size_t i = 0; i < b.size(); i++) {
		cin >> b[i];
	}
	for (size_t i = 0; i < c.size()-1; i++) {
		cin >> c[i];
	}

	uint32_t result = 0;
	uint32_t last_a = 21;
	for (uint32_t _a : a) {

		result += b[_a - 1];
		if (_a == last_a + 1) {
			result += c[_a - 2];
		}
		last_a = _a;
	}

	printf("%d\n", result);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int w,h,x,y,r;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    if(x-r>=0&&y-r>=0&&x+r<=w&&y+r<=h) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 2692
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toInt() }

    var next = 1
    var crashed = 0

    aa.forEach {
        if (it == next) {
            next++
        } else {
            crashed++
        }
    }

    if (crashed == n) {
        println(-1)
    } else {
        println(crashed)
    }
}

Measured memory_bytes: 82928
#include <bits/stdc++.h>
 
using namespace std;
 
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define f first
#define s second
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
typedef long long ll;
typedef long double lld;
typedef unsigned long long ull;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
 
mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
// const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;
 


ll n, m, k, q, l, r, x, y, z;
const ll template_array_size = 1000625;
ll a[template_array_size];
ll b[template_array_size];
ll c[template_array_size];
string s, t;
ll ans = 0;



void solve(int tc = 0) {
	cin >> s;
	
	ll sum = 0;
	for (ll i = 0; i < s.length(); i++) sum += (s[i] - '0');
	
	cout << (sum % 9 ? "No\n" : "Yes\n");
}
 
int main() {
	#ifdef galen_colin_local
		auto begin = std::chrono::high_resolution_clock::now();
	#endif
	
	send help
 
	#ifndef galen_colin_local
		// usaco("cowland");
	#endif
	
	// usaco("cowland");
 
	int tc = 1;
	// cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);
	
	#ifdef galen_colin_local
		auto end = std::chrono::high_resolution_clock::now();
		cout << setprecision(4) << fixed;
		// cout << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
	#endif
} 

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  vector<int> vec(3);
  for(int i=0;i<3;i++){
    int num;
    cin >> num;
    vec[i] = num;
  }
  sort(vec.begin(),vec.end());
  cout <<vec[0]<<" "<<vec[1]<<" "<<vec[2]<<"\n";
}

Measured memory_bytes: 3140
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N = S.length();
  replace(begin(S), end(S), '?', 'D');
  cout << S << endl;
}


Measured memory_bytes: 3748
#include <stdio.h>
int selectionSort(int A[],int N);
int main(void)
{
	int i,n,result;
	scanf("%d", &n);
	int a[n];
	
	for(i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	result = selectionSort(a,n);
	
	for(i=0; i<n; i++){
		if(i < n-1){
			printf("%d ",a[i]);
		}
		else{
			printf("%d",a[i]);
		}
	}
	printf("\n");
	printf("%d\n", result);
	
	return 0;
}

int selectionSort(int A[], int N)
{
	int i,j,tmp,result=0,minj;
	
	for(i=0; i<= N-1; i++){
		minj = i;
		for(j=i; j<= N-1; j++){
			if(A[j] < A[minj]){
				minj =j;
			}
		}
		tmp=A[i];
		A[i]=A[minj];
		A[minj]=tmp;
		if(i != minj){
			result++;
		}
	}
	return result;
}



Measured memory_bytes: 2052
#include <stdio.h>
#include <string.h>
#define LEN 1000000

typedef struct pp{
  char name[10];
  int t;
}p;

typedef struct pk{
  char name[10];
  int m;
}q;

int main(){
  int a,b,c,cnt=0;
  int i,j,k,l;
  p h[LEN];
  q r[LEN];

  scanf("%d %d",&a,&b);
  for(i=0;i<a;i++){
    scanf("%s %d",h[i].name,&h[i].t);
  }
  
  for(j=0;;j++){
    if((h[j].t - b) > 0){
      c=h[j].t-b;
      cnt+=b;
      strcpy(h[i].name,h[j].name);
      h[i].t=c;
      i++;
    }

    if(h[j].t - b <= 0){
      k++;
      cnt+=h[j].t;
      strcpy(r[k-1].name,h[j].name); r[k-1].m=cnt;
      if(k==a) break;
    }
  }
  
  for(l=0;l<a;l++){
    printf("%s %d\n",r[l].name , r[l].m);
  }
  return 0;
}



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

int main()
{
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ca = 0, cb = 0;
  ll ans = 0;
  while (ca < x && cb < y)
  {
    ans += min(2 * c, a + b);
    ca++;
    cb++;
  }
  while (ca < x)
  {
    ans += min(2 * c, a);
    ca++;
  }
  while (cb < y)
  {
    ans += min(2 * c, b);
    cb++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <complex>

using namespace std;

const double pi=3.141592653589793;

void koch_snowflake(size_t n, complex<double> p1, complex<double> p2) {
    if (!n) return;

    complex<double> s, t, u;
    s = (2.0*p1 + p2) / 3.0;
    t = (p1 + 2.0*p2) / 3.0;
    u = (t-s)*polar(1.0, 60*pi/180)+s;

    koch_snowflake(n-1, p1, s);
    printf("%.12f %.12f\n", s.real(), s.imag());
    koch_snowflake(n-1, s, u);
    printf("%.12f %.12f\n", u.real(), u.imag());
    koch_snowflake(n-1, u, t);
    printf("%.12f %.12f\n", t.real(), t.imag());
    koch_snowflake(n-1, t, p2);
}

int main() {
    size_t n;
    scanf("%zu", &n);

    complex<double> p1(0.0, 0.0), p2(100.0, 0.0);

    printf("%.12f %.12f\n", 0.0, 0.0);
    koch_snowflake(n, p1, p2);
    printf("%.12f %.12f\n", 100.0, 0.0);

    return 0;
}

Measured memory_bytes: 2728
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;scanf("%d",&n);
    int ans=1e9;
    for(int i=0;i<=n;i++){
        int a=i,b=n-i,now=0;
        while(a){
            now+=a%9;
            a/=9;
        }
        while(b){
            now+=b%6;
            b/=6;
        }
        ans=min(ans,now);
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, sum = 0;
	cin >> nn;
	vector<int64> dd(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> dd[ii];
	}
	for(int64 ii = 0;ii < nn - 1;ii++)
	{
		for(int64 jj = ii + 1;jj < nn;jj++)
		{
			sum += dd[ii] * dd[jj];
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int llint;
int main() {
	int n;
	cin >> n;
	llint a[2];
	llint t[2];
	llint x, y;
	for (int i = 0;i < n;i++) {
		cin >> a[0] >> a[1];
		if (i == 0) {
			t[0] = a[0];
			t[1] = a[1];
		}
		else {
			if (t[0] % a[0] == 0) {
				x = t[0] / a[0];
			}
			else {
				x = t[0] / a[0] + 1;
			}
			if (t[1] % a[1] == 0) {
				y = t[1] / a[1];
			}
			else {
				y = t[1] / a[1] + 1;
			}
			if (x < y) {
				t[0] = a[0] * y;
				t[1] = a[1] * y;
			}
			else {
				t[0] = a[0] * x;
				t[1] = a[1] * x;
			}
		}
	}
	cout << t[0] + t[1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int w, n;
  scanf("%d", &w);
  scanf("%d", &n);

  int a[n + 1], b[n + 1], loop, tmp;
  int amida[w + 1];

  for (loop = 1; loop <= n; loop++) {
    scanf("%d,%d", &a[loop], &b[loop]);
  }

  for (loop = 1; loop <= w; loop++) {
    amida[loop] = loop;
  }

  for (loop = 1; loop <= n; loop++) {
    tmp = amida[a[loop]];
    amida[a[loop]] = amida[b[loop]];
    amida[b[loop]] = tmp;
  }

  for (loop = 1; loop <= w; loop++) {
    printf("%d\n", amida[loop]);
  }

  return 0;
}

Measured memory_bytes: 596
/**
 *  author: Behradm
 *  Created: 2020.07.11 15:27:05
 *  In The Name Of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  int L, R, d;
  cin >> L >> R >> d;
  int res = 0;
  for (int i = L; i <= R; i++) 
    res += (i % d == 0);
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3608