akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using static System.Math;
using static System.Console;
using System.Collections.Generic;

partial class Program
{
    public static void Main(string[] args)
    {
        var v = ReadLine()
            .Split(' ')
            .Select(x => int.Parse(x))
            .ToArray();
        var h = v[0];
        var w = v[1];
        var array = new Item[w, h];
        var bqueue = new Queue<Item>();
        var a = Enumerable
            .Range(0, h)
            .SelectMany(y => ReadLine()
                .Select((c, x) => new Item { IsBlack = c == '#', X = x, Y = y }));
        foreach (var item in a)
        {
            array[item.X, item.Y] = item;

            if (item.IsBlack)
            {
                bqueue.Enqueue(item);
            }
        }

        Item lastWhite = null;
        while (bqueue.Count > 0)
        {
            lastWhite = bqueue.Dequeue();
            var gen = lastWhite.Gen + 1;
            TurnToBlack(array, bqueue, w, h, lastWhite.X - 1, lastWhite.Y, gen);
            TurnToBlack(array, bqueue, w, h, lastWhite.X + 1, lastWhite.Y, gen);
            TurnToBlack(array, bqueue, w, h, lastWhite.X, lastWhite.Y - 1, gen);
            TurnToBlack(array, bqueue, w, h, lastWhite.X, lastWhite.Y + 1, gen);
        }
        WriteLine(lastWhite?.Gen ?? 0);
    }

    static void TurnToBlack(Item[,] array, Queue<Item> bqueue, int w, int h, int x, int y, int gen)
    {
        if (x < 0 || w <= x || y < 0 || h <= y)
        {
            return;
        }
        var item = array[x, y];
        if (!item.IsBlack)
        {
            item.IsBlack = true;
            item.Gen = gen;
            bqueue.Enqueue(item);
        }
    }

    class Item
    {
        public bool IsBlack;
        public int X;
        public int Y;
        public int Gen;
        public override string ToString() => $"{X}, {Y}, {IsBlack}, {Gen}";
    }
}

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

using namespace std;

#define LL long long
#define Re register
#define U unsigned
#define forn(i,a,b) for(Re int i = a;i <= b;++i)
#define nfor(i,a,b) for(Re int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define pb push_back
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const double e=2.71828182845904523536;
int dir[4][2]={1,0,0,1,-1,0,0,-1};
int sum[105];
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    int n;
    cin>>n;
    int a[105];
    sum[0]=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }

    int ans=1e9+5;
    for(int i=1;i<=n;i++)
    {
        ans=min(ans,abs(sum[i]*2-sum[n]));
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int[] alpha = new int[26];
		for (char c : arr) {
		    alpha[c - 'a']++;
		}
		PriorityQueue<Node> queue = new PriorityQueue<>();
	    for (int i = 0; i < 26; i++) {
	        if (alpha[i] > 0) {
	            queue.add(new Node(i, alpha[i]));
	        }
	    }
	    if (queue.size() == 1) {
	        System.out.println(queue.peek().count);
	        return;
	    }
	    ArrayList<Node> chars = new ArrayList<>();
	    while (queue.size() > 1) {
	        Node left = queue.poll();
	        Node right = queue.poll();
	        queue.add(new Node(left, right));
	        if (left.isAlpha()) {
	            chars.add(left);
	        }
	        if (right.isAlpha()) {
	            chars.add(right);
	        }
	    }
	    setLength(0, queue.peek());
	    long total = 0;
	    for (Node x : chars) {
	        total += x.getValue();
	    }
		System.out.println(total);
	}
	
	static void setLength(int length, Node target) {
	    if (target == null) {
	        return;
	    }
	    target.length = length;
	    setLength(length + 1, target.left);
	    setLength(length + 1, target.right);
	}
	
	static class Node implements Comparable<Node> {
	    int idx;
	    Node left;
	    Node right;
	    int count;
	    int length;
	    
	    public Node(int idx, Node left, Node right, int count, int length) {
	        this.idx = idx;
	        this.left = left;
	        this.right = right;
	        this.count = count;
	        this.length = length;
	    }
	    
	    public Node(int idx, int count) {
	        this(idx, null, null, count, 0);
	    }
	    
	    public Node(Node left, Node right) {
	        this(-1, left, right, left.count + right.count, 0);
	    }
	    
	    public boolean isAlpha() {
	        return idx >= 0;
	    }
	    
	    public int compareTo(Node another) {
	        return count - another.count;
	    }
	    
	    public int getValue() {
	        return count * length;
	    }
	}
 }



