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

int main()
{
    long long t,a,k;
    cin>>t>>a>>k;
    
    if(k<=t)
    {
        t=t-k;
        k=0;
    }
    else
    {
        k=k-t;
        t=0;
    }
    if(k<=a)
    {
        a=a-k;
        k=0;
    }
    else
    {
        
        k=k-a;
        a=0;
    }
    
    cout<<t<<" "<<a;
    
    return 0;
}

Measured memory_bytes: 3600
from decimal import Decimal
a,b,c = map(int,input().split())
a = a ** Decimal("0.5")
b = b ** Decimal("0.5")
c = c ** Decimal("0.5")
a_b = a + b
#print(a,b,c,a_b)
if c > a_b:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 59628
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef pair <ii,int> iii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int a, b, c, x, y, xx, yy, res, i;

int main() {
scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
res = INF;
for (i=0;i<=max(x, y);i++) {
	xx = max(0, x - i);
	yy = max(0, y - i);
	res = min(res, 2 * i * c + xx * a + yy * b);
}
printf("%d\n", res);
return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    long double L;
    cin >> L;

    cout << fixed << setprecision(10) << (L / 3.0) * (L / 3.0) * (L / 3.0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){

    int n, x;
    std::cin >> n >> x;

    int l[n+1];
    for(int i=1; i<n+1; i++){
        std::cin >> l[i];
    }

    int d = 0;
    int temp = 0;
    bool isOver = false;
    for(int i=1; i<n+1; i++){
        d = d + l[i];

        if( d > x ){
            isOver = true;
            std::cout << i << std::endl;
            break;
        }
    }

    if(isOver == false){
        std::cout << n+1 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

def main():
    n = input().rstrip()
    k = int(input())
    dp = [[[0 for l in range(2)] for j in range(k + 1)] for i in range(len(n) + 1)]
    dp[0][0][0] = 1
    for i in range(len(n)):
        for j in range(k+1):
            for l in range(2):
                x = int(n[i])
                for d in range(10):
                    n_i = i+1
                    n_j = j
                    n_l = l
                    if d != 0:
                        n_j += 1
                    if n_j > k:
                        continue
                    if l == 0:
                        if d > x:
                            continue
                        if d < x:
                            n_l = 1
                    dp[n_i][n_j][n_l] += dp[i][j][l]
    print(dp[len(n)][k][0] + dp[len(n)][k][1])

if __name__ == '__main__':
    main()

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

int parent(int);
int left(int);
int right(int);
void maxHeapify(int*,int);
void buildMaxHeap(int*);

int h;

int main(){
  int l,r,*A;
  int i;

  scanf("%d",&h);
  A = (int *)malloc(sizeof(int)*(h+1));
  for(i=1;i<=h;i++){
    scanf("%d",&A[i]);
  }

  buildMaxHeap(A);
  
  for(i=1;i<=h;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return i*2;
}

int right(int i){
  return i*2+1;
}

void maxHeapify(int* A,int i){
  int l,r,largest,tmp;
  
  l = left(i);
  r = right(i);

  if(l<=h && A[l]>A[i]) largest = l;
  else largest = i;

  if(r<=h && A[r]>A[largest]) largest = r;
  
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A,largest);
  }

  return;
}

void buildMaxHeap(int* A){
  int i;
  
  for(i=h/2;i>0;i--) maxHeapify(A,i);
  return;
}

Measured memory_bytes: 2552
#![allow(unused_imports, dead_code, unused_variables, unused_mut)]
use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use permutohedron::LexicalPermutation;
const INF: i32 = std::i32::MAX;
const MOD: i32 = 1e9 as i32 + 7;

struct Get<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
}
impl<R: std::io::BufRead> Get<R> {
    pub fn new(stdin: R) -> Self {
        Get {
            stdin: stdin,
            v: Vec::new(),
            i: 0,
        }
    }
    fn split_line(&mut self) {
        self.i = 0;
        self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        let mut ws = buf.split_whitespace();
        loop {
            let x = ws.next();
            if x.is_none() {
                break;
            }
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
    #[allow(dead_code)]
    pub fn once<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {
            self.split_line();
        }
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
    #[allow(dead_code)]
    pub fn line<T: std::str::FromStr>(&mut self) -> String {
        self.i = 0;
        self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        buf
    }
}

fn main() {
    let stdin = std::io::stdin();
    let stdin = std::io::BufReader::new(stdin.lock());
    let get = Get::new(stdin);
    solve(get);
}

fn solve<R: std::io::BufRead>(mut get: Get<R>) {
    let n: usize = get.once(); 
    let mut map = HashMap::new();
    map.insert("AC".to_string(), 0);
    map.insert("WA".to_string(), 0);
    map.insert("TLE".to_string(), 0);
    map.insert("RE".to_string(), 0);
    for i in 0..n {
        let s: String = get.once();
        *map.entry(s).or_insert_with(|| 0) += 1;
    }
    println!("AC x {}", map.get("AC").unwrap());
    println!("WA x {}", map.get("WA").unwrap());
    println!("TLE x {}", map.get("TLE").unwrap());
    println!("RE x {}", map.get("RE").unwrap());
}


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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  for(int i = A; i <= A*B; i+=A){
    if(i%B == C){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
int f(int x){
  int res=0;
  if(x%2==1){
    if((x-1)%4==0)return 1;
    else return 0;
  }
  else{
    if(x%4==0){
      return x;
    }
    else{
      return x+1;
    }
  }
  
}
signed main(){
  int a,b;cin>>a>>b;
  if(a==0)++a;
  cout<<(f(a-1)^f(b))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stdio.h>
#include<algorithm>
#include<string>
using namespace std;
class oppal{
public:
	int num[6],tmp;
	void moveS(){
		tmp = num[0];
		num[0] = num[4];
		num[4] = num[5];
		num[5] = num[1];
		num[1] = tmp;
	}
	void moveN(){
		tmp = num[0];
		num[0] = num[1];
		num[1] = num[5];
		num[5] = num[4];
		num[4] = tmp;
	}
	void moveW(){
		tmp = num[0];
		num[0] = num[2];
		num[2] = num[5];
		num[5] = num[3];
		num[3] = tmp;
	}
	void moveE(){
		tmp = num[0];
		num[0] = num[3];
		num[3] = num[5];
		num[5] = num[2];
		num[2] = tmp;
	}
};
int main(){
	string move;
	oppal a;
	for (int i = 0; i < 6; i++){
		cin >> a.num[i];
	}

	cin >> move;

	for (int i = 0; i < move.size(); i++){
		if (move[i] == 'S'){
			a.moveS();
		}
		else if (move[i] == 'N'){
			a.moveN();
		}
		else if (move[i] == 'W'){
			a.moveW();
		}
		else if (move[i] == 'E'){
			a.moveE();
		}
	}

	cout << a.num[0] << endl;

	return 0;
}


Measured memory_bytes: 3144
#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;
#pragma endregion

#pragma region const
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;
#pragma endregion

#pragma region util
#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(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

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;
}
#pragma endregion

#pragma region init
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

int main()
{
	i64 S;
	cin >> S;

	set<i64> ret;
	ret.insert(S);

	i64 ans = 1;
	i64 s = S;
	FOR(i, 2, 1000000)
	{
		s = s % 2 == 0 ? s / 2 : s * 3 + 1;
		set<i64>::iterator it = ret.find(s);
		if (it == ret.end())
		{
			ret.insert(s);
		}
		else
		{
			ans = i;
			break;
		}
	}

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


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))

h, w = inm()
grid = []
for i in range(h):
    s = ins()
    if "#" in s:
        grid.append(list(s))
remove = []
for i in range(w):
    tmp = True
    for x in grid:
        if x[i] == "#":
            tmp = False
            break
    if tmp:
        remove.append(i)
for i in remove[::-1]:
    for x in grid:
        x.pop(i)
for i in grid:
    print("".join(i))

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

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

    int ans_A, ans_B;
    for (int i = -118; i <= 119; i++)
    {
        for (int j = -119; j <= 118; j++)
        {
            long long now = pow(i, 5) - pow(j, 5);
            if (now == x)
            {
                cout << i << " " << j;
                return 0;
            }
            
        }
        
    }
    

    
}

Measured memory_bytes: 4056
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  char a[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>a[i][j];
    }
  }
  cout<<a[0][0]<<a[1][1]<<a[2][2]<<endl;
}

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

int main(){
#ifndef ONLINE_JUDGE
    freopen("ip.txt", "r", stdin);
    freopen("op.txt", "w", stdout);
#endif
	string s, t, ans;
	cin >> s >> t;
	int n = s.length(), m = t.length();

	int dp[n +1][m +1];
	memset(dp, 0, sizeof dp);

	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= m; ++j){
			if(s[i -1] == t[j -1]){
				dp[i][j] = 1 + dp[i -1][j -1];
			}else{
				dp[i][j] = max(dp[i -1][j], dp[i][j -1]);
			}
		}
	}

	int i = n, j = m;
	while(i > 0 and j > 0){	
		if(s[i -1] == t[j -1]){
			ans += s[i -1];
			--i, --j;
		}else if(dp[i -1][j] > dp[i][j -1]){
			--i;
		}else{
			--j;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

Measured memory_bytes: 38788
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var s = Console.ReadLine();
        var t = Console.ReadLine();
        var res = Enumerable.Range(0, s.Length - t.Length + 1).Min(x => s.Substring(x, t.Length).Zip(t, (x, y) => x == y ? 0 : 1).Sum());
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 27076
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<map>
#include<cstdio>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1e13
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define MOD 1000000007
#define MAX_H 101
#define MAX_W 101


typedef struct island{

    int treasure;
    int weight;

}ISLAND;

 
bool comp(const ISLAND& a,const ISLAND& b){
 
    return a.weight < b.weight;

}
 


int main(){

    int n;
    while(cin >> n,n){

        bool ans = true;
        vector<ISLAND> mp(n);
        REP(i,n){
            cin >> mp[i].treasure >> mp[i].weight;
        }
        sort(mp.begin(),mp.end(),comp);
        
        int total_weight = 0;

        REP(i,n){
            total_weight += mp[i].treasure;
            if(total_weight > mp[i].weight){
                ans = false;
            }
        }
        if(ans){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }


    return 0;
}



Measured memory_bytes: 3156
#include"bits/stdc++.h"

//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 100000000000;

string s;
int num[26] = {};

int count(int cha) {
	int cnt = 0;
	REP(i, s.size()) {
		if (s[i] == cha)cnt++;
	}
	return cnt;
}

int main() {
	cin >> s;
	int _max = 0;
	REP(i, 26) {
		int cha = i + 'a';
		num[i] = count(cha);
		if (_max < count(cha)) {
			_max = count(cha);
		}
	}
	if (_max == s.size()) { print(0); return 0; }
	int ans = mod;
	REP(i, 26) {
		int r = 0, l = 0, max_r = 0;
		int now = 'a' + i;
		REP(j, s.size()) {
			if (s[j] == now) {
				r = j;
				max_r = max(max_r,r - l);
				l = r+1;
			}
		}
		int a = s.size() - l;
		max_r = max(max_r, a);
		ans = min(ans, max_r);
	}
	print(ans);
	return 0;
}

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

int H;
int A[MAX+1];

void maxHeapify(int i) {
  int largest, right, left ;
  left = 2 * i;
  right = 2 * i + 1;
  if ( left <= H && A[left] > A[i] ) largest = left;
  else largest = i;
  if ( right <= H && A[right] > A[largest] ) largest = right;
  
  if ( largest != i ) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int main() {
  cin >> H;
  for ( int i = 1; i <= H ; i++) cin >> A[i];
  
  for ( int i = H / 2 ; i >= 1; i-- ) maxHeapify(i);
  
  for ( int i = 1; i <= H; i++ ) {
    cout << " " << A[i] ;
  }
  
  cout << endl;
  return 0;
}


Measured memory_bytes: 5008
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

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

#define PI 3.141592653589793)
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)

int a, b, c;
int k;

void solve() {
	cin >> a >> b >> c;
	cin >> k;
	int mx, x = b, y = c;

	mx = a;
	if (a < b) {
		mx = b;
		x = a;
	}
	if (mx < c) {
		y = mx;
		mx = c;
	}
	for (int i = 0; i < k; i++) mx *= 2;
	cout << mx + x + y<< endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  string s1, s2, res = "";
  cin >> s1;
  cin >> s2;
  int i = 0;
  while (i < s2.size()) {
  	res += s1[i];
    res += s2[i];
    i++;
  }
  if (i < s1.size()) {
  	res += s1[i];
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[100010];
int len, x = 1;
int main() {
	scanf("%s", s + 1);
	len = strlen(s + 1);
	if (s[1] == '0' || s[len] == '1')
		return printf("-1\n"), 0;
	for (int i = 1; i < len; i ++)
		if (s[i] ^ s[len - i]) 
			return printf("-1\n"), 0;
	for (int i = 2; i <= len; i ++) {
		printf("%d %d\n", x, i);
		if (s[i - 1] == '1')
			x = i;
	}
	return 0;
}

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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

void solve() {
    ll a, b;
    cin >> a >> b;
    cout << a * b / __gcd(a, b);
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int N,M;
cin >> N >> M;

vector<string> A(N),B(M);
rep(i,N) cin >> A[i];
rep(i,M) cin >> B[i];

bool ok = false;
for(int p = 0; p <= N-M; ++p) {
    for(int q = 0; q <= N-M; ++q) {
        bool now = true;
        rep(i,M) {
            rep(j,M) {
                if(A[p+i][q+j] != B[i][j]) now = false;
            }
        }
        if(now) ok = true;
    }
}

if(ok) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <queue>
#include <cstring>
#include <set>
#include <map>

using namespace std;

const long long oo = 1000000000000ll;
const int maxN = 200010;

#define foru(i, l, r) for (int i = l; i <= r; ++i)
#define ford(i, r, l) for (int i = r; i >= l; --i)
#define repu(i, r) for (int i = 0; i < r; ++i)
#define ll long long
#define F first
#define S second
#define mp make_pair
#define pint pair < ll, int >

int n, a[maxN], k, t[maxN];
pint s[maxN];
ll res;

void update(int x) {
    if (x == 0) x = 1;
    while (x <= n) {
        t[x]++;
        x += (x & (-x));
    }
}

int get(int x) {
    int tmp = 0;
    while (x) {
        tmp += t[x];
        x -= (x & (-x));
    }
    return tmp;
}

int main() {
    cin >> n >> k;
    foru(i, 1, n) cin >> a[i];
    s[0] = mp(0, 0);
    foru(i, 1, n) s[i] = mp(s[i - 1].F + (a[i] - k), i);
    sort(s, s + n + 1);
    foru(i, 0, n) {
        res += get(s[i].S);
        update(s[i].S);
    }
    cout << res;
}


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

int main() {
  long long A,B,K;
  cin >> A >> B >> K;
  int a = A;
  
  if (B - A + 1 < K * 2) {
    for (int i = 0; i < B + 1 - A; i++) {
      cout << a << endl;
      a += 1;
    }
  }

  
  else if (B - A + 1 >= K * 2){
    for (int i = 0; i < K; i++) {
      cout << A << endl;
      A += 1;
    }
    for (int i = 0; i < K; i++) {
      cout << B - K + 1 << endl;
      B += 1;
    }
  }
}
  

 

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))

match = {
    1: 2,
    2: 5,
    3: 5,
    4: 4,
    5: 5,
    6: 6,
    7: 3,
    8: 7,
    9: 6,
}

dp = ["-" for _ in range(11000)]
dp[0] = ""


def _max(a, b):
    if len(a) > len(b):
        return a
    if len(a) < len(b):
        return b
    return max(a, b)


for i in range(N+1):
    if dp[i] == "-":
        continue
    for a in A:
        dp[i+match[a]] = _max(dp[i+match[a]], dp[i]+str(a))

print(dp[N])



Measured memory_bytes: 30196
n = int(input())
A = list(map(int,input().split()))
start = min(A)
goal = max(A)

from collections import Counter
c = Counter(A)

ans = 0

for i in range(start,goal+1):
    ans = max(ans,c[i]+c[i+1]+c[i+2])
    
print(ans)

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

const int N = (1e5) + 5;
int n, a[N];

// claudio van
int main() {
  scanf("%d", &n);
  int mn = INT_MAX;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    if (a[i] < 0) {
      a[i] *= -1;
      cnt++;
    }
    mn = min(mn, a[i]);
  }
  ll sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += a[i];
  }
  if (cnt % 2 == 1) {
    sum -= 2LL * mn;
  }
  printf("%lld\n", sum);
  return 0;
}

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

using namespace std;
const int N=2e5+5,mod=1e9+7;
#define ll long long
ll a[N],b[N];
ll cum[N];
ll ans=0,R;
ll n,k;
bool valid(int r)
{
    ans=0;
    ll t=k;
    for(int i=0;i<n;i++)
    {
        ll idx=lower_bound(b,b+n,r-a[i])-b;
        if(idx==n) continue;
        idx=n-1-idx;
        if(idx<i) continue;
        ll sz=idx-i+1;
        t-=sz*2-1;
        ll sum=cum[idx];
        if(i) sum-=cum[i-1];
        ans+=sum*2+a[i]*(sz-1)*2;
    }
    R=t;
    return t>=0;
}
ll bs()
{
    ll s=0,e=2e5+5,mid;
    while(s<e)
    {
        mid=(s+e)/2;
        if(valid(mid)) e=mid;
        else s=mid+1;
    }
    return s;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i],b[i]=a[i];
    sort(a,a+n);
    sort(b,b+n);
    reverse(a,a+n);
    cum[0]=a[0];
    for(int i=1;i<n;i++)
        cum[i]=cum[i-1]+a[i];

    ll B=bs();
    valid(B);
    cout<<ans+R*(B-1)<<endl;
    return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <ctype.h>

int main(void){
	char ch[1001];
	int i;
	int sum;
	while(1){
		scanf("%s",ch);
		if(ch[0] == '0') break;
		i = 0;
		sum = 0;
	while(ch[i] != '\0'){
		sum += (ch[i] - '0');
		i++;
	}
	printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 536
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) int __VA_ARGS__; in(__VA_ARGS__)
//オーバーフロー対策
#define INL(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using Bint = boost::multiprecision::checked_cpp_int;
Bint modpow(Bint a, Bint n, Bint mod)
{
    Bint res = 1;
    while (n > 0)
    {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

void solve()
{
    INL(n);
    Bint ds[100010];
    ll ms = 0;
    INL(ef);
    if (ef != 0)
    {
        cout << 0 << endl;
        return;
    }
    ds[0]++;
    reps(i, 1, n)
    {
        INL(d);
        ds[d]++;
        chmax(ms, d);
    }
    if (ds[0] != 1)
    {
        cout << 0 << endl;
        return;
    }
    Bint p = 1LL;
    Bint m = 998244353LL;
    reps(i, 1, ms+1)
    {
        p = p * modpow(ds[i-1], ds[i], m) % m;
        if (ds[i] == 0)
        {
            cout << 0 << endl;
            return;
        }
    }
    cout << p % m << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3328
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
        boolean isOk = w.chars().mapToObj(i -> (char) i).sorted().collect(Collectors.groupingBy(c -> c)).values()
                .stream().allMatch(cs -> cs.size() % 2 == 0);
        if (isOk) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

#define loop(i, n) for(int i = 0; i < n; i++)
#define sloop(i, s, n) for (int i = s; i < n; i++)
#define rloop(i, n) for(int i = n-1; i >= 0; i--)

using namespace std;

int find_perm_num(int n, vector<int> &perm) {
    int ans = 0, cur = 1, temp;
    vector<int>ser(n+1, 1);
    loop(i, n) {
        cin >> temp;
        sloop(j, 1, n+1) {
            if(!ser[j]) continue;
            if(temp == j) {
                ser[j] = 0;
                break;
            }
            ans += perm[n-i-1];
        }
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> perm(10, 1);
    sloop(i, 1, 10) {
        perm[i] = perm[i-1]*i;
    }
    cout << abs(find_perm_num(n, perm) - find_perm_num(n, perm)) << endl;
    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

string max_str(string s, string t)
{
    if (s == "-")
        return t;
    else if (s.size() < t.size())
        return t;
    else if (s.size() > t.size())
        return s;
    else
        return (s > t ? s : t);
}

int match[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
int N, M;
string dp[10100];

int main()
{
    cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; i++)
        cin >> A[i];

    for (int i = 0; i < 10010; i++)
        dp[i] = "-";
    dp[0] = "";
    for (int i = 0; i <= N; i++)
    {
        if (dp[i] == "-")
            continue;
        for (int j = 0; j < M; j++)
        {
            dp[i + match[A[j] - 1]] = max_str(dp[i + match[A[j] - 1]], dp[i] + (char)('0' + A[j]));
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 44800
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
string s;
int main() {
    DAU
    cin >> s;
    for (const char& c : s)
        if (c == '7') {
            cout << "Yes";
            PLEC
        }
    cout << "No";
    PLEC
}


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

const long Day_num = 365;
const long type_num = 26;

class Scoring {
public:
    Scoring(const long arg_days, const std::vector<long>& arg_costs, const std::vector<std::vector<long>>& arg_incentives);
    std::vector<long> score(const std::vector<long>& arg_types);
private:
    long days;
    std::vector<long> costs;
    std::vector<std::vector<long>> incentives;
};

std::vector<long> Scoring::score(const std::vector<long>& arg_types) {
    std::vector<long> result(days);
    long satisfy = 0;
    std::vector<long> last_days(type_num, 0);


    for (long day = 1; day <= days; ++day) {
        const auto exe_type = arg_types[day-1];
        satisfy += incentives[day-1][exe_type-1];
        last_days[exe_type-1] = day;
        for (long type = 1; type <= type_num; ++type) {
            satisfy -= costs[type-1] * (day - last_days[type-1]);
        }
        result[day-1] = satisfy;
    }
    return result;
}

Scoring::Scoring(const long arg_days, const std::vector<long>& arg_costs, const std::vector<std::vector<long>>& arg_incentives) {
    days = arg_days;
    costs = arg_costs;
    incentives = arg_incentives;
}

int main() {
    clock_t start_clock = clock();
    std::mt19937 engine(10000123);
    std::uniform_int_distribution<> type_random(1, type_num);
    std::uniform_int_distribution<> day_random(1, Day_num);
    long D;
    std::cin >> D;
    std::vector<long> costs(type_num);
    for (long type = 1; type <= type_num; ++type) {
        std::cin >> costs[type-1];
    }
    std::vector<std::vector<long>> incentives(D, std::vector<long>(type_num));
    for (long day = 1; day <= D; ++day) {
        for (long type = 1; type <= type_num; ++type) {
            std::cin >> incentives[day-1][type-1];
        }
    }

    Scoring scoring(D, costs, incentives);

    std::vector<long> types(D);
    for (long day = 1; day <= D; ++day) {
        types[day-1] = type_random(engine);
    }

    while (static_cast<double>(clock() - start_clock)/CLOCKS_PER_SEC*1000.0 < 2000.0-20.0) {
        const auto old_types = types;
        types[day_random(engine)-1] = type_random(engine);
        if (scoring.score(old_types).back() > scoring.score(types).back()) {
            types = old_types;
        }
    }

    for (long day = 1; day <= D; ++day) {
        std::cout << types[day-1] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3864
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

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

  int a, b, c;
  cin >> a >> b >> c;
  if((a == b && a != c )|| (a == c && a != b) || (b == a && b != c) || (b == c && b != a)){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;
bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}
int main(void){
   int N;
   cin>>N;
   vector<int> h(N);
   for(int i=0;i<N;i++){
      cin>>h[i];
   }
   vector<long long> dp(N);
   dp[0]=0;
   dp[1]=abs(h[0]-h[1]);
   for(int i=2;i<N;i++){
      dp[i]=1000000000;
   }
   for(int i=2;i<N;i++){
      dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
      dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
   }
   cout<<dp[N-1]<<endl;
   return 0;
}

Measured memory_bytes: 1408
n, m = map(int, input().split())
st = [list(map(int, input().split()))for _ in range(n)]
cp = [list(map(int, input().split()))for _ in range(m)]

for a, b in st:
    temp_d = float('inf')
    temp_m = 0
    for i, cd in enumerate(cp):
        c, d = cd
        d = (abs(c - a) + abs(d - b))
        if d < temp_d:
            temp_m = i + 1
            temp_d = d
    print(temp_m)

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

int main(void) {
  int S, h, m, s;
  cin >> S;

  h = S / 3600;
  m = (S % 3600) / 60;
  s = S % 60;

  cout << h << ":" << m << ":" << s << endl;
  return 0;
}



Measured memory_bytes: 3092
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

X, Y, Z = mi()

#Y+2Zで1人座れる
#そこからY+Z増えるごとに1人ずつ座れる量が増えていく

yz = X - (Y+ 2*Z)
print(1+yz//(Y+Z))






Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    if(n % 2 == 0) out(n);
    else out(n * 2);
}

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}

int main()
{
    string S, T;
    cin >> S >> T;

    int ans = 0;
    rep(i, S.size()) {
        if (S[i] != T[i]) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3920
s=gets.chomp
puts [
  /\A.*keyence\z/,
  /\Ak.*eyence\z/,
  /\Ake.*yence\z/,
  /\Akey.*ence\z/,
  /\Akeye.*nce\z/,
  /\Akeyen.*ce\z/,
  /\Akeyenc.*e\z/,
  /\Akeyence.*\z/
].any?{|r|r.match(s)} ? "YES" : "NO"


Measured memory_bytes: 1788
#D
from collections import deque
n,m = map(int,input().split())
#インデックス→各部屋番号(-1),つながってる部屋の番号を格納
graph = [[] for _ in range(n)]

for _ in range(m):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
    
#各部屋から1までの距離(初期値999)
bango = [-999 for _ in range(n)]
bango[0] = 0

#p->今いる部屋
p = deque()
p.append(0)

while not len(p)==0:
    x = p.pop()
    for i in graph[x]:
        if bango[i] != -999:
            pass
        else:
            p.appendleft(i)
            #i番目の部屋はxからいける
            bango[i] = x
print('Yes')
for i in range(1,n):
    print(bango[i]+1)

Measured memory_bytes: 34312
N, Q = map(int, input().split())
g = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
counter = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    counter[p] += x
used = [False] * N
stack = [0]
used[0] = True
while stack:
    a = stack.pop()
    for b in g[a]:
        if not used[b]:
            used[b] = True
            counter[b] += counter[a]
            stack.append(b)
print(" ".join(map(str, counter)))

Measured memory_bytes: 66848
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

r = k()
if r<1200:
    print("ABC")
elif r<2800:
    print("ARC")
else:
    print("AGC")


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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template<typename T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template<typename... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

string Longest_Common_Subsequence(const string& S, const string& T){
	int N = S.size(), M = T.size();
	vector<vector<int>> ar(N+1,V<int>(M+1,0));
    for(size_t i = 0; i < N; i++)
    for(size_t j = 0; j < M; j++)
    ar[i+1][j+1] = (S[i] == T[j] ? ar[i][j] + 1 : max(ar[i][j + 1],ar[i + 1][j]) );

	string res = "";
	while(ar[N][M]>0){
		if(S[N-1]==T[M-1]){
			res.push_back(S[N-1]);
			N--,M--;
		}
		else{
			(ar[N-1][M]>ar[N][M-1]?N:M)--;
		}
	}

    reverse(res.begin(),res.end());
	return res;
}


int main() {
	
	string S,T; cin >> S >> T;
    cout << Longest_Common_Subsequence(S,T) << endl;

	return 0;
}


Measured memory_bytes: 35584
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char** argv)
{
	int dp[44];
	int n;
	int i;

	scanf("%d", &n);
	dp[0] = dp[1] = 1;
	for (i = 2; i <= n; ++i)
		dp[i] = dp[i - 1] + dp[i - 2];

	printf("%d\n", dp[n]);
	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long x=sc.nextInt();
    long a=1,b=0,f=(long)(Math.pow(a, 5)-Math.pow(b, 5));
    while(f!=x) {
    	for(long i=-a;i<=a-1;i++) {
    		b=i;
    		f=(long)(Math.pow(a, 5)-Math.pow(b, 5));
    		if(f==x) {
    			System.out.println(a+" "+b);
    			System.exit(0);
    		}
    	}
    	a++;
    }
    System.out.println(a+" "+b);
  }
}


Measured memory_bytes: 38992
import bisect
import collections

x, n = map(int, input().split())
p = list(map(int, input().split()))

def calc(a):
    return abs(a - x)

if not n:
    print(x)
    exit()

l = [i for i in range(102) if i not in set(p)]
print(min(l, key=calc))

Measured memory_bytes: 9460
n=int(input())
t=[""]*n
sec=[0]*n
for k in range(n):
  s=input().split()
  t[k]=s[0]
  sec[k]=int(s[1])
x=input()
p=t.index(x)
a=0
if p!=n:
  for l in range(p+1,n):
    a+=sec[l]
print(str(a))

Measured memory_bytes: 3064
def g;gets.split.map &:to_i;end
while(n,m=g)[0]>0
d=(0..n).map{[]}
m.times{s,t=g;d[s]<<t;d[t]<<s}
l=[0]+g
r=[0]+(1..n).map{g[1..-1].sort}
h={l<<1=>[]}
q=l[1]<1?[]:[l]
q.map{|*t,a|
(d[a].map{|i|t[i]>0&&[t.dup,i,"Move to room #{i}."]}+
r[a].map{|i|u=t.dup;v=u[i]^=1;a!=i &&[u,a,"Switch o#{v>0??n:"ff"} room #{i}."]})
.map{|v,i,s|v&&h[v<<i]||=(q<<v;[s,t+[a]])}}
puts (h[c=[0]*n+[1,n]])?(s=[]
s=[l]+s while(l,c=h[c])[1]
["You can go home in #{s.size} steps."]+s):h.all?{|k,v|k[n+1]<n}?"Help me!":"You can not switch off all lights."
end

Measured memory_bytes: 45344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll f(ll x)
{
    switch (x % 4)
    {
        case 0:
            return x;
        case 1:
            return 1;
        case 2:
            return x + 1;
        case 3:
            return 0;
    }
    return 0;
}

int main()
{
    ll a, b; cin >> a >> b;
    if (a != 0) a--;

    ll ans = f(a) ^ f(b);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int x, n, t;
    int p[111] = {};
    scanf("%d %d", &x, &n);
    if (n == 0)
    {
        printf("%d", x);
        return 0;
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &t);
        p[t] = 1;
    }
    int i = 0;
    while (1)
    {
        if (p[x - i] == 0)
        {
            printf("%d", x - i);
            return 0;
        }
        if (p[x + i] == 0)
        {
            printf("%d", x + i);
            return 0;
        }
        i++;
    }
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  int ans1,ans2;
  ans1 = 0;
  ans2 = 0;
  vector<int> a(S.size());
  vector<int> b(S.size());
  for (int i = 0; i < S.size(); i++) {
  a.at(i)=0;
  b.at(i)=0;
  }
  for(int i = 0;i<S.size();i++){
    if(i % 2 == 0){
    a.at(i) = 0;
    b.at(i) = 1;
    }
    else{
    a.at(i) = 1;
    b.at(i) = 0;
    }
  }
  for(int k=0;k<S.size();k++){
    if(a.at(k)!=S.at(k)-48){
      ans1++;
    }
    if(b.at(k)!=S.at(k)-48){
      ans2++;
    }
  }
  cout << min(ans1,ans2) << endl;   
}


Measured memory_bytes: 1280
# -*- coding: utf-8 -*-

def main():

    
    N = int(input())
    a = list(map(int, input().split()))

    cost = 0
    listCost = []

    for i in range(min(a), max(a)+1):
        for j in a:
            if i != j:
                cost += (i - j) ** 2

        listCost.append(cost)
        cost = 0

    ans = min(listCost)

    print(ans)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9024
#include <stdio.h>

int left[500000/2+2],right[500000/2+2];
int cnt=0;

void merge(int *,int,int,int,int);
void mergeS(int *,int,int,int);

int main(){
    int M[500000],n,i;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&M[i]);
    }
    
    mergeS(M,n,0,n);
    
    for(i=0;i<n;i++){
        if(i != 0)printf(" ");
        printf("%d",M[i]);
    }
    printf("\n%d\n",cnt);

    return 0;
}

void merge(int *M, int n,int le,int mi,int ri){
    int i,j,k;
    int n1 = mi - le;
    int n2 = ri - mi;
    for(i=0;i<n1;i++) left[i] = M[le + i];
    for(i=0;i<n2;i++) right[i] = M[mi + i];
    left[n1] = right[n2] = 1000000000 ;
    i=0;
    j=0;
    for(k=le;k<ri;k++){
        cnt++;
        if(left[i] <= right[j]){
            M[k] = left[i++];
        }else{
            M[k] = right[j++];
        }
    }
}

void mergeS(int *M,int n,int le,int ri){
    if(le+1 < ri){
        int mid = (le+ri)/2;
        mergeS(M,n,le,mid);
        mergeS(M,n,mid,ri);
        merge(M,n,le,mid,ri);
    }
}



Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    string S; cin>>S;
    rep(i,S.size()){
        cout<< "x";
    }
    cout<<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

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

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int k, x;
    cin >> k >> x;
    
    int left = max(-1000000, x - k + 1);
    int right = min(1000000, x + k - 1);
    
    for (int i = left; i <= right; ++i)
    {
        printf("%d%c", i, (i==right ? '\n' : ' '));
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    a = collections.Counter(a)
    c = 0
    t = 0
    for k, v in sorted(a.items(), reverse=True):
        if v >= 4:
            print(k * k if c == 0 else t * k)
            exit()
        elif v >= 2:
            if c != 0:
                print(t * k)
                exit()
            else:
                t += k
                c += 1
    print(0)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 57532
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=105;
int a[N],f[N][N][N],n,res;
int main(){
	scanf("%d",&n);
	fp(i,1,n+n-1)scanf("%d",&a[i]);
	sort(a+1,a+n+n);
	f[1][1][1]=1;
	fp(i,1,n-1)fp(j,1,n+n-1)fp(k,1,j)if(f[i][j][k]){
		R int tj=j,tk=k;
		if(a[n+i]!=a[n+i-1])++tj;
		if(a[n-i]!=a[n-i+1])++tj,++tk;
		fp(h,1,tj){
			if(h<tk)upd(f[i+1][tj-(tk-h-1)][h],f[i][j][k]);
			if(h>tk)upd(f[i+1][tj-(h-tk-1)][tk+1],f[i][j][k]);
			if(h==tk)upd(f[i+1][tj][h],f[i][j][k]);
		}
	}
	fp(i,1,n+n-1)fp(j,1,i)upd(res,f[n][i][j]);
//	f[n][1][0]=1;
//	for(R int i=n-1;i;--i){
//		R int dl=(a[i]!=a[i+1]),dr=(a[n+n-i]!=a[n+n-i-1]);
//		fp(j,0,n+n-1)fp(k,0,n+n-1-j)if(f[i+1][j][k]){
//			fp(l,1,j+dl)upd(f[i][j+dl-l+1][k+dr+(l>1)],f[i+1][j][k]);
//			fp(r,1,k+dr)upd(f[i][j+dl+1][k+dr-r],f[i+1][j][k]);
//		}
//	}
//	fp(i,0,n+n-1)fp(j,0,n+n-1-i)upd(res,f[1][i][j]);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 3328