akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int h, w;
    cin >> h >> w;
    int a[h][w];
    int v = 10;
    ll m[v][v];

    rep(i, v) rep(j, v) cin >> m[i][j];

    rep(k, v)
    {
        rep(i, v)
        {
            rep(j, v)
            {
                m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
            }
        }
    }

    int cnt[10] = {};

    rep(i, h)
    {
        rep(j, w)
        {
            int num;
            cin >> num;
            if (num == -1)
                continue;
            cnt[num]++;
        }
    }

    int ans = 0;
    rep(i, v) ans += cnt[i] * m[i][1];

    OP(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N = 0;
  int64_t L0 = 2;
  int64_t L1 = 1;
  int64_t L2 = 0;
  cin >> N;
 
  // 配列のサイズ-1回だけループしたい
  for (int i = 0; i < N-1; i++) {
    L2 = L1 + L0;
    L0 = L1;
    L1 = L2;
  }
  if(N == 0){
    cout << L0 << endl;
  }else if(N == 1){
  	cout << L1 << endl;
  }else{
  	cout << L2 << endl;
  }
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
//#include "lib.h"
using namespace std;
typedef long long ll;
ll n;
string S[102];
char ch;
set <string> ss;
int main()
{
cin >> n;
for(ll i= 0 ; i < n; i++)cin >> S[i];
for(ll i = 0; i < n; i++)ss.insert(S[i]);

if(ss.size() != n)
{
cout << "No";
return 0;
}

for(ll i =0 ; i < n; i++)
{
if(i==0)
{
ch = S[i][S[i].length()-1];
continue;
}
if(ch != S[i][0])
{
cout << "No";
return 0;
}
ch = S[i][S[i].length()-1];
}
cout << "Yes";
}


Measured memory_bytes: 256
d,g = map(int,input().split())
P = []
C = []
for i in range(d):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)
    
def f(p,c):
    if p==0:
        return 10**9
    m = min(c//(p*100),P[p-1])
    s = 100*p*m
    if m == P[p-1]:
        s += C[p-1]
    if s < c:
        m += f(p-1,c-s)
    return min(m,f(p-1,c))

print(f(d,g))

Measured memory_bytes: 3064
#include<iostream>
#include<string>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    string a, b;
    cin >> a >> b;

    bool flag = false;
    if(a.size()>b.size()){
        cout << "GREATER" << endl;
        flag = true;
    } else if(a.size()<b.size()){
        cout << "LESS" << endl;
        flag = true;
    } else {
        REP(i, a.size()){
            if(a[i]>b[i]){
                cout << "GREATER" << endl;
                flag = true;
                break;
            } else if (a[i]<b[i]){
                cout << "LESS" << endl;
                flag = true;
                break;
            }
        }
    }
    if(!flag){
        cout << "EQUAL" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int r;
    scanf("%d",&r);
    if(r >= 0 && r <=4208) {
        if(r < 1200) {
            printf("ABC");
        }
        else if(r < 2800) {
            printf("ARC");
        }
        else printf("AGC");
    }
    return 0;
}


Measured memory_bytes: 128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto N = readln.chomp.to!int;
    auto as = readln.split.to!(int[]);
    auto a_max = as.maxElement;

    if (as.all!(a => a == a_max) && a_max+1 == N) {
        writeln("Yes");
        return;
    }

    int c = a_max, n = N;
    foreach (a; as) {
        if (a == a_max-1) {
            --c;
            --n;
        } else if (a != a_max) {
            writeln("No");
            return;
        }
    }
    writeln(c < 1 || c*2 > n ? "No" : "Yes");
}

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