Measured memory_bytes: 29684
#include<bits/stdc++.h>
using namespace std;
char s[100001],s1[100001];
int main(){
    cin>>s>>s1;
    if(strlen(s)!=strlen(s1)) puts("NO");  //若长度不同，肯定不可以
    else{
        reverse(s1,s1+strlen(s1));  //翻转一下
        if(!strncmp(s,s1,strlen(s))) puts("YES");  //相同为YES
        else puts("NO");  //不同为NO
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define MOD 1000000007
#define f(i,a,n) for(lli i = a; i < n; i++)
#define fb(i,a,n) for(lli i=n-1;i>=a;i--)
 
#define p64 pair<lli,lli>
#define v64 vector<lli>
#define p32 pair<int,int>
#define v32 vector<int>
#define vp64 vector<pair<lli , lli >>
#define vp32 vector<pair<int , int>>
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--){
        lli n; cin>>n;
        lli ans = 0; lli total = 1;
        while(n){
            ans+=total;
            total*=2;
            n/=2;
        }
        cout<<ans<<endl;
    }
return 0;
}

Measured memory_bytes: 256
# import bisect
# from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    x, a, b = map(int, open(0).read().split())
    print((x-a)%b)

if __name__ == '__main__':
    main()

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

using namespace std;
int main()
{
    int a,b;
    cin>>a;
    cin>>b;
    long long int k=(a+b)/2;
    if(abs(a-k)==abs(b-k))
    {
        cout<<k<<endl;
    }
    else
    {
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*===================*\
|ID : harryPotter_421  |
|      LANG: C++       |
\*====================*/
#include <iostream>
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define M 1000000007
#define ld long double
#define f(j,m,n) for(lli j=m;j<n;j++)
#define harry ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
lli arr[110];
lli n,k,mini=INT_MAX;
lli winner(lli i,lli k)
             {lli dp[3][k+1];
              dp[1][0]=2;
              dp[2][0]=1;
              for(lli j=1;j<=k;j++)
                 {for(lli i=1;i<=2;i++)
                     {if(i==1)
                         dp[i][j]=2;
                      else
                         dp[i][j]=1;

                      for(int m=1;m<=n;m++)
                          {if(i==1)
                             {if(j-arr[m]>=0)
                              {dp[i][j]=dp[2][j-arr[m]];
                              if(dp[i][j]==1)
                                 break;}
                                 else
                                    dp[i][j]=2;
                              }
                            if(i==2)
                              {if(j-arr[m]>=0)
                                {dp[i][j]=dp[1][j-arr[m]];
                                if(dp[i][j]==2)
                                     break;}
                               else
                                 dp[i][j]=1;

                              }

                          }

                     }

                 }
                    




                    return dp[1][k];










                 /*if(dp[k]!=-1)
                 return dp[k];
              if(k==0)
                  return i;
              if(k<mini)
                  {//cout<<"pi";
                   if(i==1)
                     return 2;
                    else if(i==2)
                      return 1;
                   }
                   lli ans;
                if(i==1)
                 ans=2;
                else
                    ans=1;
              for(int j=1;j<=n;j++)
                 {if(i==2)
                     {if(winner(1,k-arr[j])==2)
                        {ans=2;
                        break;}

                      }
                  else if(i==1)
                     {if(winner(2,k-arr[j])==1)
                        {ans=1;
                         break;
                        }
                     }
                  }
                 dp[k]=ans;
                 return ans;*/

             }

int main()
   {harry

    cin>>n>>k;
    //lli arr[n+1];
    for(lli i=1;i<=n;i++)
        {cin>>arr[i];
        mini=min(arr[i],mini);}
        lli a;
        if(n==1)
        { a=k/arr[1];
         if(a%2==0)
            cout<<"Second";
         else
            cout<<"First";

        }
        else{a=winner(1,k);
        if(a==1)
            cout<<"First";
            else
            cout<<"Second";
        }


    }

















Measured memory_bytes: 1920
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

vector<vector<int> > v(10, vector<int>());

void root_search(int node, int &ans, vector<int> &root, int size)
{
	if (find(root.begin(), root.end(), node) == root.end())
	{
		root.push_back(node);

		if (SIZE(root) == size)
		{
			ans++;
		}
		else
		{
			REP(i, SIZE(v[node]))
			{
				root_search(v[node][i], ans, root, size);
			}
		}

		root.pop_back();
	}
}

signed solve()
{
	int n, m;
	cin >> n >> m;
	REP(i, m)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	int ans = 0;
	vector<int> root;
	root_search(0, ans, root, n);

	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int count = 0;
        int n;
        n = sc.nextInt();
        int i,j,k,l;
        int[][][] floor = new int[5][4][11];
        for(i=0;i<5;i++){//配列初期化
            for(j=0;j<4;j++){
                for(k=0;k<11;k++){
                    floor[i][j][k] = 0;
                }
            }
        }
        while(count != n){
            i = sc.nextInt();
            j = sc.nextInt();
            k = sc.nextInt();
            l = sc.nextInt();
            floor[i][j][k] += l;
            count++;
            
        }
        for(i=1;i<5;i++){
            for(j=1;j<4;j++){
                for(k=1;k<11;k++){
                    System.out.printf(" %d",floor[i][j][k]);
                }
                System.out.println();
            }
            if(i<4){
            System.out.println("####################");
        }
    }
        
        
    }
}


Measured memory_bytes: 30556
#[allow(unused_imports)]
use std::cmp::Ordering::{Equal, Greater, Less};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// grand-garden.rs --- Grand Garden
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        hs: [u32; n],
    };

    let mut ans = 0;

    for i in 1.. {
        let t = hs
            .split(|&h| h < i)
            .filter(|&part| !part.is_empty())
            .count();
        if t <= 0 {
            break;
        }

        ans += t;
    }

    println!("{}", ans);
}


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

