akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cmath>
#include<map>
#include<queue>

using namespace std;
#define N 4
#define N2 16

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
//static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle {
    int f[N2], space, MD;
    int cost;
    
    bool operator < ( const Puzzle &p ) const {
        for ( int i = 0; i < N2; i++ ) {
            if ( f[i] == p.f[i] ) continue;
            return f[i] < p.f[i];
        }
        return false;
    }
};

struct State {
    Puzzle puzzle;
    int estimated;
    bool operator < (const State &s) const {
        return estimated > s.estimated;
    }
};

int getAllMD(Puzzle pz) {
    int sum = 0;
    for ( int i = 0; i < N2; i++ ) {
        if ( pz.f[i] == N2 ) continue;
        sum += MDT[i][pz.f[i] - 1];
    }
    return sum;
}

int aster(Puzzle s) {
    priority_queue<State> PQ;
    s.MD = getAllMD(s);
    s.cost = 0;
    map<Puzzle, bool> V;
    Puzzle u, v;
    State initial;
    initial.puzzle = s;
    initial.estimated = getAllMD(s);
    PQ.push(initial);
    
    while ( !PQ.empty() ) {
        State st = PQ.top(); PQ.pop();
        u = st.puzzle;
        
        if ( u.MD == 0 ) return u.cost;
        V[u] = true;
        
        int sx = u.space / N;
        int sy = u.space % N;
        
        for ( int r = 0; r < 4; r++ ) {
            int tx = sx + dx[r];
            int ty = sy + dy[r];
            if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
            v = u;
            
            v.MD -= MDT[tx * N + ty][v.f[tx * N + ty] - 1];
            v.MD += MDT[sx * N + sy][v.f[tx * N + ty] - 1];
            
            swap(v.f[sx * N + sy], v.f[tx * N + ty]);
            v.space = tx * N + ty;
            if ( !V[v] ) {
                v.cost++;
                State news;
                news.puzzle = v;
                news.estimated = v.cost + v.MD;
                PQ.push(news);
            }
        }
    }
    return -1;
}

int main() {
    for ( int i = 0; i < N2; i++ )
        for ( int j = 0; j < N2; j++ )
            MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
            
    Puzzle in;
    
    for ( int i = 0; i < N2; i++ ) {
        cin >> in.f[i];
        if ( in.f[i] == 0 ) {
            in.f[i] = N2;
            in.space = i;
        }
    }
    cout << aster(in) << endl;
    
    return 0;
}


Measured memory_bytes: 257592
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder1
{
    class MainClass
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
                        return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }
        public static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var input = Reads();
            var h = input[0];
            var w = input[1];
            var l = new string[h];
            for (int i = 0; i < h; i++)
            {
                l[i] = Console.ReadLine();
            }
            var memo1 = new List<int>();
            bool b = false;
            for (int i = 0; i < h; i++)
            {
                b = false;
                for (int j= 0; j < w; j++)
                {
                    if (l[i][j] == '#')
                    {
                        b = true;
                    }
                }
                if (!b)
                {
                    memo1.Add(i);
                }        
            }
            var memo2 = new List<int>();
            for (int i = 0; i < w; i++)
            {
                b = false;
                for (int j = 0; j < h; j++)
                {
                    if (l[j][i] == '#')
                    {
                        b = true;
                    }
                }
                if (!b)
                {
                    memo2.Add(i);
                }
            }
            int k = 0;
            int m = 0;
            for (int i = 0; i < h; i++)
            {
                if (k != memo1.Count && memo1[k] == i)
                {
                    k++;
                    continue;
                }
                for (int j = 0; j < w; j++)
                {
                    if (m != memo2.Count && memo2[m] == j)
                    {
                        m++;
                        continue;
                    }
                    Console.Write(l[i][j]);
                }
                m = 0;
                Console.WriteLine();
            }

                Console.Out.Flush();
        }
    }
}

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

int main()
{
    string S;

    cin >> S;

    int countA = 0;
    int countB = 0;

    for (int i = 0; i < S.length(); i++)
    {
        if (((i % 2 == 0) && (S[i] == '1')) || ((i % 2 == 1) && (S[i] == '0')))
        {
            countA++;
        }

        if (((i % 2 == 0) && (S[i] == '0')) || ((i % 2 == 1) && (S[i] == '1')))
        {
            countB++;
        }
        
    }

    if (countA > countB)
    {
        cout << countB << endl;
    }
    else
    {
        cout << countA << endl;
    }

    return 0;
}