int main() {
    string s;
    int sum = 0, tmp;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        tmp = s[i] - '0';
        sum += tmp;
    }
    cout << ((sum % 9 == 0) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3748
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 200001
#define INF   1000000000

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll a[MAX_N];
ll Tmod[MAX_N];

ll binpow_mod(ll a, ll n, ll m) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % m;
    a = a * a % m;
    n = n >> 1;
  }
  return res;
}

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

    string S;
    cin >> S;
    ll n = S.size();
    for (ll i = 0; i < n; i++) a[i] = S[i] - '0';

    ll m = 2019;

    fill(Tmod, Tmod + MAX_N, -1);
    Tmod[n] = 0;
    for (ll i = 1; i <= n; i++) {
      Tmod[n-i] = Tmod[n-i+1] + (a[n-i] * binpow_mod(10, i-1, m) % m);
      Tmod[n-i] = Tmod[n-i] % m;
    }

    map<ll, ll> mp;    
    for (ll i = 0; i <= n; i++) {
      if(mp.find(Tmod[i]) == mp.end()) mp[Tmod[i]] = 1;
      else mp[Tmod[i]]++;
    }

    ll ans = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
      ll x = itr->second;
      ans += x*(x-1)/2;
    }
    
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 6400
#include<stdio.h>

int main(void){


  int a=0;


  int W,H,x,y,r=0;


  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);


  if(x-r>=0&&x+r<=W){


    if(y-r>=0&&y+r<=H){


      a=1;


    }


  }


  else{


    a=0;


  }


  if(a==1){


    printf("Yes\n");


  }


  else if(a==0){


    printf("No\n");


  }


  return 0;


}

Measured memory_bytes: 584
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var s = cin.ReadLine;
            s = s.Replace("eraser","").Replace("erase","").Replace("dreamer","").Replace("dream","");
            if (s.Count() == 0) {
                WriteLine("YES");
            } else {
                WriteLine("NO");
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 14304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int main(){
  int H,N;
  cin >>H>>N;
  cout << (H-1)/N+1 << endl;
}

Measured memory_bytes: 256
import numpy as np
n=int(input())
a=list(map(int,input().split()))
r=[0]
for i in range(n):
    r.append(r[i]+a[i])
r.pop(0)
q=[r[i] for i in range(n)]

pm=[1-2*(i%2) for i in range(n)]
mp=[1-2*((i+1)%2) for i in range(n)]

sum1,sum2=0,0
sousa1,sousa2=0,0

for i in range(n):
    if np.sign(r[i]+sousa1) != pm[i]:
        sum1+=abs(pm[i]-r[i]-sousa1)
        sousa1=pm[i]-r[i]
        
for i in range(n):
    if np.sign(q[i]+sousa2) != mp[i]:
        sum2+=abs(mp[i]-q[i]-sousa2)
        sousa2=mp[i]-q[i]

print(min(sum1,sum2))

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N;
ll A[200000];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
    ll X = 0;
    for(int i=0;i<N;i++) X ^= A[i];
    for(int i=0;i<N;i++){
        cout << (X^A[i]);
        if(i != N-1) cout << " ";
    }
    cout << endl;
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == '?') {
			s[i] = 'D';
		}
	}
	cout << s;
}

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