int main()
{
    int N, l, r, ans;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]); if(i!=n-1) cout << " ";} cout << endl;
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n[4];
    rep(i,0,4){
        cin >> n[i];
    }
    sort(n, n+4);
    if(n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9){
        print("YES");
    }else{
        print("NO");
    }

}


Measured memory_bytes: 256
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();
        int max = Math.Max(a, Math.Max(b, c));
        Console.WriteLine(a + b + c - max);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

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

// Longest Common Subsequence

class LCS {
    string S, T;
    vector <vector<int>> dp;

public:
    LCS(string &s, string &t) : S(s), T(t) {
        int sl = S.size(), tl = T.size();
        dp.assign(sl + 1, vector<int>(tl + 1, 0));

        for (int i = 0; i < sl; i++) {
            for (int j = 0; j < tl; j++) {
                if (S[i] == T[j]) {
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                } else {
                    dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
                }
            }
        }
    }

    int len() { return dp[S.size()][T.size()]; }

    string str() {
        string ret = "";
        int i = S.size(), j = T.size();
        while (dp[i][j]) {
            if (S[i - 1] == T[j - 1]) {
                i--, j--;
                ret = S[i] + ret;
            } else if (dp[i - 1][j] > dp[i][j - 1]) {
                i--;
            } else {
                j--;
            }
        }
        return ret;
    }
};


// verified
//   https://atcoder.jp/contests/dp/tasks/dp_f
void AtCoder_2019_1_6_F() {
    string s, t;
    cin >> s >> t;
    LCS lcs(s, t);
    cout << lcs.str() << '\n';
}

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

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

struct edge{
	int u,v;
	ll cost;
};

bool comp(const edge& e1, const edge& e2){
	return e1.cost < e2.cost;
}

