akhauriyash/Code-Regression huggingface dataset:
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;
const int MAX_V = 201;

ll rec(ll x,ll allv, ll lev,ll n) {

	if (x <= n) return 0;
	if (x > allv - n) return lev;

	if (n == 1) {
		return x == 5 ? 3 : x - 1;
	}
	
	ll half = allv / 2;
	ll sum = 0;
	if (half < x) {

		sum += lev / 2 + 1;
		sum += rec(x - half - 1, allv - half - 2, lev / 2, n - 1);
	}
	else {

		sum += rec(x - 1, half - 1, lev / 2 , n - 1);

	}

	return sum;
}

ll all(int n) {
	if (n == 0) return 1;
	return 3 + all(n - 1) * 2;
}
void Christmas(){
	int n;
	ll x;
	cin >> n >> x;
	ll lev = 1;
	for (size_t i = 0; i < n; i++)
	{
		lev = lev * 2 + 1;
	}
	ll allv  = all(n);
	cout << rec(x,allv,lev ,n) << endl;
}
int main() {
	Christmas();
	return 0;
}



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

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]


    token = lines[0].split(" ")
    a = int(token[0])
    b = int(token[1])

    return (a, b)


def solve(a, b):

    c = (a + b) / 2

    if not c.is_integer():
        return "IMPOSSIBLE"

    return int(c)


def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
n, p = map(int, input().split())
s = list(map(int, list(input())))[::-1]

div = [0 for _ in range(p)]

su = 0
for i in range(n):
	su = (su + s[i] * pow(10, i, p)) % p
	div[su] += 1

cnt = 0
if p in [2, 5]:
	if p == 2:
		ok = [0, 2, 4, 6, 8]
	else:
		ok = [0, 5]

	for i in range(len(s)):
		if s[i] in ok:
			cnt += n - i

else:
	for i in range(len(div)):
		x = div[i]
		if i == 0:
			y = x * (x + 1) // 2
		else:
			y = x * (x - 1) // 2
		cnt += y

print(cnt)

Measured memory_bytes: 61680
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include<sstream>
#include<unordered_set>

using namespace std;



int main(){
    string ts = "CODEFESTIVAL2016";
    string s;
    cin >> s;
    int res = 0;
    for (int i = 0; i < s.length(); ++i)
        if (s[i] != ts[i])
            ++res;
    cout << res;


}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
int main(){
	long long n;
	cin>>n;
	long long x=sqrt(n),ans=0,y;
	for(long long i=1;i<=x;i++){
		y=(n-i)/i;
		if(n==i*y+i&&i<y) ans+=y;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N, M;
int S, T;
const int MAX_NM = 100100;
vector<int> edges[MAX_NM];
int costs[MAX_NM][4];
void init()
{
    for (int i = 0; i < MAX_NM; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            costs[i][j] = INF;
        }
    }
}
void dijkstra()
{
    init();
    min_priority_queue<tuple<int, int, int>> min_que;
    min_que.emplace(mt(0, S, 0));
    while (not min_que.empty())
    {
        auto p = min_que.top();
        min_que.pop();
        int cost, pos, cnt;
        tie(cost, pos, cnt) = p;
        // cerr << pos << " " << cost << " " << cnt << " " << costs[pos][cnt] << endl;
        if (costs[pos][cnt] <= cost)
        {
            continue;
        }
        costs[pos][cnt] = cost;

        int nxt_cnt = cnt + 1;
        int nxt_cost = cost;
        if (nxt_cnt > 3)
        {
            nxt_cost += 1;
            nxt_cnt = 1;
        }
        for (auto &nxt : edges[pos])
        {
            if (costs[nxt][nxt_cnt] >= nxt_cost)
            {
                min_que.emplace(nxt_cost, nxt, nxt_cnt);
            }
        }
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        edges[u].push_back(v);
    }
    cin >> S >> T;
    S--, T--;
    dijkstra();
    int res = costs[T][3] == INF ? -1 : costs[T][3] + 1;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 9076
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    set<int> st;
    for(int i = 0; i < q; i++)
    {
        int com, x;
        cin >> com >> x;
        if(com == 0)
        {
            st.insert(x);
            cout << st.size() << endl;
        }
        else if(com == 1)
        {
            cout << (st.find(x) != st.end() ? 1 : 0) << endl;
        }
        else if(com == 2)
        {
            st.erase(x);
        }
    }
    return 0;
}




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

const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) {
			x -= mod;
		}
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) {
			x -= mod;
		}
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

