akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int h, w; cin >> h >> w;
	vi cnt(26);
	REP(i, h)
	{
		string s; cin >> s;
		for (auto c : s) cnt[c - 'a']++;
	}
	int c1 = 0, c2 = 0, c4 = 0;
	REP(i, 26)
	{
		c4 += cnt[i] / 4;
		c2 += cnt[i] % 4 / 2;
		c1 += cnt[i] % 4 % 2;
	}
	int n1 = 0, n2 = 0, n4 = 0;
	if (h % 2 == 0 && w % 2 == 0)
	{
		n4 = h * w / 4;
	}
	else if (h % 2 == 1 && w % 2 == 1)
	{
		n1 = 1;
		n2 = (h - 1) / 2 + (w - 1) / 2;
		n4 = (h * w - h - w + 1) / 4;
	}
	else
	{
		if (h % 2 == 1) swap(h, w);
		n2 = h / 2;
		n4 = (h * w - h) / 4;
	}
	bool f = true;
	if (n4 > c4) f = false;
	c4 -= n4;
	c2 += c4 * 2;
	if (n2 > c2) f = false;
	c2 -= n2;
	c1 += c2 * 2;
	if (n1 != c1) f = false;
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long[] sum = new long[n + 1];
			sum[0] = 0L;
			IntStream.rangeClosed(1, n).forEach(i -> sum[i] = sum[i - 1] + scanner.nextInt());
			// 左と右の配列のそれぞれ区切ったところ
			int left = 1, right = 3;
			long answer = Long.MAX_VALUE;
			for (int i = 2; i <= n - 2; i++) {
				while ((left < i - 1) && (Math.abs(sum[left] - (sum[i] - sum[left])) > Math
						.abs(sum[left + 1] - (sum[i] - sum[left + 1])))) {
					left++;
				}
				while ((right < n - 1) && (Math.abs((sum[right] - sum[i]) - (sum[n] - sum[right])) > Math
						.abs((sum[right + 1] - sum[i]) - (sum[n] - sum[right + 1])))) {
					right++;
				}
				answer = Math.min(answer,
						Math.abs(max(sum[left], sum[i] - sum[left], sum[right] - sum[i], sum[n] - sum[right])
								- min(sum[left], sum[i] - sum[left], sum[right] - sum[i], sum[n] - sum[right])));
			}
			System.out.println(answer);
		}
	}

	/**
	 * 複数のlongの最大値を取得する
	 * 
	 * @param longs 複数のlong
	 * @return 複数のlongの最大値
	 */
	private static long max(long... longs) {
		if (null != longs) {
			return Arrays.stream(longs).max().getAsLong();
		}
		return 0L;
	}

	/**
	 * 複数のlongの最小値を取得する
	 * 
	 * @param longs 複数のlong
	 * @return 複数のlongの最小値
	 */
	private static long min(long... longs) {
		if (null != longs) {
			return Arrays.stream(longs).min().getAsLong();
		}
		return 0L;
	}
}


Measured memory_bytes: 64052
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << (char)toupper(s1.front()) << (char)toupper(s2.front()) << (char)toupper(s3.front()) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define F  first
#define S  second
#define ff(i,n) for(i=0;i<n;i++)
int main()
{ 
	ll t;
	t=1;
	while(t--)
	{
		ll k,i,n;
		cin>>n>>k;
		ll arr[n];
		ff(i,n)
		   cin>>arr[i];
		sort(arr,arr+n); 
		ll ans=0;
		for(i=0;i<k;i++)
			ans+=arr[i];
		cout<<ans;	  
	}
	return 0;
}

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

int main()
{
    int n,m=0,c,s=0;
    cin>>n;
    while(n--)
    {
        cin>>c;
        if(m<c)m=c;
        s+=c;
    }
    s-=m/2;
    cout<<s<<endl;
    return 0;
}

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

rllist=[]
for _ in range(N):
  X,L=map(int,input().split())
  rllist.append((X+L,X-L))
rllist.sort()
#print(rllist)

answer=0
max_r=-float("inf")
for r,l in rllist:
  #print(max_r,l)
  if max_r<=l:
    answer+=1
    max_r=r
  
print(answer)

Measured memory_bytes: 22896
package main

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

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		d, w := io.NextInt(), io.NextInt()
		if d == 0 {
			break
		}
		e := make([][]int, d)
		for i := 0; i < d; i++ {
			e[i] = make([]int, w)
			for j := 0; j < w; j++ {
				e[i][j] = io.NextInt()
			}
		}
		ans := 0
		for i := 0; i < d-2; i++ {
			for j := 0; j < w-2; j++ {
				for k := i + 2; k < d; k++ {
					for l := j + 2; l < w; l++ {
						ans = intMax(vol(e, i, j, k, l), ans)
					}
				}
			}
		}
		io.Println(ans)
	}
}