int main(){
	ll V,E;
	cin >> V >> E;
	vector<edge> e;
	vector<int> c;
	rep(i,V){
		c.push_back(i);
	}
	rep(i,E){
		int s,t;
		ll w;
		cin >> s >> t >> w;
		edge e1 = {s,t,w};
		e.push_back(e1);
	}
	sort(e.begin(),e.end(),comp);
	
	ll ans = 0;
	
	rep(i,E){
		if(c[e[i].u] != c[e[i].v]){
			ans += e[i].cost;
			int temp = c[e[i].v];
			rep(j,V){
				if(c[j] == temp){
					c[j] = c[e[i].u];
				}
			}
		}
	}
	
	cout << ans << endl;
    return 0;
}




Measured memory_bytes: 5008
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 200005
#define _rep(i, a, n) for(int i = a; i < n; i++)
#define rep(i, a, n) for(i = a; i < n; i++)

int a[maxn];
int n, i;
void trace(int a[], int n){
	rep(i, 0, n){
		if(i)	cout << ' ';
		cout << a[i];
	}
	cout <<endl;
}
void insertionSort(int a[], int n){
	int i ,j, v;
	rep(i, 1, n){
		v = a[i];
		j = i - 1;
		while(j >= 0 && a[j] > v){
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		trace(a, n);
	}
} 
int main(void){
	cin >> n;
	_rep(i, 0, n)	cin >> a[i];
	trace(a, n);
	insertionSort(a, n);
	return 0;
} 


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

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  int score = 0;
  for(int i=0;i<n-1;i++){
    if(s.at(i) == s.at(i+1)) score++;
  }
  int ans = min(score+2*k, n-1);
  cout << ans << endl;
}

Measured memory_bytes: 512
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <array>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>

/* ----- Type Alias ----- */
using lint = long long int;
using Real = long double;
template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T>
T ndvec(T v) { return v; }

template <class T, class... Ts>
auto ndvec(size_t l, Ts... ts) {
    return std::vector<decltype(ndvec<T>(ts...))>(l, ndvec<T>(ts...));
}

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;
template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;

#endif

/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// const Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    int n, m;
    std::cin >> n >> m;

    Graph<> graph(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;
        graph[u].emplace_back(u, v);
    }

    std::vector<Real> effect(n);
    for (int r = 0; r < n; ++r) {
        std::vector<Real> dp(n, 0);
        for (int v = n - 2; v >= 0; --v) {
            for (auto e : graph[v]) {
                dp[v] += dp[e.dst];
            }
            dp[v] /= graph[v].size();
            if (v == r) dp[v] += 1;
        }
        effect[r] = dp[0];
    }

    std::vector<Real> dp(n, 0);
    for (int v = n - 2; v >= 0; --v) {
        int sz = graph[v].size();
        for (auto e : graph[v]) {
            dp[v] += dp[e.dst];
        }
        dp[v] /= sz;
        dp[v] += 1;
    }

    Real maxeffect = 0;
    for (int v = 0; v < n - 1; ++v) {
        int sz = graph[v].size();
        if (sz == 1) continue;

        for (int k = 0; k < graph[v].size(); ++k) {
            // k番目を塞いだ場合
            Real sum = 0;
            for (int i = 0; i < sz; ++i) {
                int u = graph[v][i].dst;
                sum += (i == k ? 0 : dp[u]);
            }
            Real diff = dp[v] - (sum / (sz - 1) + 1);
            maxeffect = std::max(maxeffect, diff * effect[v]);
        }
    }

    std::cout << std::fixed << std::setprecision(10)
              << dp[0] - maxeffect << std::endl;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define PI 		    acos(-1)