Measured memory_bytes: 512
package main

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

func main() {
	sc := NewScanner()

	_ = sc.NextInt()
	s := sc.NextLine()

	prev := s[0]
	ans := 0
	for i := 1; i < len(s); i++ {
		if prev != s[i] {
			prev = s[i]
			ans++
		}
	}

	fmt.Printf("%v\n", ans+1)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1280
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	LL ans = 0;
	LL a, b, c;
	cin >> a >> b >> c;
	LL x = min(a, c);
	ans += x;
	a -= x;
	c -= x;
	LL y = min(b, c);
	ans += 2 * y;
	b -= y;
	c -= y;
	ans += c > 0;
	ans += b;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
"use strict";
function Main(input) {
  for(let i = 1; i < 4; i++) {
    if (input[i] === input[i - 1]) {
      console.log('Bad');
      return;
    }
  }
  console.log('Good');

}

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

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

using namespace std;
///////////////////////////////////////////////////////////////////////////////////////////////////////////
#define endl "\n"
#define ll long long
#define out(x)  cout<<x<<"\n"
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,n) for(i=1;i<=n;i++)
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<long long, long long>  pl;
typedef vector<int>     vi;
typedef vector<long long>       vl;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// <<,


int main(){
// <<,

    ll t=1;
    //cin>>t;
    while(t--)
    {   
        long double a;
        long double b;
        cin>>a>>b;
        long double ans = a*b;
        ll ansPro = ans;
        cout<<ansPro<<endl;
    }
    return 0;
}// <<,



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

int main(void) {
    int x, y;
    cin >> x >> y;
    if (2 * x <= y && y <= 4 * x && y % 2 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <string>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>
#include<iomanip>

using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
 
	long double A,B,H,M;
	cin >> A >> B >> H >> M;
    long double degree1 = 30*H + 0.5*M;
    long double degree2 = 6*M;
    long double degreecos = cos((degree1-degree2)*M_PI/180);
    long double Ans = A*A+B*B-2*A*B*degreecos;
    cout << sqrt(Ans);
}

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

typedef long long ll;
typedef long double ld;

int main()
{

  ll R;
  ld ans;
  cin >> R;

  ans = 2 * R * 3.1415;

  cout << ans<<endl;
  

  return 0;
}


Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 505

#define mod 998244353

ll gcd(ll a, ll b)
{
	return (b == 0 ? a : gcd(b, a % b));
}

ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}

ll bexp(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if(b & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		b >>= 1;
	}
	return res % mod;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	map<ll, ll> mi;
	ll a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		mi[a[i]]++;
	}
	// cout << mi.size() << "\n";
	int f = 0;
	if(mi.find(0) != mi.end() && mi[0] == n)
	{
		cout << "Yes\n";
		return 0;
	}

	if(n % 3 != 0)
	{
		cout << "No\n";
		return 0;
	}
	vector<ll> al;
	if(mi.size() == 2)
	{
		ll k1 = mi.begin()->ff, l1 = mi.begin()->ss,
		k2 = mi.rbegin()->ff, l2 = mi.rbegin()->ss;
		
		if((l1 == 2 * l2 && k2 == 0) || (l2 == 2 * l1 && k1 == 0))
			f = 1;
		// int k = n / 3;
		// // for(auto e : mi)
		// // {
		// // 	if(e.ss == k)
		// // 		al.pb(e.ff);
		// // 	else
		// // 		al.pb(e.ff), al.pb(e.ff);
		// // }
		// if(l1 == k)
		// 	al.pb(k1), al.pb(k2), al.pb(k2);
		// else
		// 	al.pb(k1), al.pb(k1), al.pb(k2);
		// // for(auto e : mi)
		// // {
		// // 	for (int i = 0; i < e.ss/(n/3); ++i)
		// // 	{
		// // 		al.pb(e.ff);
		// // 	}
		// // }
		// if(al.size() == 3 && (al[0] ^ al[1] ^ al[2]) == 0)
		// {
		// 	f = 1;
		// }
	}
	else if(mi.size() == 3)
	{
		ll b[3] = {}, i = 0;
		for(auto e : mi)
		{
			b[i++] = e.ff; 
		}

		if(((b[0] ^ b[1]) == b[2]) && (mi[b[0]] == mi[b[1]]) && (mi[b[0]] == mi[b[2]]))
			f = 1;
	}

	if(f)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