func vol(e [][]int, a, b, c, d int) int {
	outer := 10
	for i := a; i <= c; i++ {
		outer = intMin(e[i][b], outer)
		outer = intMin(e[i][d], outer)
	}
	for j := b; j <= d; j++ {
		outer = intMin(e[a][j], outer)
		outer = intMin(e[c][j], outer)
	}
	a++
	b++
	vol := 0
	for i := a; i < c; i++ {
		for j := b; j < d; j++ {
			if e[i][j] >= outer {
				return 0
			}
			vol += outer - e[i][j]
		}
	}
	return vol
}

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

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

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}



Measured memory_bytes: 1364
/*
 *
 *  1. sprawdz corner cases
 *  2. sprawdz limity, jesli sie da pozamieniaj wszystkie lokalne zmienne na LL!
 *  3.  MINIMALNE I MAKSYMALNE WEJŚCIE I WYJŚCIE
 *  4. lokalne zmienne, iteracja po tablicach dwuwymiarowych uwazaj
 *  5. SPRAWDZ CZY input jest POSORTOWANY jaki jest niezmiennik
 *
 *
 */
#include <algorithm>
#include <cstdio>
#include <iomanip> // std::setprecision
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>
#define FOR(x, y, z) for (int x = (y); x < (z); x++)
#define FORD(x, y, z) for (int x = (y); x >= z; x--)
#define REP(r, n) for (int r = 0; r < (n); r++)
#define MP make_pair
#define ST first
#define ND second
#define SIZE(c) ((int)((c).size()))
#define FOREACH(i, x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define ALL(u) (u).begin(), (u).end()
#define RALL(u) (u).rbegin(), (u).rend()
#define PB push_back
#define PF push_front
#define SZ(x) long long((x).size())
#define IS_IN(x, t) (t.find(x) != t.end())
#define BIT(n, i) (((n) >> (i)) & 1)

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) \
    {              \
    }
#endif

#define TYPEMAX(type) std::numeric_limits<type>::max()
#define TYPEMIN(type) std::numeric_limits<type>::min()

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<LL> VI;
typedef pair<LL, LL> PR;