int main() {
	int n, k;
	cin >> n >> k;

	mint nCk = 1;
	mint kCi = 1;
	int N = n - k + 1;
	for (int i = 1; i <= k; i++) {
		if (N < i) {
			cout << 0 << endl;
		}
		else {
			nCk *= (N - i + 1);
			nCk /= i;
			if (i != 1) {
				kCi *= (k - i + 1);
				kCi /= (i - 1);
			}
			cout << (nCk.x * kCi.x) % mod << endl;
		}
	}
}

Measured memory_bytes: 256
N, K = gets.chomp.split(' ').map(&:to_i)
hates = gets.chomp.split(' ').map(&:to_i)

n = N
loop do
  ok = true
  g = n
  while g.positive?
    if hates.include?(g % 10)
      ok = false
      break
    end
    g /= 10
  end

  if ok
    p n
    break
  end

  n += 1
end


Measured memory_bytes: 1788
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin >> N;
    double sum = 0.0;
    for (int i = 0; i < N; ++i)
    {
        double Xi;
        string Ui;
        cin >> Xi >> Ui;
        if (Ui == "JPY")
        {
            sum += Xi;
        }
        else
        {
            sum += Xi * 380000.0;
        }
    }
    cout << setprecision(16) << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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 ll INF = 1e9;
const ll MOD = 1e9 + 7;


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

    int n = x/100;
    int y = x%100;

    rep(a, n+1){
        rep(b, n+1){
            rep(c, n+1){
                rep(d, n+1){
                    rep(e, n+1){
                        rep(f, n+1){
                            if(a+b+c+d+e > n) break;
                            if(a+b*2+c*3+d*4+e*5 == y){
                                cout << 1 << endl;
                                return 0;
                            }
                        }
                    }
                }
            }
        }
    }

    cout << 0 << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int L = sc.nextInt();
			
			int all = 0, answer = L, answer_diff = Math.abs(L);
			for(int i = 0; i < N; i++) {
				final int next = Math.abs(L + i);
				all += (L + i);
				
				if(answer_diff > next) {
					answer_diff = next;
					answer = L + i;
				}
			}
			
			System.out.println((all - answer));
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22996
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 
#define int ll
using namespace std;

const int N = 3e5 + 5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const long double eps = 1e-9 ;

using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve()
{
    string s;
    cin >> s;
    string ans(s.begin() , s.begin() + 3); 
    cout << ans ;
}
     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}


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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

string s, t;
ll n, m;
map<ll, char> mp;
set<ll> st;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m >> s >> t;
	ll l = n * m / __gcd(n, m);
	for (ll i = 0; i < n; i++)
		mp[i * (l / n) + 1] = s[i], st.insert(i * (l / n) + 1);
	for (ll i = 0; i < m; i++)
		if (st.count(i * (l / m) + 1) && mp[i * (l / m) + 1] != t[i])
			return cout << -1 << endl, 0;
	cout << l << endl;
	return 0;
}


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

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

auto solve(long long r, long long g, long long b){
    auto s = 100 * r + 10 * g + b;
    return (s % 4 == 0) ? YES : NO;
}