#define pb          push_back
#define ins         insert
#define INF        	1000000000000000007 //1e18+7
#define mk          make_pair
#define lb(v,x)     lower_bound(all(v),x)
#define ub(v,x)     upper_bound(all(v),x)
#define ff          first
#define ss          second
#define rev         reverse
#define umap        unordered_map
#define endl        "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a)       (ll)a.size()
#define double      long double
#define minpq       priority_queue <ll,vector<ll>,greater<ll> > 
#define fill(x,y)   memset(x,y,sizeof(x))
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define MOD         1000000007		//1e9+7
#define bp(n)       __builtin_popcountll(n)
#define mxt(a)      *(max_element(a.begin(),a.end()))
#define mnt(a)      *(min_element(a.begin(),a.end())
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i, a, mp) for(ll i = (a); i<= (mp); ++i)
#define trav(a, x) 	 for(auto &a : x)
#define re(i,n)      for(ll i = 0; i < n; ++i) 
const int N = 5e5 + 7;
typedef pair<ll,ll>   pii;
typedef vector<pii>   vpii;
typedef vector<ll>    vll;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int dx[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int dy[8]={+1, 0, -1, +1, -1, +1, 0, -1};
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
template<typename T> T gcd(T a,T mp){ if(a==0) return mp; return gcd(mp%a,a); }
template<typename T> T powm(T a,T mp, ll m){T cnt=1; while(mp>0){ if(mp%2==1) cnt=(cnt*a)%m; mp/=2; a=(a*a)%m; }return cnt%m;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll sqr(ll x) { return x * x;} 
void prec(){

}
void run(){
	ll int n,k;cin>>n>>k;
	ll int h[n+10],dp[n+10];
	rep(i,1,n) cin>>h[i];
	rep(i,1,n) dp[i]=INF;
	dp[0]=0,dp[1]=0;
	rep(i,1,n){
		for(ll j=i+1; j<=i+k; ++j) if(j<=n) dp[j]=min(dp[j],abs(h[j]-h[i])+dp[i]);
	}
	cout<<dp[n]<<endl;
}
int main()
{
    cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
    int tc=1;
    //cin>>tc;
    prec();
    re(i,tc)
    	run();
    return 0; 
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, a, b, x, ans=0;
	scanf("%d %d %d", &n, &a, &b);
	for(int i=0; i<n; i++) {
		scanf("%d", &x);
		if(x>=a && x<b) continue;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
if __name__=='__main__' :
    c1=input().split()
    c2=input().split()
    
    x1 = int(c1[0])
    y1 = int(c1[1])
    r1 = int(c1[2])
    x2 = int(c2[0])
    y2 = int(c2[1])
    r2 = int(c2[2])
    d = ((x1-x2)**2+(y1-y2)**2)**(1/2)
    if d > r1+r2 :
        print(4)
    elif d == r1+r2 :
        print(3)
    elif (d < r1+r2) and (abs(r1-r2) < d) :
        print(2)
    elif  abs(r1-r2) == d :
        print(1)
    elif d < abs(r1-r2) :
        print(0)



Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int a, b;

    cin >> a >> b;

    cout << max(a + b, max(a - b, a * b)) << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	static Scanner sc;
	static int T,N,M,arr[],ans[][];
	
	public static int min(int a, int b)	{
		if(a<=b)
			return a;
		else
			return b;
	}
	
	public static int minCount(int a[],int x, int s)	{
		int c,d;
		for(int i=0;i<x;i++)
			ans[0][i] = 0;
		for(int i=1;i<=s;i++)	{
			for(int j=0;j<x;j++)	{
				if(i-a[j]>=0 && ans[i-a[j]][j]!=-1)
					c = 1 + ans[i-a[j]][j];
				else
					c = -1;
				if(j-1>=0 && ans[i][j-1]!=-1)
					d = ans[i][j-1];
				else
					d = -1;
				if(c!=-1 && d!=-1)
					ans[i][j] = min(c,d);
				else if(c==-1 && d!=-1)
					ans[i][j] = d;
				else if(c!=-1 && d==-1)
					ans[i][j] = c;
				else
					ans[i][j] = -1;
			}
		}
		return ans[s][x-1];
	}

	public static void main(String[] args) {
		int answer;
		sc = new Scanner(System.in);
		//T = sc.nextInt();
		//for(int l=0;l<T;l++)	{
			N = sc.nextInt();
			M = sc.nextInt();
			arr = new int[M];
			ans = new int[N+1][M];
			for(int i=0;i<M;i++)
				arr[i] = sc.nextInt();
			answer = minCount(arr, M, N);
			if(answer==-1)
				System.out.println("No solution");
			else
				System.out.println(answer);
		//}
	}

}

Measured memory_bytes: 31900
import math
N,D=map(int,input().split())
x=[]
for i in range(N):
    y=list(map(int,input().split()))
    x.append(y)

cnt=0
for n in range(N):
    for nn in range(N):
        if n==nn:
            continue
        else:
            a=[]
            for d in range(D):
                a.append((x[n][d]-x[nn][d])**2)
            c=math.sqrt(sum([abs(i) for i in a]))
            if c%1==0:
                cnt+=1
print(int(cnt/2))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

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


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}


////////////////////////////////////////////////////////////////////

int main() {
int a,b,c;
cin>>a>>b>>c;
int n=max(a,max(b,c));
int ans=3*n-a-b-c;
if(ans%2)ans+=3;
cout<<ans/2<<endl;
return 0;

}




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

int main() {
    int N;
    cin >> N;
    set<int> s;
    rep(i, N) {
        int a;
        cin >> a;
        s.insert(a);
    }
    if (s.size() == N) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 9600
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	if(k==1)
	{
		printf("0\n");
		return 0;
	}
	int ans=max(n-k,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int 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;
    }
}
int func(int x)
{
    if (x % 100 != 0)
    {
        return 0;
    }
    return func(x / 100) + 1;
}
int main()
{
    int d, n;
    cin >> d >> n;
    int count = 0;
    for (int i = 1;; i++)
    {
        if (func(i) == d)
        {
            count++;
            if (count == n)
            {
                cout << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
# 解答ちらっと見た
# 問題のキモは Cx,Cy,Hがそれぞれ100通り、
# 全探索をCx,Cy,Hに対して試みると 入力された情報のcheckを入れて101*101*100*100でTLEする。
# でもよく考えてみると、Cx,CyがわかればHはそのあとで出せるので Cx,Cyに対して全探索をする(101*101*100+100の計算量で済む)


def get_H(Cx, Cy):
    for x, y, h in L:
        if h > 0:
            return abs(x - Cx) + abs(y - Cy) + h


def check_H(Cx, Cy, H):
    for x, y, h in L:
        if h != max(H - abs(x - Cx) - abs(y - Cy), 0):
            return False
    return True


N = int(input())

L = [(list(map(int, input().split()))) for _ in range(N)]

for Cx in range(101):
    for Cy in range(101):
        H = get_H(Cx, Cy)
        if check_H(Cx, Cy, H):
            print('{} {} {}'.format(Cx, Cy, H))
            exit(0)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

const int MAX_V = 101;
const int INF = 1e+8;

// 頂点は(ノード番号,割引券の数)の組
typedef pair<int,int> P;
// 状態は(コスト,頂点)の組
typedef pair<int,P> State;

struct edge{
	int to, cost;
	edge(int v, int cost_){
		to = v;
		cost = cost_;
	}
};

// 頂点数
int V;
// G[u][i] = ノード u に接続している i 番目の edge が返ってくる
vector<edge> G[MAX_V];

// 初期化
void init(int n){
	V = n;
	for(int i = 0 ; i < MAX_V ; i++ ){
		G[i].clear();
	}
}


// ノード番号 s を始点, 割引券の枚数を c としたダイクストラ法
int dijkstra(int s, int c, int g){
	// greater<State> を指定することで コスト が小さい順に取り出せる
	priority_queue<State, vector<State>, greater<State> > q;
	
	// d[c][v] := 割引券 c 枚でノード番号 v にたどり着く最小コスト
	int d[11][101];
	for(int i=0 ; i < 11 ; i++ ){
		for(int j=0 ; j < 101 ; j++ ){
			d[i][j] = INF;
		}
	}
	
	d[c][s] = 0;
	State start( 0 , P(s,c) );
	q.push( start );
	
	int result = INF;
	while( !q.empty() ){
		int now_cost = q.top().first;
		int v = q.top().second.first;
		int c =  q.top().second.second;
		q.pop();
		
		if( v == g ){
			result = now_cost;
			break;
		}
		
		if( d[c][v] < now_cost ) continue;
		
		for(int i=0 ; i < G[v].size() ; i++ ){
			edge e = G[v][i];
			
			int next_cost = d[c][v] + e.cost;
			if( next_cost < d[c][e.to] ){
				d[c][e.to] = next_cost;
				State next( next_cost , P(e.to,c) );
				q.push( next );
			}
			if( c > 0 ){
				next_cost = d[c][v] + e.cost/2 ;
				if( next_cost < d[c-1][e.to] ){
					d[c-1][e.to] = next_cost;
					State next( next_cost , P(e.to,c-1) );
					q.push( next );
				}
			}
		}
	}
	return result;
}

// 重み cost の辺 (u,v) の追加
void add_edge(int u, int v, int cost){
	edge e( v , cost );
	G[u].push_back( e );
	e.to = u;
	G[v].push_back( e );
}


int main(){
	int c,n,m,s,g;
	while( cin >> c >> n >> m >> s >> g, c || n || m || s || g ){
		init(n);
		s--; g--;
		for(int i=0 ; i < m ; i++ ){
			int u, v, cost;
			cin >> u >> v >> cost;
			u--; v--;
			add_edge(u,v,cost);
		}
		int ans = dijkstra( s , c , g );
		cout << ans << endl;
	}
}

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

int main() {
    map<string, int> m;
    int n;
    cin >> n;
    string s;
    rep(i, n) {
        cin >> s;
        m[s]++;
    }

    for (string s : {"AC", "WA", "TLE", "RE"}) {
        cout << s << " x " << m[s] << endl;;
    }
    
    return(0);
}


Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>


#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;

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

int main()   {
    cout.precision(17);
    ll modd = 1000 * 1000 * 1000 + 7;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
    ll infinit = 10000000000000000;


//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n); readll(k);
        vector<ll> a;
        multiset<ll> a_set;
        forr(i,0,n) {
            readll(kk); a.push_back(kk);
            a_set.insert(kk);
        }
        map<int,int> how_many_below;
        int so_far = 0;
        while (!a_set.empty()) {
            int smallest = *a_set.begin();
            how_many_below[smallest] = so_far;
            so_far += a_set.count(smallest);
            a_set.erase(smallest);
        }
        vector<int> kleene;
        forr(i,0,a.size()) {
            int ct = 0;
            for(int j = i+1; j < a.size(); ++j) {
                if (a[j]<a[i]) {ct++;}
            }
            kleene.push_back(ct);
        }

        ll ret = 0;
        forr(i,0,a.size()) {
            ret += k*kleene[i];
            ret = ret % modd;
            ret += ((((k*(k-1))/2) % modd) * how_many_below[a[i]]) % modd;
            ret = ret % modd;
        }
        
        cout << ret << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int N, L, ret, x[5000], a[5000], dp[5001][5001];
int main() {
	scanf("%d%d", &N, &L);
	for (int i = 0; i < N; i++) scanf("%d", &x[i]);
	for (int i = 0; i < N; i++) scanf("%d", &a[i]), a[i] = a[i] ? a[i] : L;
	dp[N][L] = 1;
	for (int i = N - 1; i >= 0; i--) {
		int sum = dp[i + 1][L];
		for (int j = L - 1; j >= 0; j--) {
			if (j >= x[i] && (j - x[i]) % a[i] == 0) {
				dp[i][j] = sum;
			}
			sum = (sum + dp[i + 1][j]) % 1000000007;
		}
	}
	for (int i = 0; i < L; i++) ret = (ret + dp[0][i]) % 1000000007;
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 69448
import math
def C(n,r):
  if n<0 or r<0 or n-r<0:
    return 0
  else:
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))
 
n,k=map(int,input().split())
for i in range(1,k+1):
  print(C(n-k+1,i)*C(k-1,i-1)%(10**9+7))

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

int main()
{
  string S;
  cin >> S;
  int i = 0;
  for (; i < 3; ++i)
    if (S[i] == S[i + 1])
      break;
  cout << (3 == i ? "Good" : "Bad");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

int n, m, k, sx, sy, fx, fy;
vector<vector<int>> vis, dis;
string s[N];

bool valid(int x, int y) {
    return x >= 0 && x < n && y >= 0 && y < m;
}

void bfs() {
    queue<PR> q;
    q.push({sx, sy});
    vis[sx][sy] = 1;
    while (!q.empty()) {
        PR u = q.front();
        q.pop();
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <= k; j++) {
                int x = (dx[i] * j) + u.first;
                int y = (dy[i] * j) + u.second;
                if (!valid(x, y)) {
                    continue;
                }
                if (s[x][y] == '@') {
                    break;
                }
                if (vis[x][y] == 1 && dis[u.first][u.second] + 1 > dis[x][y]) {
                    break;
                }
                if (vis[x][y] == 1) {
                    continue;
                }
                q.push({x, y});
                vis[x][y] = 1;
                dis[x][y] = dis[u.first][u.second] + 1;
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> k >> sx >> sy >> fx >> fy;
    sx--, sy--, fx--, fy--;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        vector<int> tmp(m, 0);
        vis.push_back(tmp);
        dis.push_back(tmp);
    }
    bfs();
    cout << (vis[fx][fy] == 1 ? dis[fx][fy] : -1) << '\n';
    return 0;
}


Measured memory_bytes: 47392
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//コピペするとこ


//-------------------------------------------------


int main()
{
  int n ;
  cin >> n ;
  vector<int> vec(n) ;
  REP(i,n){
    cin >> vec.at(i) ;
  }
  vector<int> memo(n,0) ;
  memo.at(0)=vec.at(0) ;
  
  int ans = vec.at(1)-vec.at(0) ;
  FOR(i,1,n){
    memo.at(i) = min(memo.at(i-1),vec.at(i)) ;
  }
  FOR(i,1,n){
    ans = max(vec.at(i)-memo.at(i-1),ans) ;
  }
  cout <<ans <<endl ;
    
  return 0 ;
}




Measured memory_bytes: 4388
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <stack>
using namespace std;

int main()
{
#if _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, x;
	cin >> n >> x;
	int l[100];
	for (int i = 0; i < n; ++i)
	{
		cin >> l[i];
	}
	int d = 0, i = 0;
	while (d <= x) {
		d += l[i++];
	}
	cout << i << endl;
	return 0;
}

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

char ch[4] = {'m','c','x','i'};
int num[4] = {1000,100,10,1};
int ans;
string mcxi;

void math(char wo, int n){

  for(int i = 0; i < 4; i++){
    if(wo == ch[i]){
      ans += num[i] * n;
    }
  }
}

void cg(int p){

  for(int i = 0; i < 4; i++){
    if(p / num[i] == 0) continue;
    else if(p / num[i] == 1){
      mcxi += ch[i];
      p -= num[i];
    }else {
      mcxi += ((p/num[i])+'0');
      mcxi += ch[i];
      p -= num[i] * (p/num[i]);
    }
  }
}

int main(){

  int n;
  string a, b;
  int judge = 0;
  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> a >> b;
    mcxi="";
    for(int t = 0; t < (int)a.size(); t++){
      for(int s = 2; s <= 9; s++){
	if(a[t]-'0' == s){
	  math(a[t+1],s);
	  t++;
	  judge = 1;
	}
      }
      if(judge == 0){
	math(a[t],1);
      }
      judge = 0;
    }
    for(int t = 0; t < (int)b.size(); t++){
      for(int s = 2; s <= 9; s++){
	if(b[t]-'0' == s){
	  math(b[t+1],s);
	  t++;
	  judge = 1;
	}
      }
      if(judge == 0){
	math(b[t],1);
      }
      judge = 0;
    }
    cg(ans);
    cout << mcxi << endl;
    ans = 0;
    mcxi.clear();
  }
}

Measured memory_bytes: 1200
public class Main {

  private static void solve() {
    int a = ni();
    int b = ni();
    System.out.println(a * b);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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


int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    
    //kがb-aの半分より大きい場合には全てを出力する
    if(b-a <= 2*k-1){
        for(int i=a; i<=b; i++){
            cout << i << endl;
        }
        return 0;
    }


    rep(i,k) cout << a+i << endl;
    //昇順に出力するため一旦ベクトルに入れて逆順にする
    vector<ll> temp(k);
    rep(i,k) temp[i] = b-i;
    reverse(all(temp));
    rep(i,k) cout << temp[i] << endl;

}

Measured memory_bytes: 3624