inline LL GCD(LL a, LL b)
{
    LL r;
    while (b) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
};
inline LL LCM(LL a, LL b) { return a / GCD(a, b) * b; };
inline LL fpow(LL n, LL k, LL p)
{
    LL r = 1;
    for (; k; k >>= 1) {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
};
inline LL inv(LL a, LL p) { return fpow(a, p - 2, p); }

[[maybe_unused]] const LL MOD = (LL)1e9 + 7;
[[maybe_unused]] const LL MAXUS = 100001;//TYPEMAX(LL);
[[maybe_unused]] const LD PI = acos((LD)-1);
[[maybe_unused]] const LD epsilon = 1e-9;

template <typename T>
T input()
{
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e)
{
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}
 
LL F[MAXUS];
LL ccnk(LL n, LL k) {
    cout << n << " " << k;
  if (k < 0 || k > n) return 0;
  return F[n] / F[k] / F[n-k];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    VI inp(n);
     LL sum1 = 0;
     LL sum2 = 0;
    REP(i,n) {
        cin >> inp[i];
        sum1 += inp[i] * inp[i];
        sum2 += inp[i]*2;
    }
    LL best_sum = -1;
    for (int k = -100; k <= 100; k++) {
        LL cur_sum = n * k * k + sum1 - sum2 * k;
        if (best_sum == -1  || best_sum > cur_sum) {
            best_sum = cur_sum;
        }
    }

    cout << best_sum  << endl;
    return 0;
}


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

const int N=200100,mod=1000000007;
typedef long long ll;
void gofail(){cout<<0<<'\n';exit(0);}

vector<int>vts,cir,g[N],g2[N];
stack<int>S;
int dfn[N],clk,fa[N],n,ans,inv[N],incir[N];

void dfs(int x,int fa=-1){
	dfn[x]=++clk;vts.push_back(x);S.push(x);
	for(int i:g[x])if(i!=fa){
		if(!dfn[i])dfs(i,x);
		else if(dfn[i]<dfn[x]){
			if(!cir.empty())gofail();
			for(;S.top()!=i;S.pop())cir.push_back(S.top());
			cir.push_back(i);S.pop();
		}
	}
	if(!S.empty()&&S.top()==x)S.pop();
}
int sz[N];
int gsz(int x){
	if(sz[x])return sz[x];sz[x]=1;
	for(int i:g2[x])sz[x]+=gsz(i);
	return sz[x];
}

void setfa(int x){
	for(int i:g[x])if(i!=fa[x])fa[i]=x,setfa(i);
}

int solve(){
	int ret=1;
	for(int i:vts){
		g2[i].clear();sz[i]=0;
		for(int j:g[i])if(j<fa[i])g2[i].push_back(j);
	}
	for(int i:vts)ret=(ll)ret*inv[gsz(i)]%mod;
	return ret;
}

void Init(){
	inv[1]=ans=1;
	for(int i=2;i<=n;++i)inv[i]=mod-mod/i*(ll)inv[mod%i]%mod,ans=(ll)ans*i%mod;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;n*=2;Init();
	for(int i=1;i<=n;++i){
		int x,y;cin>>x>>y;y+=n/2;
		g[x].push_back(y);g[y].push_back(x);
	}
	for(int i=1;i<=n;++i)if(!dfn[i]){
		vts.clear();cir.clear();dfs(i);if(cir.empty())gofail();
		int tmp=0;
		for(int j:cir)incir[j]=1;
		for(int j:cir)
			for(int k:g[j])if(!incir[k])fa[k]=j,setfa(k);
		int la=cir.back();
		for(int j:cir)fa[j]=la,la=j;tmp=(tmp+solve())%mod;
		la=cir.back();
		for(int j:cir)fa[la]=j,la=j;tmp=(tmp+solve())%mod;
		ans=(ll)ans*tmp%mod;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 26928
import java.io.*;
import java.util.*;


class Main {
    static ArrayList<Integer>[]g;
    static void dfs(int v,int p,int c,int[]d){
        d[v]=c;
        for(int w:g[v])
            if(w!=p)
                dfs(w,v,c+1,d);
    }
    @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        g=new ArrayList[n];
        Arrays.setAll(g,x->new ArrayList<Integer>());
        for(int i=0;i<n-1;++i){
            int a=sc.nextInt()-1;
            int b=sc.nextInt()-1;
            g[a].add(b);
            g[b].add(a);
        }
        int[]d0=new int[n],dn1=new int[n];
        dfs(0,-1,0,d0);
        dfs(n-1,-1,0,dn1);
        int fennec=0,snuke=0;
        for(int i=0;i<n;++i)
            if(d0[i]<=dn1[i])fennec++;
            else snuke++;
        out.println(fennec>snuke?"Fennec":"Snuke");
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 72348
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[100005];
ll a[100005];
ll n,k;
ll func(ll i)
{
	ll d,min1=LLONG_MAX,j;
	if(dp[i]!=-1)
		return dp[i];
	if(i==1)
		return 0;
	for(j=1;j<=k;j++)
	{
		if(i-j>=1)
		{
			d=func(i-j)+abs(a[i]-a[i-j]);
			if(min1>d)
				min1=d;
		}
	}
	dp[i]=min1;
	return dp[i];
}
int main()
{
	ll i;
	cin>>n>>k;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		dp[i]=-1;
	}
	cout<<func(n)<<endl;
}


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

int main(void) 
{
   int x;
   cin >> x;
   if(x >= 30) cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#define N 100

int isEmpty(void);
void enqueue(int);
int dequeue(void);
void BFS(int);

int n;
int A[N][N],c[N],d[N];
int Q[N];
int head=0,tail=0;

int main(){

  int i,j,l;
  int u,k;

  scanf("%d",&n);
  int B[n][n];
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(l=0;l<k;l++){
      scanf("%d",&B[i][l]);
    }
    for(j=0;j<n;j++){
      A[i][j]=0;
      for(l=0;l<k;l++){
	if(B[i][l]==j+1){
	  A[i][j]=1;
	}
      }
    }
  }
  BFS(0);
  for(i=0;i<n;i++){
    printf("%d %d\n",i+1,d[i]);
  }
  return 0;
}
int isEmpty(){
  if(head==tail) return 1;
  return 0;
}

void enqueue(int n){
  
  Q[tail]=n;
  if(tail+1==N){
    tail=0;
  }
  else{
    tail++;
  }
}

int dequeue(){

  int n;

  n=Q[head];
  if(head+1==N){
    head=0;
  }
  else{
    head++;
  }
  return n;
}

void BFS(int s){
  int i;
  int u,v;
  for(i=0;i<n;i++){
    c[i]=0;
    d[i]=-1;
  }
  c[s]=1;
  d[s]=0;
  enqueue(s);

  while(isEmpty()!=1){
    u=dequeue();
    for(v=0;v<n;v++){
      if(A[u][v]==1){
	if(c[v]==0){
	  c[v]=1;
	  d[v]=d[u]+1;
	  enqueue(v);
	}
      }
    }
    c[u]=2;
  }
}



Measured memory_bytes: 2112
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	a--, b--, c--, d--;
	// a -> c, b -> d;
	string s;
	cin >> s;
	int flag = 1;
	if (d > c) {
		
		for (int i = b + 1; i < d; i++) {
			if (s[i] == '#' && s[i-1] == '#') {
				flag = 0;
				break;
			}
		}

		for (int i = a + 1; i < c; i++) {
			if (s[i] == '#' && s[i-1] == '#') {
				flag = 0;
				break;
			}
		}		
	}
	else {
		int find3 = 0;
		for (int i = b; i <= d; i++) {
			if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
				find3 = 1;
				break;
			}
		}
		
		if (find3 == 0) {
			flag = 0;
		}
		
		for (int i = a + 1; i < c; i++) {
			if (s[i] == '#' && s[i-1] == '#') {
				flag = 0;
				break;
			}
		}
	}

	if (flag == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}














Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
#define par pair<pair<int,int>, int>
#define f first
#define s second

int h,w,vis[25][25],mx;
char s[25][25];

int X [] = {0 ,0 ,1 ,-1};
int Y [] = {1 ,-1, 0, 0};

bool valid(int x, int y)
{
    return (x >-1 && x<h && y>-1 && y<w);
}

int bfs(int x, int y)
{
    int ans =0 ;
    if(s[x][y] == '#') return 0;
    queue <par> q;
    q.push({{x, y},0});
    while(!q.empty())
    {
        par fron = q.front();
        q.pop();
        if(fron.s < vis[fron.f.f][fron.f.s])
        {
            ans = max(ans, fron.s);
            vis[fron.f.f][fron.f.s] = fron.s;
            for(int i=0; i<4; i++)
            {
                x = X[i]+fron.f.f;
                y = Y[i]+fron.f.s;
                if(valid(x, y) && s[x][y] != '#' && (fron.s)+1 < vis[x][y])
                {
                    q.push({{x,y},fron.s+1});
                }
            }
        }
    }
    return ans;
}

void visite()
{
    for(int i=0; i<=h; i++)
    {
        for(int j=0; j<=w; j++)
        {
            vis[i][j] = oo;
        }
    }
}

int main()
{
    scanf("%d%d",&h,&w);
    for(int i=0; i<h; i++)
    {
        scanf("%s",&s[i][0]);
    }
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            visite();
            mx = max(mx, bfs(i,j));
        }
    }
    printf("%d",mx);
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.math.*;
import java.util.*;

public class Main {
	 static InputReader in = new InputReader(System.in);
	 static PrintWriter out = new PrintWriter(System.out);
	 
	 public static void main(String[] args) throws Exception {
		 int n = in.nextInt();
		 int b = in.nextInt();
		 int[] arr =in.intArr();
		 int dis =0;
		 for(int i=0; i<n; i++)
		 {
			 dis+=Math.min(arr[i],Math.abs(b-arr[i]));
		 }
		 
		 out.println(dis*2);
		 out.close();
		 
		 
	
	 }
	 static class InputReader {
	        public BufferedReader reader;
	        public StringTokenizer tokenizer;
	 
	        public InputReader(InputStream stream) {
	            reader = new BufferedReader(new InputStreamReader(stream), 32768);
	            tokenizer = null;
	        }
	 
	        public String next() {
	            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	                try {
	                    tokenizer = new StringTokenizer(reader.readLine());
	                } catch (IOException e) {
	                    throw new RuntimeException(e);
	                }
	            }
	            return tokenizer.nextToken();
	        }
	 
	        public int nextInt() {
	            return Integer.parseInt(next());
	        }
	 
	        public long nextLong() {
	            return Long.parseLong(next());
	        }
	 
	        public double nextDouble() {
	            return Double.parseDouble(next());
	        }
	 
	        public String nextLine() {
	            try {
	                return reader.readLine();
	            } catch (Exception e) {
	                e.printStackTrace();
	            }
	            return null;
	        }
	 
	        public boolean hasNext() {
	            String next = null;
	            try {
	                next = reader.readLine();
	            } catch (Exception e) {
	            }
	            if (next == null) {
	                return false;
	            }
	            tokenizer = new StringTokenizer(next);
	            return true;
	        }
	 
	        public BigInteger nextBigInteger() {
	            return new BigInteger(next());
	        }
	        
	       public int[] intArr() throws Exception {
	            String[] strarray = reader.readLine().trim().split(" ");
	            int[] intarray = new int[strarray.length];
	            for (int i = 0; i < intarray.length; i++) {
	                intarray[i] = Integer.parseInt(strarray[i]);
	            }
	            return intarray;
	    }
	}
}