#include<string.h>
int main()
{
    int n, ac=0, wa=0, tle=0, re=0, i;
    char s[4];
    scanf("%d", &n);
    for(i=1; i<=n; i++){
        scanf(" %s", s);
        if(s[0]=='A') ++ac;
        else if(s[0]=='W') ++wa;
        else if(s[0]=='T') ++tle;
        else if(s[0]=='R') ++re;
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  long long count=0;
  long long r=0,b=0,g=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R') r+=1;
    if(s[i]=='G') g+=1;
    if(s[i]=='B') b+=1;
  }
  for(int k=2;k<n;k++){
    //cout << 0 << endl;
    for(int j=1;j<k;j++){
      int i=2*j-k;
      if(i>=0&&s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k]) count += 1; 
    }
  }
  cout << r*b*g-count << endl;
}


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

bool check(vector<int>& S, int t) {
    int lb = -1, ub = S.size();
    while (ub - lb > 1) {
        int m = (lb + ub) / 2;
        if (S[m] > t) ub = m;
        else if (S[m] < t) lb = m;
        else return true;
    }
    return false;
}

int main() {
    int n;
    cin >> n;
    vector<int> S(n);
    for (int i = 0; i < n; ++i) {
        cin >> S[i];
    }
    int q, ans = 0;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int t;
        cin >> t;
        if (check(S, t)) ans++;
    }
    cout << ans << endl;
}


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

bool stackable(ll P, ll* bag, int n, int kk){
  int w = 0;
  int k = 1;
  if(bag[0] > P) return false;
  for(int i = 0; i < n; i++){
    if(w + bag[i] <= P){
      w += bag[i];
    }else{
      k++;
      if(bag[i] > P) return false;
      w = bag[i];
    }
  }
  if(w == 0) k--;
  return k <= kk;
}

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll baggage[100000];
  int n, k; cin >> n >> k;
  for(int i = 0; i < n; i++) cin >> baggage[i];

  ll l = 0, r = 10000*100000;
  while(l < r-1){
    ll mid = (l+r)/2;
    if(stackable(mid, baggage, n, k)){
      r = mid;
    }else{
      l = mid;
    }
  }
  cout << r << endl;
  return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  string ret = "No";
  if (A - B > 0) {
    for (int i = A; i >= B; i--) {
      if (i == C) {
        ret = "Yes";
        break;
      }
    }
  } else if (A - B < 0) {
    for ( int i = A; i <= B; i++) {
      if (i == C) {
        ret = "Yes";
        break;
      }
    }
  } else {
  }
  
  cout << ret << endl;
}


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

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<vector<int>> v(n, vector<int>(2));
    for(int i = 0; i < n; i++) {
        cin >> v[i][0] >> v[i][1];
    }
    sort(v.begin(), v.end());
    ll index = 0;
    int i = 0;
    while(1) {
        index += v[i][1];
        if(index >= k)break;
        i++;
    }
    cout << v[i][0] << endl;
}

Measured memory_bytes: 5760
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64

#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
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; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e17 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };


void solve() {
	string S; cin >> S;
	ll sum = 0;
	int N = S.size();
	REP(i, N) {
		sum += S[i] - '0';
	}
	if (sum % 9 == 0)print("Yes");
	else print("No");
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 3748
#include<iostream>
#define INF 1 << 30
using namespace std;

void newboat(int cost[101][101])
{

	int c, d, e;
	cin >> c >> d >> e;

	if (cost[c][d]>e){
		cost[c][d] = e;
		cost[d][c] = e;
	}
	return;
}

void go(int n, int b, int cost[101][101], int access[], bool used[], bool though[101][101])
{
	int minaccess = INF, minisland;

	for (int i = 1; i <= n; i++){
		if (minaccess > access[i] && !used[i]){
			minaccess = access[i];
			minisland = i;
		}
	}
	if (minaccess >= access[b]){ return; }
	used[minisland] = true;
	for (int i = 1; i <= n; i++){
		if (cost[minisland][i] != INF && !though[minisland][i]){
			though[minisland][i] = true;
			though[i][minisland] = true;
			if (access[i] > access[minisland] + cost[minisland][i]){
				access[i] = access[minisland] + cost[minisland][i];
			}
		}
	}

	go(n, b, cost, access, used, though);
	return;
}

int solve(int n, int cost[101][101])
{
	int a, b, access[101];
	bool used[101], though[101][101];
	cin >> a >> b;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			though[i][j] = false;
		}
		used[i] = false;
		access[i] = INF;
	}

	access[a] = 0;

	go(n, b, cost, access, used, though);
	return (access[b] != INF) ? access[b] : -1;
}