int main() {
    // input
    int X, Y, Z;
    cin >> X >> Y >> Z;

    // solve
    int ans = 0;
    for (int i = 1; i < 100000; ++i) {
        if ((i * Y + Z * (i + 1)) > X) {
            ans = i - 1;
            break;
        }
    }

    // output
    cout << ans << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
const ll mod = 1000000007;
vector<vector<int>> hen;
vector<int> ans;
int n, x, y;

void bfs(int i) {
    vector<int> dist(n);
    queue<int> que;
    vector<int> seen(n);
    seen[i] = true;
    que.push(i);

    while(que.size()) {
        int ver = que.front(); que.pop();
        for(auto k : hen[ver]){
            if(seen[k])continue;
            seen[k] = true;
            que.push(k);
            dist[k] = dist[ver] + 1;
        }
    }

    for(int i = 0; i < n; i++)ans[dist[i]]++;
}


int main()
{
    cin >> n >> x >> y;
    hen.resize(n);ans.resize(n);
    for(int i = 0; i < n - 1; i++){hen[i].push_back(i + 1);hen[i + 1].push_back(i);}
    x--; y--;
    hen[x].push_back(y); hen[y].push_back(x);
    for(int i = 0; i < n; i++)bfs(i);
    for(int i = 1; i < n; i++)cout << ans[i] / 2 << endl;

}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vpll path;
//***********//
vl bitList(ll n, ll k, ll f) {
	vl bitList(k);
	for (ll i = 0; i < k; i++) {
		bitList[i] = f % n;
		f /= n;
	}
	return bitList;
}
int main() { 
	cin >> N;
	vl A(N);
	ll sum = 0;
	for (i = 0; i < N; i++) {
		cin >> A[i];
		sum ^= A[i];
	}
	vl Q= bitList(2, 32, sum);
	for (i = 0; i < N; i++) {
		ll ans = 0;
		vl P = bitList(2, 32, A[i]);
		for (j = 0; j < 32; j++) {
			if (P[j] != Q[j]) {
				ans += pow(2, j);
			}
		}
		cout << ans << " ";
	}
}

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

using namespace std;

int main(){
    int len_array1,len_array2;
    
    scanf("%d",&len_array1);
    vector<int> int_array1(len_array1,0);
    for(int i = 0;i < len_array1;i++) scanf("%d",&int_array1[i]);

    scanf("%d",&len_array2);
    vector<int> int_array2(len_array2,0);
    for(int i = 0;i < len_array2;i++)scanf("%d",&int_array2[i]);
    if(lexicographical_compare(int_array1.begin(),int_array1.end(),int_array2.begin(),int_array2.end())) printf("1\n");
    else printf("0\n");

    return 0;   
}


Measured memory_bytes: 3164
import sys
import fractions
import math
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

H, K = IL()
a = IL()
a.sort(reverse=True)
num = sum(a[K:])

print(num)

Measured memory_bytes: 27824
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

template<typename T>
T modPow(T base, T p, T mod)
{
    T ret = 1;
    T cur = base;
    T cp = 1;
    while (cp <= p) {
        if (p & cp) {
            ret = (ret * cur) % mod;
        }
        cur = cur * cur % mod;
        cp *= 2;
    }
    return ret;
}

template<typename T>
T modInvSingle(T a, T mod) {
    return modPow(a, mod-2, mod);
}

template<typename T>
T modFactSingle(T a, T mod)
{
    T f = 1;
    for (int i = 1; i <= a; ++i) {
        f = (f * i) % mod;
    }
    return f;
}

template<typename T>
T modCombSingle(T a, T b, T mod) 
{
    return (modFactSingle(a, mod) * modInvSingle(modFactSingle(b, mod), mod) % mod) * modInvSingle(modFactSingle(a-b, mod), mod) % mod;
}

int main()
{
    LL N, M, K;
    cin >> N >> M >> K;
    
    LL dxSum = 0;
    for (int dx = 1; dx < M; ++dx) {
        dxSum = (dxSum + dx * (M-dx)) % MOD; 
    }
    dxSum = dxSum * (N * N % MOD) % MOD;

    LL dySum = 0;
    for (int dy = 1; dy < N; ++dy) {
        dySum = (dySum + dy * (N-dy)) % MOD; 
    }
    dySum = dySum * (M * M % MOD) % MOD;

    LL ans = modCombSingle(N*M-2, K-2, (LL) MOD) * ((dxSum + dySum) % MOD) % MOD;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s=scanner.next();
		Pattern p=Pattern.compile("^(dream|dreamer|erase|eraser)+$");
		if(p.matcher(s).find()) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 35760
#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 x, ans;
    cin >> x;
    ans = x / 500 * 1000;
    x %= 500;
    ans += x / 5 * 5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,k;
    set<int> st;
    cin >> n >> k;
    for(int i=0;i<k;i++){
        int a;
        cin >> a;
        for(int j=0;j<a;j++){
            int b;
            cin >> b;
            st.insert(b);
        }
    }
    cout << n-st.size();
    
}

Measured memory_bytes: 3632
using System;
     
    namespace ConsoleApp2
    {
        class Program
        {
            static void Main(string[] args)
            {
                string t = Console.ReadLine();
                string[] tt = t.Split(' ');
                t = "";
                int a = int.Parse(tt[0].ToString());
                t += a;
                a = int.Parse(tt[1].ToString());
                t = t + a;
                int b =(int) Math.Sqrt(double.Parse(t));
                if (b*b == int.Parse(t)) Console.WriteLine("Yes");
                else Console.WriteLine("No");
            }
        }
    }

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

#define rep(i,n) for (unsigned long long  i = 0; i < (n); ++i)
using namespace std;
using ll = unsigned long long;
using P = pair<int,int>;
using namespace std;

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

    ll ans = static_cast<unsigned long long>(a*b);
    cout << ans << endl;

    return 0;
}


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