Measured memory_bytes: 32944
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[100005];
ll ar[100005];
ll n,k;
ll f(ll ind){
	if(ind==n) return 0;
	if(dp[ind]>=0) return dp[ind];
	ll res = 10000000000;
	for(ll i=ind+1;i<=min(n,ind+k);i++){
		//cout<<i<<" "<<ind<<"\n";
		res = min(res,f(i)+abs(ar[ind]-ar[i]));
	}
	return dp[ind]=res;
}

int main(){
	cin>>n>>k;
	fill(dp,dp+n,-1);
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	cout<<f(1);
}


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

using namespace std;

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

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

	sort(p.begin(), p.end());

	int ans = 0;
	for (int i = 0; i < K; i++) {
		ans += p[i];
	}

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


Measured memory_bytes: 3596
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

r,d,x = i2()
for i in range(10):
	x  = r*x - d
	print(x)
	

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N; 
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }
    
    sort(d.begin(), d.end());
    
    int left, right;
    left = d[N / 2 - 1];
    right = d[N / 2];
    int ans = right - left;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
/*
元号	期間
meiji	1868. 9. 8	〜	1912. 7.29
taisho	1912. 7.30	〜	1926.12.24
showa	1926.12.25	〜	1989. 1. 7
heisei	1989. 1. 8	〜
*/
bool comp (int y1, int m1, int d1, int y2, int m2, int d2, bool flag )
{
	if (y1 != y2 ) return y1 < y2;
	if (m1 != m2 ) return m1 < m2;
	return (flag ? d1 <= d2 : d1 < d2 );
}