int main()
{
	while (1){
		int n, k;
		cin >> n >> k;
		if (!n&&!k){ break; }

		int cost[101][101];
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				cost[i][j] = INF;
			}
		}

		for (int i = 0; i<k; i++){
			bool how;
			cin >> how;
			if (how){
				newboat(cost);
			}
			else{
				cout << solve(n, cost) << endl;
			}
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
	
	int a,b,c;
	cin >> a >> b >> c;
	if(a <= c && (a + b) >= c){
		cout <<"YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

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

var pair map[int][]int

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	var N, M int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &M)

	ps := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &ps[i])
	}

	pair = make(map[int][]int)
	for i := 0; i < M; i++ {
		var a, b int
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &a)
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &b)
		pair[a] = append(pair[a], b)
		pair[b] = append(pair[b], a)
	}

	ans := 0
	done := NewIntSet()
	for i := 1; i <= N; i++ {
		if done.Contains(i) {
			continue
		}
		conn := NewIntSet()
		connected(i, conn)
		cnt := 0
		for pos, _ := range conn.Entries() {
			done.Add(pos)
			if conn.Contains(ps[pos-1]) {
				cnt++
			}
		}
		ans = ans + cnt
	}
	fmt.Println(ans)
}

func connected(n int, done *IntSet) {
	done.Add(n)
	ret := make([]int, 0)
	ret = append(ret, n)
	for _, c := range pair[n] {
		if !done.Contains(c) {
			connected(c, done)
		}
	}
}

type IntSet struct {
	set map[int]struct{}
}

func NewIntSet() *IntSet {
	return &IntSet{
		set: make(map[int]struct{}),
	}
}

func (s *IntSet) Add(str int) {
	s.set[str] = struct{}{}
}

func (s *IntSet) Contains(str int) bool {
	_, e := s.set[str]
	return e
}

func (s *IntSet) Size() int {
	return len(s.set)
}

func (s *IntSet) IsEmpty() bool {
	return s.Size() == 0
}

func (s *IntSet) Entries() map[int]struct{} {
	return s.set
}


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

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

  vector<int> L(N);
  rep( i, 0, N ) cin >> L.at(i);

  int Sum = 0;
  int Ans = 1;
  rep( i, 0, N ) {
    Sum += L.at(i);
    if ( Sum<=X ) Ans++;
  }

  cout << Ans <<endl;
}


Measured memory_bytes: 256
local n,m=io.read("n","n","l")
local a={}
for i=1,n do
    a[i]=io.read()
end
local b={}
for i=1,m do
    b[i]=io.read()
end

for i=1,n-m+1 do
    for j=1,n-m+1 do
        local flag=true
        for k=1,m do
            if a[i+k-1]:sub(j,j+m-1)~=b[k] then
                flag=false
            end
        end
        if flag then
            print("Yes")
            return
        end
    end
end
print("No")

Measured memory_bytes: 888
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Task[] t = new Task[N];
        for (int i = 0; i < N; ++i) {
            t[i] = new Task();
            t[i].a = sc.nextLong();
            t[i].b = sc.nextLong();
        }
        Arrays.sort(t, new MyComparator());
        long agg = 0;
        for (int i = 0; i < N; ++i) {
            agg += t[i].a;
            if (agg > t[i].b) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
    static class MyComparator implements Comparator<Task> {
        @Override
        public int compare(Task t1, Task t2) {
            return t1.b < t2.b || (t1.b == t2.b && t1.a < t2.a) ? -1 : 1;
        }
    }
    static class Task {
        long a, b;
    }
}


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