int main(){
    long long r;
    scanf("%lld",&r);
    long long g;
    scanf("%lld",&g);
    long long b;
    scanf("%lld",&b);
    auto result = solve(r, g, b);
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cctype>
#include <string>
using namespace std;
int main(){
  string str,com,temp,s;
  int q,a,b,p;
  cin>>str>>q;
  for(int i=0;i<=q-1;i++){
    cin>>com>>a>>b;
    if(com=="print") {
      cout<<str.substr(a,b-a+1)<<endl;
    }
    else if(com=="reverse"){
      temp=str.substr(a,b-a+1);
      int n=temp.size();
      for(int i=0;i<=n-1;i++) {
        str[a+i]=temp[n-1-i];
      }
    }
    else if(com=="replace"){
      cin>>s;
      str=str.replace(a,b-a+1,s);
    }
  }
  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
    #include <string>
     
    using namespace std;
     
    string Muqayise(string x, string y)
            {
                if (x.length() > y.length()) return (">");
                if (x.length() < y.length()) return ("<");
                if (x.length() == y.length())
                {
                    int max = x.length();
                    for (int i = 0; i < max; i++)
                    {
                        if (x[i] != y[i])
                        {
                            if (x[i] > y[i]) return ">";
                            return "<";
                        }
                    }
                }
                return "=";
            }
    int main(){
        string a,b;
        cin>>a>>b;
         if (a == "") a = "0";
         if (b == "") b = "0";
         if (Muqayise(a,b) == "="){
            cout << "EQUAL" << endl;
            return 0;
         }
         if (Muqayise(a,b) == ">"){
            cout << "GREATER" << endl;
            return 0;
         }
     
           if (Muqayise(a,b) == "<"){
            cout << "LESS" << endl;
            return 0;
         }
         return 0;
    }

Measured memory_bytes: 888
// solution is at the bottom

import kotlin.math.*
import kotlin.system.exitProcess

@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

const val _BUFFER_SIZE = 1 shl 16
@JvmField val _buffer = ByteArray(_BUFFER_SIZE)
@JvmField var _bufferPt = 0
@JvmField var _bytesRead = 0

tailrec fun readChar(): Char {
    if(_bufferPt == _bytesRead) {
        _bufferPt = 0
        _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)
    }
    return if(_bytesRead < 0) Char.MIN_VALUE
    else {
        val c = _buffer[_bufferPt++].toChar()
        if (c == '\r') readChar()
        else c
    }
}

fun readLine(): String? {
    var c = readChar()
    return if(c == Char.MIN_VALUE) null
    else buildString {
        while(true) {
            when(c) {
                '\n', Char.MIN_VALUE -> return@buildString
                else -> {
                    append(c)
                    c = readChar()
                }
            }
        }
    }
}
fun readLn() = readLine()!!

fun read() = buildString {
    var c = readChar()
    while(c <= ' ') {
        if(c == Char.MIN_VALUE) return@buildString
        c = readChar()
    }
    do {
        append(c)
        c = readChar()
    } while(c > ' ')
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

fun main() {
    val (d, t, s) = readIntArray(3)
    if (t * s >= d) {
        println("Yes")
    } else {
        println("No")
    }
}


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

int main() {
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << W*H/2 << " ";
  if (x == W/2 && y == H/2) cout << 1 << endl;
  else cout << 0 << endl;
}

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

#define rep(x, y) for (int i = (x); i < (y); i++)

typedef long long ll;

using namespace std;

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;

    rep(0, n) {
        cout << s[i] << t[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 100 * 1000 + 47;

int A[MAX];
int main()
{
    // freopen("in.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    FOR(i, 0, n)scanf("%d", A + i);
    sort(A, A + n);
    
    if (A[n-1] - A[0] > 1)
    {
        printf("No\n");
        return 0;
    }
    
    if (A[n-1] - A[0] == 1)
    {
        int a = 0, b = 0;
        FOR(i, 0, n)
        if (A[i] == A[0])a++;
        else b++;
        //cout << a << " " << b << endl;
        if (a + 1 <= A[n-1] && 2 * A[n-1] <= 2 * a + b)
            printf("Yes\n");
        else printf("No\n");
            
        
    }
    else
    {
        if (A[0] == n-1)
        {
            printf("Yes\n");
            return 0;
        }
        bool ok = 1;
        FOR(i, 0, n)
            if (2 * A[i] > n)
                ok = 0;
        if (ok)printf("Yes\n");
        else printf("No\n");
    }
    

    
    return 0;
}






Measured memory_bytes: 640
nm=[int(x) for x in input().split()]
N=nm[0]
M=nm[1]

to=[N]*N
for _ in range(M):
    nm=[int(x) for x in input().split()]
    A=nm[0]-1
    B=nm[1]-1
    if to[B]==N or to[B]<A:
        to[B]=A

last=0
ans=0
for i in range(N):
    if to[i]==N:
        continue
    if to[i]>=last:
      last=i
      ans+=1
print(ans)



        
    
    
  

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

int main() {
  int N;
  cin >> N;
  long long sum = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      sum += i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3592
import itertools


def count_chains(nums):
    it = iter(nums)
    try:
        previous = next(it)
    except StopIteration:
        return

    count = 1
    for n in it:
        if previous < n:
            yield count
            count = 0

        count += 1
        previous = n

    yield count


def main():
    n = int(input())
    h = [int(x) for x in input().split()]

    print(max(count_chains(h)) - 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14528
arr = list(map(int, input().split()))

W = arr[0]
H = arr[1]
x = arr[2]
y = arr[3]
r = arr[4]

top = y + r
bottom = y - r
right = x + r
left = x - r

if top <= H and bottom >= 0 and right <= W and left >= 0:
	print("Yes")
else:
	print("No")



Measured memory_bytes: 5596
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
      
        
 
		// 出力
		System.out.println(2 * b - a);
	}
}

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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N,M,K; cin >> N >> M >> K;
	map<int,vi> row,col;
	map<int,int> cnt;
	set<ii> maxi;
	forn(i,0,K){
		int r,c; cin >> r >> c; r--; c--;
		row[r].pb(c);
		col[c].pb(r);
		cnt[c]++;
	}
	for(auto &x : cnt)maxi.insert({x.se,x.fi});
	int res = 0;
	for(auto &x : row){
		int resTmp = x.se.size();
		//quitamos
		for(auto &y : x.se){
			//int r = x.fi;
			int c = y;
			maxi.erase({cnt[c],c});
			cnt[c]--;
			maxi.insert({cnt[c],c});
		}
		if(maxi.size()){
			auto it = maxi.rbegin();
			resTmp += it->fi;
		}
		res = max(res,resTmp);
		//regresamos
		for(auto &y : x.se){
			//int r = x.fi;
			int c = y;
			maxi.erase({cnt[c],c});
			cnt[c]++;
			maxi.insert({cnt[c],c});
		}
	}
	
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 97364
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        if(n<=2)
        {
        cout<<n;
        exit(0);
        }
        for(ll i=0;i<8;i++)
        {
            if(n>pow(2,i+1) && n<=pow(2,i+2))
            {
                if(n==pow(2,i+2))
                {cout<<pow(2,i+2);
                break;}
                else
                {cout<<pow(2,i+1);
                break;}
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4316
#include<bits/stdc++.h>
using namespace std;
typedef long long int ld;
int main()
{
    int n,k,i,j;
    cin>>n>>k;
    ld dp[n],h[n],min;
    for(i=0;i<n;i++)
        cin>>h[i];
    dp[0]=0;
    //dp[1]=abs(h[1]-h[0]);
    for(i=1;i<n;i++)
    {
        min=dp[i-1]+abs(h[i]-h[i-1]);
        for(j=2;j<=k;j++)
        {
            if((i-j)<0)
                break;
            if((dp[i-j]+abs(h[i]-h[i-j]))<min)
                min=dp[i-j]+abs(h[i]-h[i-j]);
        }
        dp[i]=min;
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
p = list(map(int, input().split()))

import numpy as np
exps = np.array(p) / 2 + 0.5

# s = exps[:k].sum()
# m = s
# for i in range(1, n - k + 1):
#     s = s - exps[i-1] + exps[i+k-1]
#     if s > m:
#         m = s
# print(m)

cum = exps.cumsum()
diff = cum[k-1:n] - np.r_[0, cum[:n-k]]
print(diff.max())

Measured memory_bytes: 25060
#include <stdio.h>

int main(void)
{
	int n,v[100],c[100],sum;
	
	sum=0;
	
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		
		scanf("%d",&v[i]);
		
	}
	
	for(int i=0;i<n;i++){
		
		scanf("%d",&c[i]);
		
	}
	
	for(int i=0;i<n;i++){
		
		if(v[i]-c[i]>0){
			
			sum=sum+(v[i]-c[i]);
			
		}
		
	}
	
	printf("%d\n",sum);
	
	return 0;
	
}
	

Measured memory_bytes: 128
N = int(input())
A = [int(input()) for i in range(N)]

max1 = max(A[0], A[1])
max2 = min(A[1], A[0])
if A[0] > A[1]:
    maxi1 = 0
    maxi2 = 1
else:
    maxi1 = 1
    maxi2 = 0


for i, a in enumerate(A[2:], 2):
    if max1 < a:
        max2 = max1
        maxi2 = maxi1
        max1 = a
        maxi1 = i
    elif max2 < a:
        max2 = a
        maxi2 = i

for i in range(N):
    if i != maxi1:
        print(max1)
    else:
        print(max2)



Measured memory_bytes: 70360
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {

      
 public static void main(String[] args) {
    
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    String T = in.nextLine();
    String S = in.nextLine();
    int slen = S.length();
    int tlen = T.length();
    int[][] dp = new int[slen+1][tlen+1];
    char[][] ch = new char[slen+1][tlen+1];
    
    StringBuilder sb = new StringBuilder();
    
    for(int i = 1 ; i <= slen; i++) {
        for(int j = 1; j <= tlen; j++) {
            if(S.charAt(i-1) == T.charAt(j-1)) {
                ch[i][j] = 'd';
                dp[i][j] = dp[i-1][j-1]+1;
            } else if(dp[i-1][j] >= dp[i][j-1]){
                ch[i][j] = 'u';
                dp[i][j] = dp[i-1][j];
            } else {
                ch[i][j] = 'l';
                dp[i][j] = dp[i][j-1];
            }
        }
    }
    dfs(ch, slen, tlen, slen+1, tlen+1, sb, S);
    System.out.println(sb.reverse().toString());
  }
  
  private static void dfs(char[][] ch, int r, int c, int nr, int nc, StringBuilder sb, String S) {
      if(r <= 0 || c <= 0 || r >= nr || c >= nc) return ;
      
      if(ch[r][c] == 'd')  {
          sb.append(S.charAt(r-1));
          dfs(ch, r-1, c-1, nr, nc, sb, S);
      }
      else if(ch[r][c] == 'u') {
          dfs(ch, r-1,c, nr, nc, sb, S);
      }
      else if(ch[r][c] == 'l') {
          dfs(ch, r, c-1, nr, nc, sb, S);
      }
  }
  
}

Measured memory_bytes: 89276
use std::io::prelude::*;
use std::str::FromStr;

fn main() {
    let stdin_ = std::io::stdin();
    let stdout_ = std::io::stdout();
    let mut stdin = stdin_.lock();
    let mut stdout = stdout_.lock();

    let mut buffer = String::new();
    stdin.read_line(&mut buffer).unwrap();
    let v = buffer
        .split_whitespace()
        .map(|s| usize::from_str(s).unwrap())
        .collect::<Vec<_>>();
    let n = v[0];
    let k = v[1];
    buffer.clear();
    stdin.read_line(&mut buffer).unwrap();
    let s = buffer.trim().chars().collect::<Vec<char>>();

    let mut nums = Vec::<u64>::new();
    let mut now = 1;
    let mut cnt = 0;
    for i in 0..n {
        if s[i] as u8 == now + '0' as u8 {
            cnt += 1;
        } else {
            nums.push(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }
    if cnt > 0 {
        nums.push(cnt);
    }
    if nums.len() % 2 == 0 {
        nums.push(0);
    }

    let add = 2 * k + 1;
    let mut ans = 0;
    let mut left = 0;
    let mut right = 0;
    let mut tmp = 0;

    for i in 0..nums.len() {
        if i % 2 == 1 {
            continue;
        }

        let next_left = i;
        let next_right = std::cmp::min(i + add, nums.len());

        loop {
            if next_left <= left {
                break;
            }

            tmp -= nums[left];
            left += 1;
        }

        loop {
            if next_right <= right {
                break;
            }

            tmp += nums[right];
            right += 1;
        }

        ans = std::cmp::max(ans, tmp);
    }

    write!(stdout, "{}\n", ans).unwrap();
}


Measured memory_bytes: 4352
#include<stdio.h>

/*AtCode で次に開催されるコンテストは ABC と呼ばれ、レーティングが 1200 未満の参加者のレーティングが変動します。
その次に開催されるコンテストは ARC と呼ばれ、レーティングが 2800 未満の参加者のレーティングが変動します。
そのさらに次に開催されるコンテストは AGC と呼ばれ、すべての参加者のレーティングが変動します。*/

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


Measured memory_bytes: 128
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define deb1(x) cout << #x <<"="<< x <<endl;
#define deb2(x,y) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<endl;
#define deb3(x,y,z) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<<endl;
#define deb4(x,y,z,a) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<< ", "<<#a <<"="<<a << endl;
#define debarr(x) cout << #x<<"::"<<endl;for(int i : x){cout << i <<" ";} cout <<endl;

inline void add(int& a, int b){a = (a+b); if(a>=mod)a-=mod;}
inline void sub(int& a, int b){a = a-b; if(a<0)a+=mod;}
inline void mul(int& a, int b){a = (a*b)%mod;}



void mymain(){
    int ans=0;
    int n;
    cin >> n;
    for(int a=1;a<=n;a++)
        for(int b=1;b<=n;b++)
    for(int c=1;c<=n;c++){
        int g = __gcd(a,b);
        g = __gcd(g,c);
        ans += g;
    }
    cout << ans <<endl;
}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
///cin>>t;

for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
}
return 0;
}
/*

*/


Measured memory_bytes: 3652
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <cmath>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define ins insert
#define iter ::iterator
#define upb upper_bound
#define lwb lower_bound

#define sz(v) v.size()
#define aloc(i, a, n) i *a = new i[n]

#define for0(i,a) for(ll i = 0; i < a; i++)
#define fori(i,a,b) for(ll i = a; i < b; ++i)
#define rfor0(i,a) for(ll i = a; i >= 0; --i)
#define rfor(i,a,b) for(ll i = a; i >= b; --i)

int main(){

  int a,b;
  cin >> a >> b;
  if(a % b != 0) cout << a / b + 1 << endl;
  else cout << a / b << endl;

}


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

#define ll long long int

int main()
{
	
		char c;
		cin>>c;
		string ss="abcdefghijklmnopqrstuvwxyz";
		for(int i=0;i<ss.size();i++){
			if(c==ss[i]){
				cout<<ss[i+1];
				break;
			}
		}
		


}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, k int
	fmt.Scan(&a,&b,&k)
	
	if a+b <= k {
		fmt.Println(0,0)
	}else if (a <= k) {
		fmt.Println(0, b-(k-a))
	}else {
		fmt.Println(a-k,b)
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;

#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

typedef long long ll;
typedef pair<int, int> pii;

int main() {
  ll n;
  cin >> n;
  int ans = 0;
  for (int i = 2; ; i++) {
    if (1LL * i * i > n) break;
    int cnt = 0;
    while (n % i == 0) n /= i, cnt++;
    if (cnt == 0) continue;
    for (int j = 1; j < 10; j++) {
      if (cnt >= j) cnt -= j, ans++;
      else break;
    }
  }
  if (n > 1) ans++;
  cout << ans << endl;
}


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

int main()
{
  string buf;
  cin >> buf;
  
  if (buf.find("a") != std::string::npos &&
      buf.find("b") != std::string::npos &&
      buf.find("c") != std::string::npos)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) {
        cin >> a[i];
    }
    string s;
    cin >> s;
    reverse(a, a + n);
    reverse(ALL(s));
    vector<ll> bs;
    rep(i, n) {
        for (auto b : bs) {
            a[i] = min(a[i], a[i] ^ b);
        }
        if (s[i] == '0') {
            if (a[i] != 0) bs.emplace_back(a[i]);
        } else {
            if (a[i]) {
                cout << 1 << endl;
                return;
            }
        }
    }
    cout << 0 << endl;
}

signed main() {
    int tt;
    cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

vector<ll>a,b;
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		int z;
		cin>>z;
		a.push_back(z);
		b.push_back(z);
	}
	sort(b.begin(),b.end());
	bool ans=true;
	for(int i=0;i<n;i++){
		if(a[i]!=b[i]){
			ans=false;
			break;
		}
	}
	if(ans){
		cout << "YES";
		return 0;
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ans=true;
			swap(a[i],a[j]);
			for(int k=0;k<n;k++){
				if(a[k]!=b[k]){
					ans=false;
					break;
					}
				}
				if(ans){
					cout<< "YES";
					return 0;
				}
				swap(a[i],a[j]);
		}

	}
	cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define re(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
int n;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    string s,t;
    cin>>s>>t;
    int kai=0;
    rep(i,s.size()){
        if(s[i]==t[i]){
            kai++;
        }
    }
    cout<<kai<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  string a, b;
  while(cin >> a >> b, a != "0") {
    int hi = 0, br = 0;
    REP(i,4) {
      REP(j,4) {
        if (a[i] == b[j]) {
          if (i==j) hi++;
          else br++;
        }
      }
    }
    cout << hi << " " << br << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0; i < 4; i++){
		if(s[i] == '+') ans++;
		else ans--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

vector<vector<char>> v;

int main () {
    int N;
    cin >> N;
    v = vector<vector<char>>(N, vector<char>(N));
    REP (i, 0, N) REP (j, 0, N) cin >> v[i][j];

    int cc = N * N, rr = 0;
    int ans = N * N;
    vector<int> c(N, 0);
    vector<int> r(N, 0);
    REP (i, 0, N) {
        REP (j, 0, N) {
            c[i] += (v[i][j] == '#' ? 0 : 1);
            r[j] += (v[i][j] == '#' ? 0 : 1);
        }
        cc = min(cc, c[i]);
    }

    REP (i, 0, N) rr += (r[i] != 0 ? 1 : 0);

    if (cc == N) {
        cout << -1 << endl;
        return 0;
    }

    //cout << rr << endl;

    if (cc == 0) {
        ans = N;
        REP (i, 0, N) {
            if (r[i] == 0) ans--;
        }
    } else {
        REP (t, 0, N) {
            int temp = 0;
            if (r[t] != N) {
                temp = c[t] + rr;
                ans = min(ans, temp);
            } else {
                temp = c[t] + 1 + rr;
                ans = min(ans, temp);
            }
        }
    }
    if (ans == N * N) ans = -1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    char x,y;
    cin>>x>>y;
    if(x>y)cout<<">"<<endl;
    else if(x<y)cout<<"<"<<endl;
    else cout<<"="<<endl;
}

Measured memory_bytes: 256
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>
#include<cmath>
#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N ;
char str[26];
std::map<char,int> M ;
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  cin >> N ;
  if(N == 1){
    cout << 1 << endl;
    return 0 ;
  }
  int p ;
  int ans ;

  for(int i = 2 ; i < 32 ; i++){
    for(int j = 2 ; j <= 10 ; j++)
    {
      if(pow(i,j) <= N)
      {
        ans = max((int)(pow(i,j)),ans);
      }
    }

  }
  cout << ans << endl;
  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a%3==0 || b%3==0 || (a+b)%3==0?"P":"Imp") << "ossible";   
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int a, b;
	int d=0, r=0;
	double f=0;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a % b;
	f = (double)a / b;
	printf("%d %d %.5f\n", d, r, f);
	return 0;
}


Measured memory_bytes: 2112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc119d
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var H = ReadIntList();
            var ans = 1;
            var max = H[0];
            for (int i = 1; i < N; i++)
            {
                if(H[i] >= max)
                {
                    ans++;
                }
                if(max < H[i])
                {
                    max = H[i];
                }
            }
            Console.WriteLine(ans);
#if DEBUG
            Console.ReadKey();
#endif
        }

        private static bool IsRange(int a, int from, int to) => (from <= a && a <= to);
        private static int ReadInt() => int.Parse(Console.ReadLine());
        private static List<int> ReadIntList() => Console.ReadLine().Split().Select(int.Parse).ToList();
        private static double ReadDouble() => double.Parse(Console.ReadLine());
        private static List<double> ReadDoubleList() => Console.ReadLine().Split().Select(double.Parse).ToList();
        private static long ReadLong() => long.Parse(Console.ReadLine());
        private static List<long> ReadLongList() => Console.ReadLine().Split().Select(long.Parse).ToList();
        private static List<int> Int2Digits(int a) => a.ToString().ToCharArray().Select(_ => int.Parse(_.ToString())).ToList();
        private static int BinarySearch<Type>(IReadOnlyList<Type> s, Type target) // target 以下の最大要素のインデックスを返す
            where Type : IComparable
        {
            var lower = 0;
            var upper = s.Count - 1;
            while (upper - lower > 1)
            {
                var mid = lower + (upper - lower) / 2;
                if (s[mid].CompareTo(target) <= 0)
                {
                    lower = mid;
                }
                else
                {
                    upper = mid;
                }

            }
            return lower;
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define ll long long int 
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector<pair<pll,pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll,ll>
#define fir first
#define sec second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define fo(i,b) for(i=0;i<b;i++)
#define repa(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define all(x) (x).begin(), (x).end()
#define s(v) v.size()
const long long int MAX = (ll)(1e18+1);
const long long int MIN = (ll)(-1e18-1);
const long long int mod = (ll)(1e9+7);
using namespace std;

ll max(ll a,ll b,ll c) {return max(max(a, b), c);}
ll min(ll a,ll b,ll c) { return min(min(a, b), c);}
ll max(ll a,ll b) {return (a>b) ? a : b;}
ll min(ll a,ll b) {return (a<b) ? a : b;}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power_mod(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=(p*a)%mod_;} n/=2; a=(a*a)%mod_;} return p%mod_;}
                                                 /*Code Begins*/


int main(){
     
    _cin;
    // cout << setprecision(15);
    ll mn = MAX, mx = MIN;
    ll n, t, m, k, i, j,  sum=0,  prev, flag=0, cnt=0;
    ll x=0, y=0, fx, tot=0, l , r;
    int TC=1;
    // cin >> TC;
while(TC--){
    cin >> n;
    int a[n][n];
    fo(i,n) fo(j,n) cin >> a[i][j];
    ll dp[1LL<<n] = {0};
    for(ll msk =0; msk < 1LL<<n; msk++){
        dp[msk]=0;
        fo(i,n){
            if(!(msk & 1LL<<i)) continue;
            repa(j,i+1,n){
                if(msk & 1LL<<j) dp[msk] += a[i][j];
            }
        }
    }

    vll F(1LL<<n);
    for (ll mask = 0; mask < (1LL<<n); mask++){
    F[mask] = dp[mask];
    for(ll i = mask; i > 0; i = (i-1) & mask){
        F[mask] = max(F[mask] , dp[i] + F[mask ^ i]);
    }
}

    cout << F[(1LL<<n)-1];
}
    return 0;
}


Measured memory_bytes: 1280
#include <iostream> 
using namespace std;
	 
int main()
{
	int n,i,p,a,s=0,b,c,total=0;
	cin>>n>>a>>b;
	
	for(i=1;i<=n;i++){
		p=i;
		s=0;
		while(p!=0){
			c=p%10;
			s+=c;
			p/=10;
		}
		if(s>=a && s<=b) total+=i; 
	}
	
	cout<<total<<endl;
	return 0;
}

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

typedef struct DICE{
    int s[6];
}dice;

dice dice_rotate(dice d, char rotate){
    int swap;
    if(rotate == 'E'){
        swap = d.s[2];
        d.s[2] = d.s[0];
        d.s[0] = d.s[3];
        d.s[3] = d.s[5];
        d.s[5] = swap;
    }else if(rotate == 'N'){
        swap = d.s[4];
        d.s[4] = d.s[0];
        d.s[0] = d.s[1];
        d.s[1] = d.s[5];
        d.s[5] = swap;
    }else if(rotate == 'S'){
        swap = d.s[1];
        d.s[1] = d.s[0];
        d.s[0] = d.s[4];
        d.s[4] = d.s[5];
        d.s[5] = swap;
    }else if(rotate == 'W'){
        swap = d.s[3];
        d.s[3] = d.s[0];
        d.s[0] = d.s[2];
        d.s[2] = d.s[5];
        d.s[5] = swap;
    }

    return d;
}

int main(){
    dice d,proto;
    char rotate;
    int i,j,q,top,flont;

    for(i=0;i<6;i++){
        cin >> d.s[i];
    }

    proto = d;

    cin >> q;
    for(j=0;j<q;j++){
        d = proto;
        cin >> top;
        cin >> flont;
        i=0;
        while(d.s[0] != flont){
            if(i%2==0){
                d = dice_rotate(d, 'S');
            }else if(i%2==1){
                d = dice_rotate(d, 'E');
            }
            i++;
        }
        d = dice_rotate(d, 'S');
        while(d.s[0] != top){
            d = dice_rotate(d, 'E');
        }
    cout << d.s[2] << endl;

    }
    return 0;
}



Measured memory_bytes: 3092