int main()
{
//	cut here before submit 
//	freopen ("testcase.era_name_transformation2", "r", stdin );
	const int y[] = {INT_MIN, 1868, 1912, 1926, 1989, INT_MAX };
	const int m[] = {INT_MIN,    9,    7,   12,    1, INT_MAX }; 
	const int d[] = {INT_MIN,    8,   30,   25,    8, INT_MAX };
	const string gengo[] = { "pre-meiji", "meiji", "taisho", "showa", "heisei" };
	int n = sizeof (y)/sizeof (y[0] );

	int year, month, day;
	while (scanf ("%d %d %d", &year, &month, &day ) != EOF ){
		rep (i, n - 1 ){
			if (comp (y[i], m[i], d[i], year, month, day, true ) 
			 && comp (year, month, day, y[i+1], m[i+1], d[i+1], false ) ){
				if (i ==  0 ){
					cout << gengo[i] << endl;
				}else{
					cout << gengo[i] << ' ' << (year - y[i] + 1) << ' ' << month << ' ' << day << endl;
				} // end if
				break;
			} // end if
		} // end rep
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1224
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

int n, m, q;
int a[50], b[50], c[50], d[50];
vector<int> cur;

int solve(int now) {
	if(now == n) {
		int res = 0;
		for(int i = 0; i < q; i++) {
			if(cur[b[i]]-cur[a[i]] == c[i])
				res += d[i];
		}
		return res;
	}
	int mn = 1, res = 0;
	if(now)
		mn = cur.back();
	for(int i = mn; i <= m; i++) {
		cur.push_back(i);
		res = max(res, solve(now+1));
		cur.pop_back();
	}
	return res;
}

signed main() {
	EmiliaMyWife

	cin >> n >> m >> q;
	for(int i = 0; i < q; i++)
		cin >> a[i] >> b[i] >> c[i] >> d[i], a[i]--, b[i]--;
	cout << solve(0);

	return 0;
}


Measured memory_bytes: 3656
from math import sin,cos,pi
a, b, h, m = [int(i) for i in input().split()]
t = (h + m / 60)*2*pi

ax, ay = a * cos(t / 12), a * sin(t / 12)
bx, by = b * cos(t), b * sin(t)
print(((ax-bx)**2+(ay-by)**2)**0.5)


Measured memory_bytes: 9564
#include<bits/stdc++.h>
using namespace std;
int main(){
  long A[7];
  for(int i=0;i<7;i++)cin>>A[i];
  long ans=(A[0]/2+A[3]/2+A[4]/2)*4;
  if(A[0]>0&&A[3]>0&&A[4]>0){
    ans=max(ans,((A[0]-1)/2+(A[3]-1)/2+(A[4]-1)/2)*4+6);
  }
  ans+=A[1]*2;
  cout<<ans/2;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int t,h,m,s;
	scanf("%d",&t);
	h=t/3600;
	m=(t%3600)/60;
	s=(t%3600)%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

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

int main() {
  int n, x, r = 0, c = 1;
  cin >> n >> x;
  for(int i = 0; i < n; i++){
    int p;
    cin >> p;
    r += p;
    if(r <= x)
      c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#n,k=map(int,input().split())
from collections import defaultdict
n=int(input())
l=list(map(int,input().split()))
d=defaultdict(int)
s=0
for i in l:
  d[i]+=1
  s+=i

q=int(input())
for _ in range(q):
  a,b=map(int,input().split())
  temp=a*d[a]
  if temp==0:
    print(s)
  else:
    k=b*d[a]
    s+=k-temp
    print(s)
    d[b]+=d[a]
    del d[a]




Measured memory_bytes: 24196
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl
const int NIL = -1;

struct Node {
  int p, l, r;
  int location;
};
struct Point {
  int id, x, y;
  bool operator < (const Point& p) const {
    return id < p.id;
  }
};
const int MAX = 1000000;
Point P[MAX];
Node T[MAX];
int np;
vector<Point> ans;

bool lessX(const Point& p1, const Point& p2) { return p1.x < p2.x; }
bool lessY(const Point& p1, const Point& p2) { return p1.y < p2.y; }
int makeKDTree(int l, int r, int depth) {
  if (l >= r)
    return NIL;
  int mid = l + (r - l) / 2;
  int t = np;
  ++np;
  sort(P + l, P + r, depth % 2 == 0 ? lessX : lessY);
  T[t].location = mid;
  T[t].l = makeKDTree(l, mid, depth + 1);
  T[t].r = makeKDTree(mid + 1, r, depth + 1);
  return t;
}
void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
  int x = P[T[v].location].x;
  int y = P[T[v].location].y;

  if (sx <= x && x <= tx && sy <= y && y <= ty)
    ans.push_back(P[T[v].location]);
  if (depth % 2 == 0) {
    if (T[v].l != NIL && sx <= x)
      find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
    if (T[v].r != NIL && x <= tx)
      find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
  } else {
    if (T[v].l != NIL && sy <= y)
      find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
    if (T[v].r != NIL && y <= ty)
      find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
  }
}
int main() {
  IN(N);
  REP(i, N) {
    IN(x); IN(y);
    P[i] = Point();
    P[i].id = i;
    P[i].x = x; P[i].y = y;
  }
  np = 0;
  int root = makeKDTree(0, N, 0);

  IN(Q);
  REP(i, Q) {
    IN(sx); IN(tx);
    IN(sy); IN(ty);
    ans.clear();
    find(root, sx, tx, sy, ty, 0, ans);
    sort(ALL(ans));
    for (const auto& e : ans) {
      cout << e.id << "\n";
    }
    cout << "\n";
  }

  return 0;
}



Measured memory_bytes: 16304
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

void bfs(vector<long>& minpath, queue<pair<long, long>> imfo, vector<vector<long>> tree, vector<bool> reached) {
	
	while (!imfo.empty()) {

		long node, cost;
		node = imfo.front().first;
		cost = imfo.front().second;
		imfo.pop();

		if (reached[node]) continue; else reached[node] = true;

		minpath[node] = cost;

		for (long e : tree[node]) {
			imfo.emplace(e, cost + 1);
		}

	}
}

int main() {

	long N, M; cin >> N >> M;
	vector<vector<long>> tree(3 * N);

	for (int i = 0; i < M; i++) {
		long u, v; cin >> u >> v;
		u--; v--;
		//グラフの三倍化0 -> 3N - 1
		tree[u].push_back(v + N);
		tree[u + N].push_back(v + 2 * N);
		tree[u + 2 * N].push_back(v);
	}

	long S, T; cin >> S >> T;
	S--; T--;

	//tree[S]からtree[T]までの最短経路
	//BFS

	vector<long> minpath(3 * N);//最短コスト
	queue<pair<long, long>> imfo;//情報(頂点,コスト)
	vector<bool> reached(3 * N); //到達済みか

	for (int i = 0; i < 3 * N; i++) { minpath[i] = INT_MAX; reached[i] = false; }

	imfo.emplace(S, 0);

	bfs(minpath, imfo, tree, reached);


	if (minpath[T] == INT_MAX) { cout << -1 << endl; return 0; }
	minpath[T] /= 3;
	cout << minpath[T] << endl;
}

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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

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

  Int n,m;
  while(cin>>n>>m,n||m){
    vector<Int> as(n);
    for(Int i=0;i<n;i++) cin>>as[i];
    Int need=m/n;
    
    Int ans=0;
    for(Int i=0;i<n;i++)
      ans+=min(as[i],need);
    cout<<ans<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3176
public class Main {

  private static void solve() {

    String s = next();
    if (s.equals("RRR")) {
      System.out.println(3);
    } else if (s.startsWith("RR") || s.endsWith("RR")) {
      System.out.println(2);
    } else if (s.equals("SSS")) {
      System.out.println(0);
    } else {
      System.out.println(1);
    }

  }

  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: 36772
#include <bits/stdc++.h>

using namespace std;

using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int INF = 1000000000;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<llong> A(n);
    rep(i, n) cin >> A[i];

    llong max_height = A[0];
    llong res = 0;
    rep(i, n) {
        if (max_height > A[i]) {
            res += max_height - A[i];
        } else {
            max_height = A[i];
        }
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 4752
#include <bits/stdc++.h>
 
using namespace std;
 
#define f(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int> >
#define ss second
#define ff first
#define ll long long
#define lld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define pqll priority_queue< ll >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define INF 1000000000
#define NINF -1000000000
#define endl '\n'
 
// void print_vi(vi a){
//     for (auto i: a){
//         cout << i << " " ;
//     }
//     cout << endl;
// }
 
void solve(){

    int n;
    cin >> n;
    int count = 0;
    vi a (n);
    for (int i = 0 ; i < n ; i++){
        cin >> a[i];
        if ((a[i] %2) && ((i+1) % 2)){
            count++;
        }
    }
    cout << count;
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
 
 
    int t = 1;
    // cin >> t;
    
    while(t--){ 
        solve();
        cout << endl;
    }
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, m, q;
vector< vector<int> > train(550, vector<int>(550, 0));
vector< vector<int> > sum(550, vector<int>(550, 0));

int main() {
    cin >> n >> m >> q;
    for(int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        train.at(l).at(r)++;
    }
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            sum.at(i+1).at(j+1) = sum.at(i).at(j+1) + sum.at(i+1).at(j) - sum.at(i).at(j) + train.at(i).at(j);
        }
    }

    for(int i = 0; i < q; ++i) {
        int l, r;
        cin >> l >> r;
        int ans = sum.at(r).at(r) - sum.at(l-1).at(r) - sum.at(r).at(l-1) + sum.at(l-1).at(l-1);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
double pi = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(0);
    int r;
    cin>>r;
    cout<<fixed<<setprecision(8)<<pi*r*2;
    return 0;
}

Measured memory_bytes: 3800
//
// Created on 2020/01/10.
//

#include <bits/stdc++.h>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;
using gragh = vector<vector<int>>;

int main() {
    int N;
    cin>>N;
    vector<int> v(N);
    iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
    int a;
    int b;
    vector<int>p(N,0);
    vector<int>q(N,0);
    for (int i = 0; i < N; ++i) {
        cin>>p[i];
    }
    for (int j = 0; j < N; ++j) {
        cin>>q[j];
    }
    int count = 1;
    do {
            if(v == p){
                a = count;
            }
            if(v == q) {
                b = count;
            }
        count ++;
         //cout << x << " "; cout << "\n";    // v の要素を表示
    } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成

    cout<<abs(a-b)<<endl;
}



Measured memory_bytes: 256
number = int(input())
rate = [int(i) for i in input().split()]


# In[7]:

counter = {}
for r in rate:
    if 1 <= r < 400:
        counter["grey"] = counter.get("grey", 0) + 1
    if 400 <= r < 800:
        counter["brown"] = counter.get("brown", 0) + 1
    if 800 <= r < 1200:
        counter["green"] = counter.get("green", 0) + 1
    if 1200 <= r < 1600:
        counter["sky"] = counter.get("sky", 0) + 1
    if 1600 <= r < 2000:
        counter["blue"] = counter.get("blue", 0) + 1
    if 2000 <= r < 2400:
        counter["yellow"] = counter.get("yellow", 0) + 1
    if 2400 <= r < 2800:
        counter["orange"] = counter.get("orange", 0) + 1
    if 2800 <= r < 3200:
        counter["red"] = counter.get("red", 0) + 1
    if 3200 <= r:
        counter["color"] = counter.get("color", 0) + 1

answer = 0
for k, v in counter.items():
    if not v == 0:
        answer += 1
        
if counter.get("color", 0) == 0:
    print(str(answer) + " " + str(answer))
else:
    if answer == 1:
        print("1 " + str(counter["color"]))
    else:
        print(str(answer-1) + " " + str(answer-1+counter["color"]))


Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;
const string YES = "YES";
const string NO = "NO";

int main()
{
  std::string S;
  std::cin >> S;
  int a[3] = {};
  for (int i = 0; i < S.size(); ++i)
    a[S[i] - 'a']++;
  int nmin = min({a[0], a[1], a[2]});
  a[0] -= nmin;
  a[1] -= nmin;
  a[2] -= nmin;
  int nmax = max({a[0], a[1], a[2]});
  if (nmax > 1)
    cout << NO << endl;
  else
    cout << YES << endl;

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
void read() {}
template<class T, class... Arg>
void read(T &x, Arg&&... args) {
	cin >> x;
	read(args...);
}
void print_err() {
	cerr << "\n";
}
template <class T, class... Arg>
void print_err(T x, Arg&&... args) {
	cerr << x << " ";
	print_err(args...);
}
template<class T>
void print_container(T &cont) {
	for (auto iter : cont) {
		cerr << iter << " ";
	}
	cerr << "\n";
}
#ifdef local
#define debug(...) print_err(__VA_ARGS__)
#define debug_c(container) print_container(container)
#else
#define debug(...)
#define debug_c(container)
#endif
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define vl vector<ll>
#define vpll vector<pair<ll,ll>>
#define mll map<ll,ll>
#define mllrev map<ll,ll,greater<int>>
#define ps(x,y) fixed<<setprecision(y)<<x//it will give upto y decimal places
#define w(t) ll t;cin>>t;while(t--)
#define fo(i,n) for(ll i=0;i<n;++i)
#define foab(i,a,b) for(ll i=a;i<b;++i)
#define inp cin>>
#define pr cout<<
#define pqb priority_queue<ll>//max heap
#define pqs priority_queue<ll,vl,greater<int>>//min heap
#define mk(arr,n,type) type *arr=new type[n];
#define all(A) (A).begin(),(A).end()
#define fastio ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define mem(a,val) memset(a,val,sizeof(a))
template<class T>
void debug_arr(T arr, ll st, ll en) {
	foab(i, st, en) {
		cerr << arr[i] << " ";
	}
	cerr << endl;
}
template<class T>
void read_arr(T arr, ll n) {
	fo(i, n) {
		cin >> arr[i];
	}
}
template<class T>
void read_c(T &arr, ll n) {
	fo(i, n) {
		cin >> arr[i];
	}
}
void CP() {
	fastio
#ifdef local
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
	return;
}
char* stringTOCharArray(string str) {
	ll n = str.length();
	mk(ch, n + 1, char);
	strcpy(ch, str.c_str());
	return ch;
}
class Graph {
public:
	list<ll> *adj_list;
	ll v;
	Graph(ll v) {
		this->v = v;
		adj_list = new list<ll>[v];
	}
	void add_edge(ll u, ll v, bool bidirectional = true) {
		adj_list[u].push_back(v);
		if (bidirectional) {
			adj_list[v].push_back(u);
		}
	}
	void print();
	void connected_compo();
	void dfs(vector<vector<ll>> vect, ll k1, ll k2, ll n);
	void bfs(ll v, bool visited[]);
};
const int d4i[4] = { -1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};
const int d8i[8] = { -1, -1, 0, 1, 1, 1, 0, -1}, d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};
void solve() {
	ll n;
	read(n);
	ll arr[n];
	read_arr(arr, n);
	// debug_arr(arr, 0, n);
	ll ans = 0, temp = arr[0];
	foab(i, 1, n) {
		if (arr[i] > temp) {
			temp = arr[i];
		} else {
			ans += (temp - arr[i]);
		}
	}
	cout << ans << endl;
	return ;
}
int main() {
	CP();
	// w(t) {
	solve();
	// }
	return 0;
}

Measured memory_bytes: 5208
// JavaScript source code
"use strict";

function main(input) {
    input = input.split(" ");
    for (let i = 0; i < 5; i++) {
        if (input[i] == 0) {
            console.log(i + 1);
            break;
        }
    }
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29624
S = input()
l = len(S)
cnt = 0
for i in range(l):
    if (i % 2 == 0 and (S[i] == 'R' or S[i] =='U' or S[i] =='D')) or (i % 2 != 0 and (S[i] == 'L' or S[i] =='U' or S[i] =='D')):
        cnt += 1
    else:
        cnt = 0
if cnt == l:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
x = 0
# for a in A:
#     print(bin(a))
# print()
for a in A:
    x ^= a
idx = 0
for i in range(59, -1, -1):
    if x>>i & 1 == 0:
        for j, a in enumerate(A[idx:], idx):
            if a>>i & 1:
                break
        else:
            continue
        A[idx], A[j] = A[j], A[idx]
        for j in range(N):
            if j != idx and A[j] >> i & 1:
                A[j] ^= a
        idx += 1
s = 0
#for a in A:
#    print(bin(a))
for a in A:
    s ^= a
#print(f"s={bin(s)}")
for i in range(60):
    if x>>i & 1 == 1 and s>>i & 1:
        s ^= 1<<i
#print(x, s)
print(x + (s<<1))


Measured memory_bytes: 16116
n,S[10][6];w[10],s[10];W[1024],B[1024],G[10][1024];R(f,F){int*p=G[f]+F,i,g,m;m=F?*p?*p:1e9:w[f];for(i=m==1e9?n:0;i--;F&g&&s[i]>=W[F^g]&&(g=R(i,F^g)+W[F])<m?B[m=g,F]=i:0)g=1<<i;return*p=m;}main(f,F){for(;~scanf("%d",&n);){for(f=n;f--;)scanf("%s%d%d",S[f],w+f,s+f);for(F=1<<n;F--;)for(W[F]=f=0;f<n;G[f++][F]=0)F&1<<f?W[F]+=w[f]:0;for(R(0,F=(1<<n)-1);F;F^=1<<f)puts(S[f=B[F]]);}}

Measured memory_bytes: 0
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define endl '\n'
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}


i64 P[65050];
i64 J[65050];
i64 s[65060];
i64 r[65060];
i64 num[65060];

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

    int N;
    while(cin >> N, N) {
        for (int i = 0; i < N; ++i) cin >> P[i];
        for (int i = 0; i < N-1; ++i) cin >> J[i];

        sort(P, P+N, greater<>());
        sort(J, J+N-1, greater<>());
        memset(s, 0, sizeof(s));
        memset(r, 0, sizeof(r));
        for (int i = 0; i < N; ++i) {
            s[i+1] = P[i];
            s[i+1] += s[i];
        }
        for (int i = 0; i < N-1; ++i) {
            r[i+1] = J[i];
            r[i+1] += r[i];
        }

        for (int i = 0; i < N; ++i) num[i] = N - i;

        i64 ans = 0;
        for (int k = 0; k < N; ++k) {
            chmax(ans, num[k] * (s[N] + r[k]));
        }
        cout << ans << endl;

    }
    return 0;
}



Measured memory_bytes: 5640