int main(){
  string s,t;
  cin >> s;
  t = s[0];
  int sum = 0;
  
  for(int bit = 0; bit < (1<<3); ++bit){
    int a;
    sum = s[0]-'0';
    t = s[0];
    for(int i = 0; i < 3; ++i){
      a = s[i+1]-'0';
      if(bit & (1<<i)){
        sum += a;
        t = t + '+' + s[i+1];
      }
      else{
        sum -= a;
        t = t + '-' + s[i+1];
      }
    }
    if(sum == 7){
      cout << t << "=7" << endl;
      break;
    }
  }      
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,sum=0,arr[55],temp[55];
    cin>>n;
      for(i=0;i<n;i++){
        cin>>arr[i];
        temp[i]=arr[i];
      }
    sort(arr,arr+n);

    for(i=0;i<n;i++){
       if(temp[i]!=arr[i])
        sum++;
      }
      if(sum<3)
      cout<<"YES"<<endl;
      else
          cout<<"NO"<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

string s;
ll cnt, ans;

int main() {
	cin >> s;
	for (int i = 0; i != s.size(); ++i) {
		if (s[i] == 'W') {
			ans += cnt;
		}
		else
			++cnt;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;
 
public class Main{
    
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        int N = s.nextInt();
		long[] A = new long[N];
		for(int i = 0; i < N; i++){
			A[i] = s.nextLong();
		}

		long sum = 1;
		boolean r = false;
		for(int i = 0; i < N; i++){
			sum = sum*A[i];
			if(A[i] == 0L){
				sum = 0;
				r = false;
				break;
			}
			if(sum > (long)(Math.pow(10, 18)) || sum <= 0L){
				r = true;
			}
		}

		if(r){
			System.out.println(-1);
		}else{
			System.out.println(sum);
		}
        
	}
} 

Measured memory_bytes: 61916
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

Node *find(int k) {
  Node *x = root;
  while (x != NIL) {
    if (k == x->key) {
      return x;
    } else if (k < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  return NIL;
}

void del(Node *z) {
  if (z == NIL) {
    return;
  }
  if (z->left == NIL && z->right == NIL) {
    if (z == root) {
      root = NIL;
    } else {
      if (z->parent->left == z) {
        z->parent->left = NIL;
      } else {
        z->parent->right = NIL;
      }
    }
    free(z);
  } else if (z->left == NIL) {
    if (z == root) {
      root = z->right;
    } else {
      if (z->parent->left == z) {
        z->parent->left = z->right;
      } else {
        z->parent->right = z->right;
      }
      z->right->parent = z->parent;
    }
    free(z);
  } else if (z->right == NIL) {
    if (z == root) {
      root = z->left;
    } else {
      if (z->parent->left == z) {
        z->parent->left = z->left;
      } else {
        z->parent->right = z->left;
      }
      z->left->parent = z->parent;
    }
    free(z);
  } else {
    Node *x = z->right;
    while (true) {
      if (x->left != NIL) {
        x = x->left;
      } else if (x->right != NIL) {
        x = x->right;
      } else {
        break;
      }
    }
    z->key = x->key;
    del(x);
  }
}

void inorder(Node *u) {
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node *u) {
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  string com;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    cin >> com;
    if (com == "insert") {
      scanf("%d", &x);
      insert(x);
    } else if (com == "find") {
      scanf("%d", &x);
      if (find(x) != NIL) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    } else if (com == "delete") {
      scanf("%d", &x);
      Node *z = find(x);
      del(z);
    } else if (com == "print") {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 21936
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   string s;
   cin>>s;
   int mx=0;
   int i=0;
   while(i<3)
   {
       char x=s[i];
       int cnt=0;
       while(i<3 && x==s[i])
       {
           cnt++;
           i++;
       }
       if(x=='R')
        mx=max(mx,cnt);
   }
   cout<<mx<<endl;
}



Measured memory_bytes: 3636
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T>
inline void chmax(T &a, const T &b) {
    if ((a) < (b)) (a) = (b);
}
template <class T>
inline void chmin(T &a, const T &b) {
    if ((a) > (b)) (a) = (b);
}

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x)    \
    sort(all(x)); \
    x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> iii;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
    }
} fast;
void check_input() {
    assert(cin.eof() == 0);
    int tmp;
    cin >> tmp;
    assert(cin.eof() == 1);
}

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"


int solve() {
    int a,b,c,k;cin>>a>>b>>c>>k;

    if (k<=a){
        cout << k << endl;
    }
    else if (k<=a+b){
        cout << a << endl;
    }
    else if (k<=a+b+c){
        cout << a - (k-(a+b)) << endl;
    }

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3672
n,m=map(int,input().split())
if n==1 and m==1:
  print(1)
  exit()
if n==1 or m==1:
  print(n*m-2)
  exit()
if n==2 or m==2:
  print(0)
  exit()
print((m-2)*(n-2))


Measured memory_bytes: 9112
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int k, n;
    cin>>k>>n;
    int i;
    int a[n+5];
    FOR0(i, n)
        cin>>a[i];
    int mx = ninf;
    FOR0(i, n-1)
    {
        int cur = abs(a[(i+1)%n] - a[i]);
        mx = MAX2(mx, cur);
    }
    int cur = k-a[n-1]+a[0];
    mx = MAX2(mx, cur);
    cout<<k-mx<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 1024
// フェルマーの小定理
package main

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

const (
	m = 1000000007
)

func mpow(x, y int) int {
	result := 1
	for y != 0 {
		if y&1 == 1 {
			result *= x
			result %= m
		}
		x *= x
		x %= m
		y >>= 1
	}
	return result
}

var (
	fac []int
)

func initFactorialTable(n int) {
	fac = make([]int, n+1)
	fac[0] = 1
	for i := 0; i < n; i++ {
		fac[i+1] = fac[i] * (i + 1) % m
	}
}

func mcomb(n, k int) int {
	if n == 0 && k == 0 {
		return 1
	}
	if n < k || k < 0 {
		return 0
	}
	return (fac[n] * mpow(fac[n-k], m-2) % m) * mpow(fac[k], m-2) % m
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	defer flush()

	N := readInt()
	K := readInt()

	initFactorialTable(max(K-1, N-K+1))

	for i := 1; i <= K; i++ {
		println(mcomb(K-1, i-1) * mcomb(N-K+1, i) % m)
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 1856
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#define llong long long
#define For(i,a,b) for(int i=(a);i<(b);i++)
#define Rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
  int NB, NA;
  cin >> NB;
  string b[NB];
  Rep(i, NB){
    cin >> b[i];
  }
  cin >> NA;
  string a[NA];
  Rep(i, NA){
    cin >> a[i];
  }
  int ans = 0;
  Rep(i, NB){
    int tmp = 0;
    Rep(j, NB){
      if (b[i] == b[j]) tmp++;
    }
    Rep(j, NA){
      if (b[i] == a[j]) tmp--;
    }
    ans = max(ans, tmp);
  }

  cout << ans << endl;

}

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

const int N = 100005;
const int M = (1<<18);
ll p;
int n;
int t [N];
int tree [M+M];

void update (int u){
    for (u+=M; u!=0; u/=2)
        tree[u]++;
}

int query (int a, int b)
{
    a+=M;
    b+=M;
    int res = tree[a]+tree[b];
    while (a/2 != b/2)
    {
        if (a%2==0) res += tree[a+1];
        if (b%2==1) res += tree[b-1];
        a/=2;
        b/=2;
    }
    return res;
}

bool check (int m)
{
    int i;
    for (i=0; i<M+M; i++)
        tree[i] = 0;
    update(N);
    ll out = 0;
    int pre = 0;
    for (i=1; i<=n; i++)
    {
        pre += ((t[i]<=m) ? -1 : 1);
        out += query(N+pre+1, N+n+1);
        update(N+pre);
    }
    if (p%2==0) return (2*out >= p+2);
    if (p%2==1) return (2*out >= p+1);
}

int main ()
{
    int i, a, b;
    scanf ("%d",&n);
    p = (1ll*(n+1)*n)/2;
    for (i=1; i<=n; i++)
        scanf ("%d",&t[i]);
    a = -1;
    b = 1000000001;
    while (b-a>1)
        (check((a+b)/2) ? b : a) = (a+b)/2;
    printf ("%d\n", b);
    return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(a,n) rep(i,0,n){ cout<<(i ? " ":"")<<a[i]; }cout<<endl;
#define pprint(a,m,n) rep(j,0,m){ print(a[j],n); }
const int mod = 1e9+7;
const int size=1e5;
const long INF=1e14;
int main(){
	int N;cin>>N;
	long A[3*N];
	rep(i,0,3*N) cin>>A[i];
	vector<pair<long,long>> vp(3*N);
	long sum=0;priority_queue<long> pqf;
	rep(i,0,N){ sum+=A[i]; pqf.push(-A[i]); }
	rep(i,N,2*N+1){
		vp[i].first=sum;
		sum+=A[i]; pqf.push(-A[i]);
	    sum+=pqf.top(); pqf.pop();
	}
	sum=0;priority_queue<long> pqs;
	for(int i=3*N-1;i>=2*N;i--){ sum+=A[i]; pqs.push(A[i]); }
	for(int i=2*N;i>=N;i--){
		vp[i].second=sum;
		sum+=A[i-1]; pqs.push(A[i-1]);
		sum-=pqs.top(); pqs.pop();
	}
    /*rep(i,N,2*N+1){
        cout<<vp[i].first<<" "<<vp[i].second<<endl;
    }*/
	long ans=-INF;
	rep(i,N,2*N+1) ans=max(ans,vp[i].first-vp[i].second);
	cout<<ans<<endl;
}

Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define D                double
#define F                first
#define S                second
#define pb               push_back
#define pf               push_front
#define MP               make_pair
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define it(it,mp)        for(auto it=mp.begin() ; it!=mp.end() ; it++)
#define IOS              ios_base :: sync_with_stdio(false); cin.tie(NULL);
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
typedef long long int                   ll;
typedef pair<int,int>                   PII;
int minCoins(int coins[], int m, int V)
{

    int table[V+1];

    table[0] = 0;
    for (int i=1; i<=V; i++)
        table[i] = INT_MAX;


    for (int i=1; i<=V; i++)
    {
        for (int j=0; j<m; j++)
          if (coins[j] <= i)
          {
              int sub_res = table[i-coins[j]];
              if (sub_res != INT_MAX && sub_res + 1 < table[i])
                  table[i] = sub_res + 1;
          }
    }
    return table[V];
}
int coins[]= {59049 , 46656,7776,6561,1296,729,216,81,36,9,6,1} ;
int main()
{
    IOS
    // READ("test.txt");
    //WRITE("");


    int sz = sizeof(coins)/sizeof(int) ;
    int need ;
    cin >> need;
    cout<< minCoins(coins,sz,need)<<endl;
}


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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
        int a = sc.nextInt(); int b= sc.nextInt(); int c = sc.nextInt();int count = 0;
		for(int i = a;i<=b;i++) {
			if(i%c==0) count++;
		}
          System.out.println(count);
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 32192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  if (a[0]==a[1]||a[1]==a[2]||a[2]==a[3]){
    cout << "Bad" << endl;
  }
  else {
    cout << "Good " << endl;
  }
}

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

int main() 
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    
    ll dp[n]={0};
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    
    for(ll i=2;i<n;i++)
    {
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
    }
    
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
#D - AtCoder Express 2
#2次元累積和
import sys 
from itertools import accumulate 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,M,Q = map(int,readline().split())
data = [[0]*(N+1) for _ in range(N+1)]
#入力
for _ in range(M):
    l,r = map(int,readline().split())
    data[l][r] += 1
    
#累積和
for i in range(N+1):
    for j in range(N):
        data[i][j+1] += data[i][j]
        
#入力    
for _ in range(Q):
    p,q = map(int,readline().split())
    ans = 0
    for i in range(p,q+1):
        ans += (data[i][q] - data[i][p-1])
    print(ans)

Measured memory_bytes: 77440
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;
const ll MAX=1e9;

bool query(ll x){
    cout<<"? "<<x<<endl;
    string S; cin>>S;
    if(S=="Y") return true;
    return false;
}
int main(){
    ll ans=0;
    bool K=query(MAX);
    ll COUNT=MAX/10;
    if(K){
        while(true){
            if(query(COUNT+1)) COUNT/=10;
            else break;
            if(COUNT==0) {ans=1; break;}
        }
        if(ans==0) ans=COUNT*10;
    }

    else{
        while(true){
            if(!query(COUNT)) COUNT/=10;
            else break;
        }

        ll NG=COUNT, OK=COUNT*10;
        OK--;
        while(OK-1>NG){
            ll MID=(OK+NG)/2;
            if(query(MID*10)) OK=MID;
            else NG=MID;
        }
        ans=OK;
    }
    cout<<"! "<<ans<<endl;


}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
const int MN = 4012;
ll ctr[MN][26];
int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  ll n; cin >> n;
  string s; cin >> s;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 26; j++)
      ctr[i][j] = ctr[i-1][j];
    ctr[i][s[i-1]-'A']++;
  }
  ll ans = 0;
  int R = 'R'-'A';
  int G = 'G'-'A';
  int B = 'B'-'A';
  for (int i = 1; i <= n; i++) {
    for (int j = i+1; j <= n; j++) {
      if (s[i-1] == s[j-1]) continue;
      ll cnt = 0;
      if (s[i-1] != 'R' and s[j-1] != 'R')
        cnt = ctr[n][R] - ctr[j][R];
      else if (s[i-1] != 'G' and s[j-1] != 'G')
        cnt = ctr[n][G] - ctr[j][G];
      else if (s[i-1] != 'B' and s[j-1] != 'B')
        cnt = ctr[n][B] - ctr[j][B];
      int dist = j-i;
      if (j+dist-1 < n and s[j+dist-1] != s[i-1] and s[j+dist-1] != s[j-1])
        cnt--;
      ans += cnt;
    }
  }
  cout << ans << '\n';
  return 0;
}



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

#define int long long
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()

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

int32_t main(){
  
    int n,k; cin >> n >> k;
    bool dislike[11] = {false};
    for(int i=1;i<=k;i++){
      int d; cin >> d;
      dislike[d] = true;
    }

    while(true){
      string s = to_string(n);
      bool found = true;
      for(int i=0;i<s.size();i++){
        if(dislike[s[i]-'0']){
          found = false;
          break;
        } 
      }
      if(found){
        cout << n;
        break;
      } 
      else n++;
    }

    return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

struct state{
	int pos, time, dist, num;
	state(int p,int t,int d,int n): pos(p),time(t),dist(d),num(n){}
};


void solve(int n, const vector<int>& p, const vector<int>& t){
	const int inf = 1e9;

	//000123
	vector<vector<state> > st(n + 1, vector<state>(6, state(0, inf, inf, 0) ) );
	st[0][0] = state(0, 0, 0, 0);

	for(int i = 1; i <= n; ++i){
		bool flag = false;
		//バルーン1個
		for(int j = 0; j < 3; ++j){
			int nextt = st[i-1][j].time + p[i];
			int nextd = st[i-1][j].dist + p[i];
			if( nextt <= t[i] &&  nextd < st[i][3].dist ){
				st[i][3] = state(p[i], t[i], nextd, 1);
				flag = true;
			}
		}

		//バルーン2個
		if( st[i-1][3].time + 2 * abs(st[i-1][3].pos - p[i]) <= t[i] ){
			st[i][4] = state(p[i], t[i], st[i-1][3].dist + abs(st[i-1][3].pos - p[i]), 2);
			flag = true;
		}
		
		//バルーン3個
		if( st[i-1][4].time + 3 * abs(st[i-1][4].pos - p[i]) <= t[i] ){
			st[i][5] = state(p[i], t[i], st[i-1][4].dist + abs(st[i-1][4].pos - p[i]), 2);
			flag = true;
		}

		for(int j = 0; j < 3; ++j){
			state &base = st[i][j+3];
			st[i][j] = state(0, base.time + (j+2) * base.pos, base.dist + base.pos, 0);
		}

		if( !flag ){
			printf("NG %d\n", i);
			return;
		}
	}

	int ans = inf;
	for(int i = 0; i < 3; ++i){
		ans = min(ans, st[n][i].dist);
	}
	printf("OK %d\n", ans);
}


int main(){
	int n;
	
	while( scanf("%d", &n), n != 0 ){
		vector<int> p(n + 1), t(n + 1);
		for(int i = 1; i <= n; ++i){
			scanf("%d%d", &p[i], &t[i]);
		}

		solve(n, p, t);
	}
}

Measured memory_bytes: 1036
#include<bits/stdc++.h>
using namespace std;
const int N = 11;
int n,m,p[N];
vector<int> s[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int k;
        cin >> k;
        s[i].resize(k);
        for (int & j : s[i])
            cin >> j, --j;
    }
    for (int i = 0; i < m; ++i) cin >> p[i];
    int ans = 0;
    for (int S = 0; S < (1<<n); ++S) {
        bool ook = true;
        for (int i = 0; i < m; ++i) {
            int sum = p[i];
            for (int j : s[i])
                sum ^= S>>j&1;
            ook = ook && sum == 0;
        }
        ans += ook;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        a: u64, b: u64, x: u64
    }

    println!("{}", if x >= a && x <= a+b {"YES"} else {"NO"});
}

Measured memory_bytes: 4352