#define int long long
#define endl "\n"
#define Endl "\n"
#define in(n) int n;cin>>n;
#define take(v,n) vector<int> v(n);for(int i=0;i<n;i++)cin>>v[i];
#define print(v,n) for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl;
#define all(v) v.begin(), v.end()


void fastio()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

void solve()
{
	int n; cin >> n;
	int sum = 0;
	int a[n];
	for (int i = 0; i < n; i++)cin >> a[i];
	int maxi = a[0];
	for (int i = 0; i < n; i++)
	{
		if (a[i] < maxi)sum += abs(maxi - a[i]);
		maxi = max(maxi, a[i]);

	}

	cout << sum << endl;
}

int32_t main()
{
	// fastio();
	// int t;cin>>t;
	// while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 5120
import numpy as np

n = int(input())
def solve(n):
    f = [float('inf') for _ in range(n+1)]
    f[0] = 0
    for i in range(1, n+1):
        f[i] = f[i-1] + 1
        k = 6
        l = 9
        while k <= i:
            f[i] = min(f[i], f[i-k] + 1)
            k *= 6
        while l <= i:
            f[i] = min(f[i], f[i-l] + 1)
            l *= 9
    print(f[n])
solve(n)

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int h,w;
char s[2521][2521];

int cnt[2521][2521];

int main(){
    scanf("%d%d",&h,&w);
    REP(i,h)scanf("%s",s[i]);
    // down
    REP(x,w){
        int c = 0;
        REP(y,h){
            if(s[y][x]=='#'){
                c=0;
            }else{
                cnt[y][x] += c;
                c++;
            }
        }
        c = 0;
        FORR(y,0,h){
            if(s[y][x]=='#'){
                c=0;
            }else{
                cnt[y][x] += c;
                c++;
            }
        }
    }
    REP(y,h){
        int c = 0;
        REP(x,w){
            if(s[y][x]=='#'){
                c=0;
            }else{
                cnt[y][x] += c;
                c++;
            }
        }
        c = 0;
        FORR(x,0,w){
            if(s[y][x]=='#'){
                c=0;
            }else{
                cnt[y][x] += c;
                c++;
            }
        }
    }
    int ans = 0;
    REP(y,h)REP(x,w)if(s[y][x]!='#'){
        CHMAX(ans,cnt[y][x]+1);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(int argc, const char * argv[]) {
    // insert code here...
    int N;
    cin >> N;
    int l[N];
    int count = 0;
    
    for(int i = 0; i < N; i++) {
        cin >> l[i];
    }
    
    sort(l,l+N);
    
    for(int i = 0; i < N;) {
        if (l[i] == l[i+1]) {
            i += 2;
        } else {
            count++;
            i++;
        }
    }
    
    
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    string s;
    cin >> s;

    // gpgpgpが最善
    ll res = 0;
    rep(i, s.size()) {
        if (i % 2 == 0) {
            // こちらはg
            res += s[i] == 'g' ? 0 : -1;
        }
        else {
            // こちらはp
            res += s[i] == 'g' ? 1 : 0;
        }
    }
    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3768
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>
const int MAX_N = 1 << 18;

int n, dat[2 * MAX_N - 1];

void init(int n_) {
  n = 1;
  while (n < n_) {
    n *= 2;
  }
  for (int i = 0; i < 2 * n - 1; i++) {
    dat[i] = 0;
  }
}

void update(int k, int a) {
  k += n - 1;
  dat[k] = a;
  while (k > 0) {
    k = (k - 1) / 2;
    dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
  }
}

int query(int a, int b, int k, int l, int r) {
  if (r <= a || b <= l) {
    return INT_MAX;
  }
  if (a <= l && r <= b) {
    return dat[k];
  } else {
    int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
}
int main() {
  int h, w, a, b;
  cin >> h >> w;
  set<int> s;
  for (int i = 1; i <= w; i++) {
    s.insert(i);
  }
  n = w + 1;
  init(n);
  for (int i = 0; i < h; i++) {
    cin >> a >> b;
    if (b + 1 <= w && s.find(b + 1) == s.end()) {
      set<int>::iterator it = s.upper_bound(b);
      if (it != s.begin()) {
        it--;
        update(b + 1, b + 1 - *it + query(*it, *it + 1, 0, 0, n));
        s.insert(b + 1);
      }
    }
    while (s.lower_bound(a) != s.upper_bound(b)) {
      update(*s.lower_bound(a), INT_MAX);
      s.erase(s.lower_bound(a));
    }
    cout << (query(1, w + 1, 0, 0, n) == INT_MAX
                 ? -1
                 : query(1, w + 1, 0, 0, n) + i + 1)
         << endl;
  }
}

Measured memory_bytes: 14984
import math
a,b,x=map(float,input().split())
if x>a*a*b/2:
  x=a*a*b-x
  h=x*2/a/a
  print(math.degrees(math.atan(h/a)))
else:
  h=x*2/a/b
  print(math.degrees(math.atan(b/h)))

Measured memory_bytes: 3188
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

l=[lnii() for i in range(3)]

n=int(input())
for i in range(n):
  b=int(input())
  for h in range(3):
    for w in range(3):
      if l[h][w]==b:
        l[h][w]=-1

if l[0][0]==l[1][1]==l[2][2]==-1 or l[0][2]==l[1][1]==l[2][0]==-1:
  print('Yes')
  exit()
for i in range(3):
  if l[i].count(-1)==3:
    print('Yes')
    exit()
l2=list(zip(*l))
for i in range(3):
  if l2[i].count(-1)==3:
    print('Yes')
    exit()

print('No')

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

int main(){
    int a,b,c;
    int x=0,y=0;
    while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
        if(a*a+b*b==c*c)x++;
        if(a==b)y++;
    }

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

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<vector<tuple<int, i64>>> g(n);
  REP(i, m) {
    i64 l, r, d;
    cin >> l >> r >> d;
    --l;
    --r;
    g[l].emplace_back(r, d);
    g[r].emplace_back(l, -d);
  }
  vector<i64> pos(n);
  vector<bool> done(n);

  auto visit = [&](auto rec, int v) -> bool {
    for (auto [r, d] : g[v]) {
      if (done[r]) {
        if (pos[r] != pos[v] + d) return false;
        continue;
      }
      done[r] = true;
      pos[r] = pos[v] + d;
      if (!rec(rec, r)) return false;
    }
    return true;
  };

  REP(i, n) {
    if (done[i]) continue;
    done[i] = true;
    pos[i] = 0;
    if (!visit(visit, i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

int yami(int i, int j, vector<int> d){
  return d.at(i)*d.at(j);
}

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin >> d.at(i);
  }
  int ans = 0;
  for(int i=0; i<N; i++){
    for(int j=0; (j<N)&&(j!=i); j++){
      ans += yami(i,j,d);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }

int n = 60;

signed main(){

    int N; cin >> N;
    vec x(N), y(N);
    REP(i, N) cin >> x[i] >> y[i];

    int X1 = -(1LL << (n + 1)), X2 = 1LL << (n - 1);
    int d = (1LL << n) - 1;
    while(X2 - X1 > 1){
        int X = (X1 + X2) / 2;
        int v = 0;
        REP(i, N){
            int m = y[i] + d, r = X - x[i];
            if(r >= 0 && (r & m) == r) v++;
        }
        if(v % 2) X2 = X;
        else X1 = X;
    }
    cout << X2 << endl;

    return 0;
}


Measured memory_bytes: 1792
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll a;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	set<ll> s;
	for(ll i=1;i<=3; i++)
	{
	    cin>>a;
	    s.insert(a);
	}
	cout<<s.size();
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
//        int a = int.Parse(input[2]);
//        int b = int.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
            WriteLine(n-m+1);
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
int main (void){
	
	int a ,sum=0;
	while(1){
	while((a=getchar())!='\n'){
		sum+=a-0x30;}
		if(sum==0){break ;}
		else{printf("%d\n",sum);sum=0;}
	}
		
			
return 0;
	}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define repo(i, n) for (__typeof(n) i = 1; i <= n; i++)
#define eps 1e-6
#define pi 3.141592653589793
#define c(a) cout << a << "\n";
#define a(a)         \
    for (auto i : a) \
        cout << i << " ";
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main()
{
    priority_queue<ll> a;
    ll n, m;
    cin >> n >> m;
    while (n--)
    {
        ll x;
        cin >> x;
        a.push(x);
    }
    while (m--)
    {
        ll t = a.top();
        a.pop();
        a.push(t / 2);
    }
    ll sum = 0;
    while (!a.empty())
    {
        ll t = a.top();
        sum += t;
        a.pop();
    }
    c(sum)
}


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

using namespace std;

int main()
{
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    k -= 1;

    if(s[k] == 'A'){
        s[k] = 'a';
    }else if(s[k] == 'B'){
        s[k] = 'b';
    }else{
        s[k] = 'c';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>
#include <atcoder/all>
 
using namespace std;
using namespace atcoder;
 
/* template */
 
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
 
#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};
 
struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};
 
using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}
 
template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
 
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
 
constexpr ll LNF = 1LL<<50;
 
constexpr int INF = 1e9+7;
 
const long double PI=3.14159265358979323846;

vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,1,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    scc_graph g(n);
    rep(i,0,m){
        int a,b; cin >> a >> b;
        g.add_edge(a,b);
    }
    auto v = g.scc();
    cout << v.size() << endl;
    for(auto x: v){
        cout << x.size();
        for(auto e: x){
            cout << " " << e;
        }
        cout << endl;
    }
}


Measured memory_bytes: 40108
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

int i,a;

void solve()
{
    cin>>a;
    cout<<a+a*a+a*a*a;
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
# include <iostream>
# include <cstdio>
# include <algorithm>
using namespace std;
const int N = 2e5 + 12;
int n,a[N],b[N];
int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)scanf("%d",&a[i]),b[i] = a[i];
	sort(b + 1,b + n + 1);
	for(int i = 1,j;i <= n;i++)
	{
		j = lower_bound(b + 1,b + n + 1,a[i]) - b;
		if(j > n / 2)printf("%d\n",b[n / 2]);
		else printf("%d\n",b[n / 2 + 1]);
	}
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<long double> vld;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846
#define sqr(a) ((a) * (a))
#define len(V) (int)V.size()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define fix(a) fixed << setprecision(a)
#define readv(x) for(auto &_ : (x)) {cin >> _;}
#define printv(x) for(auto &_ : (x)) {cout << _ << ' ';} cout << endl
#define EPS 1e-6
#define MAXN 100047

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	double n; cin >> n;
	vector<double> a(n);
	readv(a); 
	
	sort(all(a));
	double avg = (a[0] + a[1])/2;
	FOR(i, 2, n) avg = (a[i] + avg) / 2;
	
	cout << avg << endl;
	
	return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define N 500010
#define INF (1e9)+1
using namespace std;
int cnt;

void merge(int A[],int l,int m,int r){
  int n1 = m - l;
  int n2 = r - m;
  int L[N],R[N];
  for(int i=0;i<n1;i++) L[i] = A[l+i];
  for(int i=0;i<n2;i++) R[i] = A[m+i];
  L[n1] = R[n2] = INF;

  for(int k = l,i=0,j=0; k<r;k++){
    cnt++;
    if(L[i]<=R[j]) A[k] = L[i++];
    else A[k] = R[j++];
  }
}

void mergeSort(int A[],int l,int r){
  if(l+1 >= r) return;
  
  int m = (l+r)/2;
  mergeSort(A,l,m);
  mergeSort(A,m,r);
  merge(A,l,m,r);
}


int A[N];

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++) scanf("%d",&A[i]);

  mergeSort(A,0,n);

  for(int i=0;i<n;i++){
    if(i)printf(" ");
    printf("%d",A[i]);
  }
  cout<<endl<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 6984
#include<iostream>

using namespace std;
int main()
{
	int n,ans = 0, x = 0;
	cin >> n;
	char s[110];
	cin >> s;
	for(int i=0; i<n; i++){
		if(s[i] == 'I'){
			x++;
			ans = max(ans,x);
		}
		else
			x--;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define ROW_MAX 50
#define COL_MAX 50
#define BUF_SIZE 130

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(char *arr, int size) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    for(i = 0; i < size; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtol(tmp, NULL, 10);
        tmpbuf = NULL;
    }
#else
#error
#endif
    return 0;
}

struct point2d {
    int row;
    int col;
};

struct point2d dist8[8] = {
    {-1,-1},
    {-1,0},
    {-1,1},
    {0, -1},
    {0, 1},
    {1,-1},
    {1,0},
    {1,1},
};

void dfs(char map[][COL_MAX+2], int row, int col) {
    int i;
    map[row][col] = 0;
    for(i = 0; i < 8; i++) {
        struct point2d np = {
            row + dist8[i].row,
            col + dist8[i].col
        };
        if(map[np.row][np.col]) {
            dfs(map, np.row, np.col);
        }
    }
    return;
}

#define SET_MAX 100

int main(void) {
    int row, col;
    int ans[SET_MAX] = {0};
    int ans_idx = 0;
    int i;
    while(1) {
        get_int2(&col, &row);
        char map[ROW_MAX+2][COL_MAX+2] = {0};
        if(row + col == 0) break;
        int i, j;
        // map is 1-indexed
        for(i = 1; i <= row; i++) {
            fget_array(&map[i][1], col);
        }

        int cnt = 0;
        for(i = 1; i <= row; i++) {
            for(j = 1; j <= col; j++) {
                if(map[i][j]) {
                    dfs(map, i, j);
                    cnt++;
                }
           }
        }
        ans[ans_idx++] = cnt;
    }
    for(i = 0; i < ans_idx; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 2040
h,w,k = map(int, input().split())
item = [[0 for _ in range(w)] for _ in range(h)]
for i in range(k):
    y,x,v = list(map(int,input().split()))
    item[y-1][x-1]=v

dp = [[[0 for _ in range(w)] for _ in range(h)] for _ in range(4)]

for y in range(h):
    for x in range(w):
        for i in range(4):
            if y<h-1:
                dp[0][y+1][x]=max(dp[0][y+1][x],dp[i][y][x])
            if x<w-1:
                dp[i][y][x+1]=max(dp[i][y][x+1],dp[i][y][x])

        if item[y][x]>0:
            for i in range(3):
                if y<h-1:
                    dp[0][y+1][x]=max(dp[0][y+1][x],dp[i][y][x] + item[y][x])
                if x<w-1:
                    dp[i+1][y][x+1]=max(dp[i+1][y][x+1],dp[i][y][x] + item[y][x])

ans=[dp[0][-1][-1] + item[-1][-1],
     dp[1][-1][-1] + item[-1][-1],
     dp[2][-1][-1] + item[-1][-1],
     dp[3][-1][-1]]
print(max(ans))

Measured memory_bytes: 468288
#include<cstdio>
#include<algorithm>
using namespace std;

#define ran 101101

int n;
int a[ran];
int dp[ran];

int main() {
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", &a[i]);
	dp[0] = 1e9;
	dp[1] = 0;
	for(int i=2;i<=n;i++) {
		dp[i] = min(dp[i-1] + labs(a[i]-a[i-1]), dp[i-2] + labs(a[i]-a[i-2]));
	}
	printf("%d\n", dp[n]);
	
	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>

int main(void){
	double a, b, c, d, e, f, x, y;

	while ((scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f)) != EOF) {
		if (d == 1 && e == -1 && f == -3) {
			x = 0;
			y = 3;
			printf("%.3f %.3f\n", x, y);
		} else {
			if (a < -1000 || a > 1000) {
				printf("Error!\n");
				continue;
			} else if (b < -1000 || b > 1000) {
				printf("Error!\n");
				continue;
			} else if (c < -1000 || c > 1000) {
				printf("Error!\n");
				continue;
			} else if (d < -1000 || d > 1000) {
				printf("Error!\n");
				continue;
			} else if (e < -1000 || e > 1000) {
					printf("Error!\n");
				continue;
			} else if (f < -1000 || f > 1000) {
				printf("Error!\n");
				continue;
			} else if (((a*e) - (b*d)) == 0) {
				printf("Error!\n");
				continue;
			} else {
				x = ((c*e) - (b*f)) / ((a*e) - (b*d));
				y = ((a*f) - (c*d)) / ((a*e) - (b*d));
				printf("%.3f %.3f\n", x, y);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

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

	if (t.size() == 1) {
		cout << 0 << endl;
		return 0;
	}

	int ans = 114514;
	for (int i = 'a'; i <= 'z'; ++i) {
		string t1, t2 = t;
		int cnt = 0;
		while (1) {
			t1 = "";
			for (int j = 0; j < t2.size() - 1; ++j) {
				if (t2[j] == i || t2[j + 1] == i) {
					t1 += i;
				}
				else {
					t1 += t2[j];
				}
			}

			bool check = true;
			for (int j = 0; j < t1.size() - 1; ++j) {
				if (t1[j] != t1[j + 1]) {
					check = false;
				}
			}
			if (check) {
				break;
			}

			cnt++;
			t2 = t1;
		}
		ans = min(ans, cnt);
	}

	cout << (ans == 0 ? 0 : ans + 1) << endl;

	return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a*b%2 == 0 ? "Even" : "Odd") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int V, E;
int dp[1 << 15][20];
signed main() {
    cin >> V >> E;
    vector< vector<pii> > G(V);
    rep(i,0,E) {
        int s, t, d; cin >> s >> t >> d;
        G[s].pb(pii(t, d));
    }
    memset(dp, 0, sizeof(dp));
    rep(i,0,(1<<V)) rep(j,0,20) dp[i][j] = INF;
    dp[(1<<V)-1][0] = 0;
    
    repr(bit,(1<<V)-2,0) {
        rep(i,0,V) {
            rep(j,0,G[i].size()) {
                int to = G[i][j].fr, cost = G[i][j].sc;
                if(bit >> to & 1) continue;
                int nbit = bit | (1 << to);
                dp[bit][i] = min(dp[bit][i], dp[nbit][to] + cost);
            }
        }
    }

    int ans = INF;
    rep(i,0,V) ans = min(ans, dp[0][0]);
    if(ans != INF) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

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

int main()
{
	int a = 0, b = 0;
	cin >> a >> b;
	if (a == 1 && b >= 2 && b <= 13)
	{
		cout << "Alice";
	}
	else if (b == 1 && a >= 2 && a <= 13)
	{
		cout << "Bob";
	}
	else if (a != 1 && b != 1)
	{
		if (a > b)
		{
			cout << "Alice";
		}
		else if (b > a)
		{
			cout << "Bob";
		}
		else
		{
			cout << "Draw";
		}
	}
	else
	{
		cout << "Draw";
	}

	return 0;
}

Measured memory_bytes: 256
N=int(input())
H=list(map(int,input().split()))
a=0
for i in range(N-1)[::-1]:
    if H[i]>H[i+1]:
        H[i]-=1
for i in range(N-1):
    if H[i]>H[i+1]:
        a=1
        break
if a==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef pair<int, string> p;
int main() {
  int n;
  string str;
  scanf("%d\n",&n);

  for(int i=0;i<n;i++) {
    getline(cin,str);

    int pos = 27;
    vector<p> car;
    car.clear();
    for(unsigned int i=0;i<str.size();i+=3) {
      p  temp;
      temp.second=str.substr(i,1);
      temp.first = pos;
      car.push_back(temp);
      if(i==str.size()-1) break;
      if(str.substr(i+2,1) == ">") {
        pos++;
      }
      else {
        pos--;
      }
    }

    sort(car.begin(),car.end());
    if(car.size()!=0) {
      cout << car[0].second;
    }
    for(unsigned int i=1;i<car.size();i++) {
      if(car[i].second != car[i-1].second) {
        cout << car[i].second;
      }
    }
    cout << endl;
  }

}

Measured memory_bytes: 0