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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

template <class T>
struct SegmentTree{
  using F = function<T(T,T)>;
  F f;
  T inf;
  int n;
  vector<T> node;

  SegmentTree(vector<T> v,T inf,F f) : inf(inf),f(f) {
    n = 1; while(n < v.size()) n *= 2;
    node.resize(2*n-1,inf);
    for(int i = 0; i < v.size(); i++) node[i+n-1] = v[i];
    for(int i = n-2; i >= 0; i--) node[i] = f(node[2*i+1],node[2*i+2]);
  }

  void update(int k,T val){
    k += n-1;
    node[k] = val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  T getval(int a,int b){ return getval(a,b,0,0,n); }
  T getval(int a,int b,int k,int l,int r){
    //区間[a, b)の値を返す
    if(r <= a || b <= l) return inf;
    if(a <= l && r <= b) return node[k];
    T vl = getval(a, b, 2*k+1, l, (l+r)/2);
    T vr = getval(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
  }
};

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    a[i] *= -1;
  }

  auto f = [&](int x,int y){
    if(x < y) return x;
    else return y;
  };
  SegmentTree<int> seg(a,0,f);

  for(int i = 0; i < n; i++){
    cout << -f(seg.getval(0,i),seg.getval(i+1,n)) << endl;
  }

  return 0;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int H, W, h, w;
    cin >> H >> W >> h >> w;

    int masu = H * W;
    cout << masu - h * W - ((w * H) - (w * h)) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] menu = new int[]{sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()};
		sc.close();

		int ans = 0;

		int min = 10;
		int minIdx = 0;
		for (int i = 0; i < 5; i++) {
			int digit = menu[i] % 10;
			if (digit != 0 && digit < min) {
				min = digit;
				minIdx = i;
			}
		}

		for (int i = 0; i < 5; i++) {
			if (i != minIdx) {
				ans += menu[i];
				if (ans % 10 != 0) {
					ans = (int) Math.ceil(ans / 10.0) * 10;
				}
			}
		}

		ans += menu[minIdx];
		System.out.println(ans);
	}
}


Measured memory_bytes: 35672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    
    cout << s.substr(0, s.length() - 8) << endl;    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <set>

typedef long long llint;

using namespace std;

int n;

set<int> s;
map<int, int> cnt;

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
    if (cnt[x] > 1) s.insert(x);
  }
  
  if (s.size() < 2) {
    printf("0\n");
    return 0; 
  }
  
  auto A = s.rbegin();
  
  if (cnt[*A] > 3) {
    printf("%lld\n", (llint) *A * *A);
  } else {
    auto B = s.rbegin();
    ++B;
    printf("%lld\n", (llint) *A * *B);
  }
  
  return 0;
}

Measured memory_bytes: 4864
from scipy.sparse import*
N,M,R=map(int,raw_input().split())
r=[int(e) for e in raw_input().split()]
a,b,c=zip(*(map(int,raw_input().split())for _ in range(M)))
a=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0,r)
print int(min(sum(a[e[i]][r[e[i+1]]]for i in range(R-1))for e in __import__('itertools').permutations(range(R))))

Measured memory_bytes: 22060
#include <stdio.h>
#define N 100
void DFvisit(int); 
int n,A[N][N],d[N],f[N],g[N],t=0;

void DFSvisit(int u){
   int v;
  
  g[u] = 2;
  t++;
  d[u] = t;
  
  for(v = 0;v < n;v++){
    if(A[u][v] == 1 && g[v] == 0)    {
      DFSvisit(v);
    }
  }
  g[u] = 1;
  f[u] = ++t;
  
  return;
}


int main(){
  int i,j,u,v,k;
  
  
  scanf("%d",&n);
  
  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      A[i][j] = 0;
    }
  }
 

  for(i = 0;i < n;i++){
    scanf("%d%d",&u,&k);

    for(j = 0;j < k;j++){
      scanf("%d",&v);
      A[u-1][v-1] = 1;
    }
  }

 
  for(i = 0;i < n;i++){
    g[i]=0;
  }
  
  for(i = 0;i < n;i++){
    if(g[i] == 0)    {
      DFSvisit(i);
    }
  }
  
  for(i = 0;i < n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  
  return 0;
}

Measured memory_bytes: 632
import * as fs from 'fs'
const reader = (s: string) => parseInt(s, 10)

function Main(input: string) {
  const N = reader(input)
  let ans = 0

  for (let i = 1; i <= N; i++) {
    ans += i
  }

  console.log(ans)
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7500
#include <iostream>
#include <algorithm>

using namespace std;

int main (void)
{
	int n,a,b,c,d;

	cin >> n >> a >> b >> c >> d;

	int p = 0,q = 0;

	for (int i = 0; i < n + 1; i++)
	{
		if (i * a >= n)
		{
			p = b * i;
			break;
		}
	}
	for (int i = 0; i < n + 1; i++)
	{
		if (i * c >= n)
		{
			q = d * i;
			break;
		}
	}

	cout << min(p,q) << endl;
}


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

namespace Contest.cs
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] input = ReadIntList();
			int n = input[0];
			int k = input[1];
			int ans = 0;
			while((k-1)*(ans-1) +k < n)
			{
				ans++;
			}
			Console.WriteLine(ans);
		}

		static string[] ReadStr()
		{
			return Console.ReadLine().Split(' ').ToArray();

		}

		static int[] ReadIntList()
		{
			return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
		}
	}
}

Measured memory_bytes: 13268
x, y = map(int, input().split())

if x == -y:   # |x| == |y|
    print(1)
else:
    if abs(x) < abs(y):
        if x >= 0 and y > 0:
            print(abs(y)-abs(x))
        elif x >= 0 and y < 0:
            print(abs(y)-abs(x)+1)
        elif x < 0 and y > 0:
            print(abs(y)-abs(x)+1)
        else:
            print(abs(y)-abs(x)+2)
    else:  # abs(x) > abs(y)
        if x > 0 and y > 0:
            print(abs(x)-abs(y)+2)
        elif x > 0 and y <= 0:
            print(abs(x)-abs(y)+1)
        elif x < 0 and y > 0:
            print(abs(x)-abs(y)+1)
        else:
            print(abs(x)-abs(y))


Measured memory_bytes: 3064
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def cross2(p, q):
    return p[0]*q[1] - p[1]*q[0]
def cross3(o, p, q):
    return (p[0] - o[0])*(q[1] - o[1]) - (p[1] - o[1])*(q[0] - o[0])
def dot2(p, q):
    return p[0]*q[0] + p[1]*q[1]
def dist2(p):
    return p[0]**2 + p[1]**2
def segment_line_dist(x, p0, p1):
    z0 = (p1[0] - p0[0], p1[1] - p0[1])
    z1 = (x[0] - p0[0], x[1] - p0[1])
    if 0 <= dot2(z0, z1) <= dist2(z0):
        return abs(cross2(z0, z1)) / dist2(z0)**.5
    z2 = (x[0] - p1[0], x[1] - p1[1])
    return min(dist2(z1), dist2(z2))**.5

def polygon_cont(x, PS):
    V = [cross3(PS[i-1], PS[i], x) for i in range(len(PS))]
    return all(e >= 0 for e in V) or all(e <= 0 for e in V)
def polygon_dist(x, PS):
    return min(segment_line_dist(x, PS[i-1], PS[i]) for i in range(len(PS)))

def check(x, PS):
    if not polygon_cont(x, PS):
        return -polygon_dist(x, PS)
    return polygon_dist(x, PS)
def check_x(x, PS):
    ly = min(y for x, y in PS); ry = max(y for x, y in PS)
    EPS = 1e-6
    while ly + EPS < ry:
        y0 = (ly*2 + ry) / 3; y1 = (ly + ry*2) / 3
        if check((x, y0), PS) < check((x, y1), PS):
            ly = y0
        else:
            ry = y1
    return ly

def solve():
    N = int(readline())
    if N == 0:
        return False
    PS = [list(map(int, readline().split())) for i in range(N)]
    EPS = 1e-6
    lx = min(x for x, y in PS); rx = max(x for x, y in PS)
    while lx + EPS < rx:
        x0 = (lx*2 + rx) / 3; x1 = (lx + rx*2) / 3
        y0 = check_x(x0, PS); y1 = check_x(x1, PS)
        if check((x0, y0), PS) < check((x1, y1), PS):
            lx = x0
        else:
            rx = x1
    x0 = lx
    y0 = check_x(x0, PS)
    write("%.16f\n" % check((x0, y0), PS))
    return True
while solve():
    ...


Measured memory_bytes: 5776
H,W = map(int,input().split())
S = [['x'] * (W+2)]
for i in range(H) :
    s1 = ['x']
    s1 += list(input())
    s1.append('x')
    S.append(s1)

S.append(['x'] * (W+2))
around = [[-1,-1],[-1,0],[-1,1],[0,1],[1,1],[1,0],[1,-1],[0,-1]]
for i in range(H+1) :
    for j in range(W+1) :
        if S[i][j] == '.' :
#            print('S[{}][{}]'.format(i,j))
            count = 0
            for k in range(8) :
                if S[i+around[k][0]][j+around[k][1]] == '#' :
#                    print('         around[{}] = {}'.format(k,around[k]))
#                    print('             S[{}][{}] = #'.format(i+around[k][0],j+around[k][1]))
                    count += 1
            S[i][j] = count

ans = ['']* H
for i in range(1,H+1) :
    for j in range(1,W+1) :
        ans[i-1] += str(S[i][j])
    print(ans[i-1])


Measured memory_bytes: 9116
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


N, K = map(int, input().split())
black = []
white = []
for i in range(N):
    x, y, c = map(str, input().split())
    temp = 0
    dx, x = divmod(int(x), K)
    temp += dx
    dy, y = divmod(int(y), K)
    temp += dy
    color = 0 if c == 'B' else 1
    color = (color + temp) % 2
    if color == 0:
        white.append((x, y))
    else:
        black.append((x, y))

white_bit_list = [0]
black_bit_list = [0]
for _ in range(K):
    white_bit = Bit(K)
    black_bit = Bit(K)
    white_bit_list.append(white_bit)
    black_bit_list.append(black_bit)
white_y = [0] * K
black_y = [0] * K
for xy in white:
    x, y = xy
    white_y[y] += 1
    x += 1
    y += 1
    white_bit_list[x].add(y, 1)
for xy in black:
    x, y = xy
    black_y[y] += 1
    x += 1
    y += 1
    black_bit_list[x].add(y, 1)
white_y_cum = [0] * (K + 1)
black_y_cum = [0] * (K + 1)
for i in range(K):
    white_y_cum[i + 1] = white_y_cum[i] + white_y[i]
    black_y_cum[i + 1] = black_y_cum[i] + black_y[i]

ans_best = 0
for dy in range(1, K):
    ul_w = 0
    ur_b = black_y_cum[dy]
    ll_b = 0
    lr_w = white_y_cum[-1] - white_y_cum[dy]
    ans = ul_w + ur_b + ll_b + lr_w
    ans_best = max(ans_best, ans, N - ans)
    for dx in range(1, K):
        ul_w += white_bit_list[dx].sum(dy)
        ur_b -= black_bit_list[dx].sum(dy)
        ll_b += black_bit_list[dx].sum(K) - black_bit_list[dx].sum(dy)
        lr_w -= white_bit_list[dx].sum(K) - white_bit_list[dx].sum(dy)
        ans = ul_w + ur_b + ll_b + lr_w
        ans_best = max(ans_best, ans, N - ans)
l_w = 0
r_b = len(black)
ans = l_w + r_b
ans_best = max(ans_best, ans, N - ans)
for dx in range(1, K):
    l_w += white_bit_list[dx].sum(K)
    r_b -= black_bit_list[dx].sum(K)
    ans = l_w + r_b
    ans_best = max(ans_best, ans, N - ans)

print(ans_best)


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

using namespace std;
int main() {
	long long X, K, D;
	cin >> X >> K >> D;
	if (X < 0) {
		X = -X;
	}
	long long count = X / D;
	if (count >= K) {
		cout << X - K * D << endl;
		return 0;
	}
	if (1 == K%2) {
		long long x = X + D;
		cout << min(x % (2 * D), abs(2 * D - x % (2 * D))) << endl;
	}
	else {
		cout << min(X % (2 * D), abs(2 * D - X % (2 * D))) << endl;
	}
	return 0;
}


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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<PP, int> PPP;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};





int main(){
	int n, m;
	int ans = 0;
	map<string, int> mr, mb;
	vector<string> b;
	cin >> n;
	string in;
	for(int i = 0; i < n; i++){
		cin >> in;
		mb[in]++;
		if(find(b.begin(), b.end(), in) == b.end()) b.pb(in);
	}
	cin >> m;
	for(int i = 0; i < m; i++){
		cin >> in;
		mr[in]++;
	}
	for(int i = 0; i < b.size(); i++){
		ans = max(ans, mb[b[i]] - mr[b[i]]);
	}

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

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, L = map(int, readline().split())
    G = [[INF] * N for _ in range(N)]
    for _ in range(M):
        a, b, c = map(int, readline().split())
        G[a - 1][b - 1] = G[b - 1][a - 1] = c
    for i in range(N):
        G[i][i] = 0

    Q, *ST = map(int, read().split())

    for k in range(N):
        for i in range(N):
            for j in range(N):
                if G[i][j] > G[i][k] + G[k][j]:
                    G[i][j] = G[i][k] + G[k][j]

    H = [[INF] * N for _ in range(N)]
    for i in range(N - 1):
        for j in range(i + 1, N):
            if G[i][j] <= L:
                H[i][j] = H[j][i] = 1

    for i in range(N):
        H[i][i] = 0

    for k in range(N):
        for i in range(N):
            for j in range(N):
                if H[i][j] > H[i][k] + H[k][j]:
                    H[i][j] = H[i][k] + H[k][j]

    ans = [0] * Q
    for i, (s, t) in enumerate(zip(*[iter(ST)] * 2)):
        s -= 1
        t -= 1
        if H[s][t] == INF:
            ans[i] = -1
        else:
            ans[i] = H[s][t] - 1

    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 101988
use std::cmp::*;

fn main() {
    let n = read::<usize>();
    let a1 = read_vec::<u32>();
    let a2 = read_vec::<u32>();

    let mut maxcount = 0;
    for i in 0..n {
        let mut count = 0;
        for j in 0..i + 1 {
            count += a1[j];
        }
        for k in i..n {
            count += a2[k];
        }
        maxcount = max(maxcount, count);
    }
    println!("{}", maxcount);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  char a,b;
  cin >> a >> b;
  if(a=='H'){
    if(b=='H'){
      cout << "H" << endl;
    }else{
      cout << "D" << endl;
    }
  }else{
    if(b=='H'){
      cout << "D" << endl;
    }else{
      cout << "H" << endl;
    }
  }
  return 0;
}


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

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        String s = sc.nextLine();

        for (int i = 1; i < s.length(); ++i) {
            if (s.substring(0, (s.length() - i) / 2).equals(s.substring((s.length() - i) / 2, s.length() - i))) {
                _out.println(s.length() - i);
                break;
            }
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
 //   freopen("input.txt", "r", stdin);
    SPEED
    ll a, b;
    cin >> a >> b;
    cout << (b + a - 2 - 1) / (a - 1);
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting, graph is not a tree/connected
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.HashMap;

public class Main {

    public static void main(String[] args){
        new Main().solve();
    }
   void solve() {
	   Scanner sc=new Scanner(System.in);
	   int n=sc.nextInt();
	   int k=sc.nextInt();
	   long[]a=new long[n];
	   long[]b=new long[n];
	   for(int i=0;i<n;i++) {
		   a[i]=sc.nextLong();
		   b[i]=sc.nextLong();
	   }
	   long ans=0;
	   for(int i=0;i<=30;i++) {
		   long sum=0;
		   if(((k>>i)&1)==1) {
			   LOOP:for(int s=0;s<n;s++) {
				   if(((a[s]>>i)&1)==0) {
				   for(int j=i+1;j<=30;j++) {
					   if(((k>>j)&1)==0) {
						   if(((a[s]>>j)&1)==0) {
						   }else {
							  continue LOOP;
						   }
					   }else {
					   }
				   }
				   sum+=b[s];
				   }
			   }
		   }else {
			   continue;
		   }
		   
		   ans=Math.max(ans, sum);
	   }
	   
	   long sum1=0;
	   loop:for(int j=0;j<n;j++) {
		   for(int i=0;i<=30;i++) {
			   if(((k>>i)&1)==1) {
			   }else {
				   if(((a[j]>>i)&1)==1) {
					   continue loop;
				   }
			   }
		   }
		   sum1+=b[j];
	   }
	   ans=Math.max(ans, sum1);
	   
	   System.out.println(ans);
   }
}


Measured memory_bytes: 93980
let a = stdin.ReadLine() |> int
let b = stdin.ReadLine() |> int
let c = stdin.ReadLine() |> int
let x = stdin.ReadLine() |> int
let divCnt = x / 50

[for i in [0..a] do
    for j in [0..b] do
        for k in [0..c] do
            yield i * 500 + j * 100 + k * 50]
            |> List.sumBy (fun t -> if t = x then 1 else 0)
            |> printfn "%d"


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

int h[102];

int watering(int l, int r){
    if(l == r){
        return 0;
    }

    int indexof0 = -1;
    for(int i=l;i<r;i++){
        if(h[i] == 0){
            indexof0 = i;
            break;
        }
    }
    if(indexof0 == -1){
        int min_h = *min_element(h+l, h+r);
        for(int i=l;i<r;i++){
            h[i] -= min_h;
        }
        // for(int i=l;i<r;i++) cout << h[i] << " ";
        // cout << endl;
        return watering(l, r) + min_h;
    }
    else{
        return watering(l, indexof0) + watering(indexof0+1, r);
    }
}

int main(){
    int N;

    cin >> N;
    for(int i=0;i<N;i++) cin >> h[i];
    cout << watering(0, N) << endl;
    return 0;
}

Measured memory_bytes: 256
var s:String;
i:Longint;
begin
readln(s);
for i:=1 to length(s)do begin
if((i mod 2=1)and(s[i]='L'))or((i mod 2=0)and(s[i]='R'))then begin
writeln('No');
exit();
end;
end;
writeln('Yes');
end.

Measured memory_bytes: 128
def nC2(n)
  n * (n - 1) / 2
end

n = gets.to_i
as = gets.split.map(&:to_i)

cs = as.each_with_object(Hash.new(0)) do |a, h|
  h[a] += 1
end

sum = cs.values.inject(0) do |r, v|
  r + nC2(v)
end

as.each do |a|
  c = cs[a]
  diff = (c - 1) # nC2(c) - nC2(c - 1)

  puts sum - diff
end


Measured memory_bytes: 29700
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define N 100005
#define inf 1e18
#define mem(a,b) memset(a,b,sizeof(a))

using namespace std;

ll binomialCoeff(ll n,ll k)
{
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}


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

void Sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}

//******************************************************    CHECK CONSTRAINTS   ***************************************************************//

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
    ll mod = 1e9 + 7;
    int h,w;
    cin >> h >> w;
    ll dp[h+1][w+1];
    mem(dp,0);
    int arr[h+1][w+1];
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            char ch;
            cin >> ch;
            if(ch=='.')
                arr[i][j] = 1;
            else
                arr[i][j] = 2;
        }
    }
    dp[1][1] = 1;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(i==1&&j==1)
                continue;
            if(arr[i][j]==2)
                dp[i][j]=0;
            else
            {
                dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
    }
    cout << dp[h][w] ;
}


Measured memory_bytes: 12032
N = int(input())
res = N

for i in range(N+1):
    cc = 0
    t = i
    while t > 0:
        cc += int(t % 6)
        t //= 6
    t = N - i
    while t > 0:
        cc += int(t % 9)
        t //= 9
    res = min(res, cc)

print(int(res))


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

#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (int)(v.size())
#define prin(a) cout << #a << " = " << a << endl
#define all(v) (v).begin(),(v).end()

typedef long long ll;

const int N = 2e5+10;
ll a[N], b[N];

int main(){
	ll n; cin >> n;
	
	fr(i,n){
		scanf("%lld %lld", a+i, b+i);
	}
	
	sort(a,a+n), sort(b,b+n);
	
	ll minv, maxv;
	if(n%2==1){
		minv = a[n/2], maxv = b[n/2];
		cout << maxv-minv+1 << endl;
	} else{
		ll minv1 = a[n/2-1], maxv1 = b[n/2-1];
		ll minv2 = a[n/2], maxv2 = b[n/2];
		minv = minv1+minv2;
		maxv = maxv1+maxv2;
		cout << maxv-minv+1 << endl;
	}
}

Measured memory_bytes: 6892
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long ;
int main()
{
    ll ans=0;
    string s;
    cin>>s;
    for(unsigned int i=0;i<s.size();i++){
        int a=s[i]-'0';
        ans+=a;
        ans%=9;
    }
    if(ans==0) cout<<"Yes";
    else cout<<"No";
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ii pair<int,int>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

const int maxn = 1e5+10;
const int mod = 1e9+7;

string s;
int n;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>s;
	for(int i=0;i<(int)s.size();++i){
		s[i] = (((s[i]-'A')+n)%26)+'A';
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<float.h>
using namespace std;


int main() {
    int a, b,c,d;
    cin >> a>>b>>c>>d;
    if (a + b < c + d)cout << "Right" << endl;
    else if (a + b > c + d)cout << "Left" << endl;
    else cout << "Balanced" << endl;
    
  
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	static int T, S, E, W, N, U;
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		int[] in = new int[6];
		for(int i = 0; i < 6; i++){
			in[i] = scan.nextInt();
		}
		T = in[0];
		S = in[1];
		E = in[2];
		W = in[3];
		N = in[4];
		U = in[5];

		int q = scan.nextInt();
		for(int i = 0; i < q; i++){
			int n = scan.nextInt();
			int m = scan.nextInt();
			boolean flg = false;
			while(true){
				if(m == N){
					MoveSouth();
					MoveSouth();
				} else if(m == U){
					MoveNorth();
				} else if(m == T){
					MoveSouth();
				} else if(m == E){
					MoveWest();
				} else if(m == W){
					MoveEast();
				}
				if(m == S){
					if(n == T){
						flg = true;
						break;
					} else {
						MoveEast();
					}
				}
				
			}
			System.out.println(E);
		}

	}

	public static void MoveSouth(){
		int a = T;
		T = N;
		N = U;
		U = S;
		S = a;
	}
	public static void MoveEast(){
		int a = T;
		T = W;
		W = U;
		U = E;
		E = a;
	}
	public static void MoveNorth(){
		int a = T;
		T = S;
		S = U;
		U = N;
		N = a;
	}
	public static void MoveWest(){
		int a = T;
		T = E;
		E = U;
		U = W;
		W = a;
	}
}

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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
using namespace std;

int main(){
	int n;	cin >> n;
	int cnt[4] = {0};
	string s[n];
	for( int i = 0; i < n; i++ ){
		cin >> s[i];
		if( s[i] == "AC" )			cnt[0]++;
		else if( s[i] == "WA" )		cnt[1]++;
		else if( s[i] == "TLE" )	cnt[2]++;
		else if( s[i] == "RE" )		cnt[3]++;
	}

	cout << "AC x " << cnt[0] << endl;
	cout << "WA x " << cnt[1] << endl;
	cout << "TLE x " << cnt[2] << endl;
	cout << "RE x " << cnt[3] << endl;

	return 0;
}


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

void s(int x){
	printf("%d\n", x);
	exit(0);
}

int main(){
	int x, y;
	scanf("%d%d", &x, &y);
	if (y == 0){
		if (x > 0)s(1 + x);
		else s(-x);
	}
	if (x >= 0 && y >= 0){
		if (x > y)s(2 + x - y);
		else s(y - x);
	}
	else if (x >= 0)s(abs(x + y) + 1);
	else if (y >= 0)s(abs(y + x) + 1);
	else {
		if (x > y)s(2 + x - y);
		else s(y - x);
	}
}


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

int main() {
  int N, l, r, sum = 0;
  cin >> N;

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<tuple>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef unsigned long long int ull;
const int INF=1e9;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=2e5;

int main(){
    int n,m;cin>>n>>m;
    vector<vector<int> > G(n+1,vector<int>(n+1,0));
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        G[a][b]=1;
        G[b][a]=1;
    }
    vector<int> num(n);
    for(int i=0;i<n;i++){
        num[i]=i+1;
    }
    int ans=0;
    do{
        bool flag=true;
        for(int i=1;i<n;i++){
            if(G[num[i-1]][num[i]]==0){
                flag=false;
                break;
            }
        }
        if(flag) ans++;
    }while(next_permutation(num.begin()+1,num.end()));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(void){
	string s;
	int i;
	bool flg;
	cin>>s;
	flg=false;
	if(s[5]-'0'==0&&s[6]-'0'>=5||s[5]-'0'==1)	flg=true;
	cout<<((flg)?"TBD":"Heisei")<<endl;
	return 0;
}


Measured memory_bytes: 256
def mcxiToDigit(s):
    s="1"+s
    num=0
    dic={"m":1000,"c":100,"x":10,"i":1}
    for c in dic:
        if c in s:
            if "2"<=s[s.index(c)-1]<="9":
                num+=int(s[s.index(c)-1])*dic[c]
            else:
                num+=dic[c]
    return num

for i in range(input()):
    L=raw_input().split()
    sm=mcxiToDigit(L[0])+mcxiToDigit(L[1])
    T=((1000,"m"),(100,"c"),(10,"x"),(1,"i"))
    s=""
    for d,c in T:
        val=sm/d
        if val>1:
            s+=str(val)+c
        elif val==1:
            s+=c
        sm%=d
    print s

Measured memory_bytes: 4296
k,n=map(int,input().split())
a=list(map(int,input().split()))
a=sorted(a)
maxi=0
for i in range(n-1):
    tmp=a[i+1]-a[i]
    maxi=max(tmp,maxi)

if maxi<=a[0]+(k-a[-1]):
    print(max(a)-min(a))
else:
    print(k-maxi)

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

for i in range(N):
    # ?????????????±?
    v = A[i]
    # ????????????????????????????????¨???
    j = i - 1
    # ?????????????????¨????????????????????§????????????
    # ????±? > ??????????±????????????????????±???????????????????1?????????????????? j ?????????????????????
    # ????±? < ??????????±??????????break ??????????????´??????
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    print(' '.join(map(str, A)))

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

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int n,m;
int pass[30][30];

int dijk(int s,int g){
    int d[30];
    bool used[30];
    rep(i,30)d[i]=999999999;
    rep(i,30)used[i]=false;
    d[s]=0;
    
    while(1){
        int v=-1;
        rep(u,n){
            if( !used[u] && (v==-1||d[u]<d[v]) )v=u;
        }
        if(v==-1)break;
        
        used[v]=true;
        
        rep(u,n){
            d[u]=min(d[u],d[v]+pass[v][u]);
        }
        
    }
    return d[g];
}



int main(){
    rep(i,30)rep(j,30)pass[i][j]=999999999;
    cin>>n>>m;
    char ch;
    rep(i,m){
        int a,b,c,d;
        cin>>a>>ch>>b>>ch>>c>>ch>>d;
        a--,b--;
        pass[a][b] = c;
        pass[b][a] = d;
    }
    int s,g,y1,y2;
    cin>>s>>ch>>g>>ch>>y1>>ch>>y2;
    s--,g--;

    
    int x,y;
    x=dijk(s,g);
    y=dijk(g,s);
    
    cout<<y1-y2-x-y<<endl;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s, t;
  cin >> s >> t;

  int ans = 0;
  REP(i, s.size()){
    if(s[i] != t[i]) ans++;
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3880
import java.util.Scanner;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int N = sc.nextInt();
        int maxPrice = 0;
        int []prices= new int[N];//dont actually need array 
        int total = 0;
        for(int i = 0; i < N; ++i) {
            prices[i] = sc.nextInt();
            if(prices[i]>maxPrice) {
                maxPrice = prices[i];
            }
            total +=prices[i];
        }
        total = total - maxPrice/2;
        System.out.println(total);
    }

}


Measured memory_bytes: 22868
n,W=map(int,input().split())
w=[0]*n
v=[0]*n
for i in range(n):
  w[i],v[i]=map(int,input().split())
ws=w[0]
V=[[] for i in range(4)]
for i in range(n):
  V[w[i]-ws].append(v[i])
V[0].sort(reverse=True)
V[1].sort(reverse=True)
V[2].sort(reverse=True)
V[3].sort(reverse=True)
VV=[[0] for i in range(4)]
for i in range(4):
  for j in range(len(V[i])):
    VV[i].append(VV[i][-1]+V[i][j])
ans=0
for i in range(len(V[0])+1):
  for j in range(len(V[1])+1):
    for k in range(len(V[2])+1):
      for l in range(len(V[3])+1):
        if i*ws+j*(ws+1)+k*(ws+2)+l*(ws+3)>W:
          break
        if VV[0][i]+VV[1][j]+VV[2][k]+VV[3][l]>ans:
          ans=VV[0][i]+VV[1][j]+VV[2][k]+VV[3][l]
print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ld eps = 1e-9;
const db PI = atan(1) * 4;

template<typename T, typename S>inline bool upmin(T&a, const S&b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S>inline bool upmax(T&a, const S&b) { return a < b ? a = b, 1 : 0; }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
namespace SOLVE {
	vector<vector<int>> memo;
	string a, b;

	int lcs(int alength, int blength) {
		if (memo[alength][blength] != -1) {
			return memo[alength][blength];
		}

		if (alength == 0 || blength == 0) {
			memo[alength][blength] = 0;
			return 0;
		}
		
		int ans;
		if (a[alength - 1] == b[blength - 1]) {
			ans = lcs(alength - 1, blength - 1) + 1;
		}
		else {
			int ans1 = lcs(alength - 1, blength);
			int ans2 = lcs(alength, blength - 1);
			ans = max(ans1, ans2);
		}
		memo[alength][blength] = ans;
		// cout << a << ' ' << b << ' ' << ans << endl;
		return ans;
	}
	void main() {
		cin >> a >> b;
		int na = a.length(), nb = b.length();
		memo.resize(na + 5, vector<int>(nb + 5, -1));
		int iptr = na, jptr = nb, current, top, left;
		stack<char> ans;

		lcs(na, nb);
		while (iptr != 0 && jptr != 0) {
			// cout << iptr << ' ' << jptr << endl;
			current = memo[iptr][jptr];
			top = memo[iptr - 1][jptr];
			left = memo[iptr][jptr - 1];
			
			if (current == left) {
				jptr--;
			}
			else if (current == top) {
				iptr--;
			}
			else {
				ans.push(a[iptr - 1]);
				iptr--;
				jptr--;
			}
		}

		while (sz(ans)) {
			cout << ans.top();
			ans.pop();
		}
	}
}

signed main() {

	int t;
	//    in(t);
	t = 1;
	while (t--) {
		SOLVE::main();

	}

	return 0;
}


Measured memory_bytes: 36096
MOD = 998244353

n, k = $stdin.readline.chomp.split.map(&:to_i)
rng = Array.new(k) { $stdin.readline.chomp.split.map(&:to_i) }

dp = Array.new(n, 0)
sdp = Array.new(n + 1, 0)

n.times do |i|
  if i == 0
    dp[i] = 1
  else
    k.times do |j|
      lj, rj = rng[j]
      l = [0, i - rj].max
      r = [0, i - lj + 1].max
      dp[i] = (dp[i] + sdp[r] - sdp[l]) % MOD
    end
  end
  sdp[i + 1] = (sdp[i] + dp[i]) % MOD
end
puts dp[n - 1]

Measured memory_bytes: 17576
'use strict'

function main(input) {
    input = input.split('\n')
    input[0] = input[0].split(' ').map(v => ~~v)
    input[1] = ~~input[1]
    input[0] = input[0].sort((a, b) => a - b)

    let n = input[0].length - 1
    input[0][n] = input[0][n] * Math.pow(2,input[1])

    let ans = input[0].reduce((a, b) => a + b)

    console.log(ans)
}

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

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if (s.size() & 1) cout << "No\n";
    else {
        bool ok = 1;
        string hi = "hi";
        for (int i = 0; i < s.size(); i++) {
            if (s[i] != hi[i&1]) ok = 0;
        }
        if (ok) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}

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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel" <<endl;
  else cout << "consonant" << endl;
}


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

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

using namespace std;

int main(){
	int na,nb,m; scanf("%d%d%d",&na,&nb,&m);
	vector<int> a(na),b(nb);
	rep(i,na) scanf("%d",&a[i]);
	rep(i,nb) scanf("%d",&b[i]);

	int ans=*min_element(a.begin(),a.end())+*min_element(b.begin(),b.end());
	rep(i,m){
		int x,y,c; scanf("%d%d%d",&x,&y,&c); x--; y--;
		ans=min(ans,a[x]+b[y]-c);
	}
	printf("%d\n",ans);

	return 0;
}


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

using namespace std;

int main() {

	long n;
	cin >> n;

	vector<long> t(n + 1);

	for (long i = 1; i <= n; i++) {
		cin >> t[i];
	}
	long total;
	total = accumulate(t.begin(), t.end(), 0);


	long m;
	long p, x;
	cin >> m;
	for (long i = 1; i <= m; i++) {
		cin >> p >> x;
		cout << total - t[p] + x << endl;;
	}

	return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
li = [[] for i in range(n)]
ind = 0
i = 0
while True:
    if i >= n:
        break
    if s[i] == "A":
        li[ind].append("A")
        i += 1
        continue
    if i+1 >= n:
        break
    elif s[i] == "B" and s[i+1] == "C":
        li[ind].append("D")
        i += 2
    else:
        i += 1
        ind += 1

ans = 0
for arr in li:
    cnt = 0
    tmp = arr[::-1]
    for j in tmp:
        if j == "D":
            cnt += 1
        else:
            ans += cnt
print(ans)

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

int main() {
	string word1, word2;
    string result = "No";
	cin >> word1;
    cin >> word2;
    
	sort(word1.begin(), word1.end());
    sort(word2.begin(), word2.end(),  [](char a, char b) { return (a > b); });

    if(word1 < word2){
      result = "Yes";  
    }else{
      result ="No";
    }
  cout << result <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll read()
{
    char ch=getchar();
    ll x=0,f=1;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main()
{
    string s;
    cin>>s;
    string str="hi";
    if(s.size()%2==1)
        printf("No\n");
    else
    {
        int j=0;
        for(int i=0;i<s.size();i++)
        {
            if(s[i]!=str[j])
            {
                printf("No\n");
                return 0;
            }
            j++;
            j%=2;
        }
        printf("Yes\n");
    }

    return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<queue>
using namespace std;

const int CN = 5e5+5;

class fs{
  public: int to,nxt; void init(int t,int n) {to=t; nxt=n;}
}E[CN * 10];
int hd[CN],ecnt = 0;
void add(int x,int y) {E[++ecnt].init(y, hd[x]); hd[x] = ecnt;}

char ch[CN]; int n,ind[CN];

int dep[CN]; queue<int> Q;
void tpsort(){
	for(int i=1;i<=n;i++)
	    if(!ind[i]) {dep[i] = 0; Q.push(i);}
	while(!Q.empty()){
		int u = Q.front(); Q.pop();
		for(int k = hd[u]; k; k = E[k].nxt){
			int v = E[k].to;
			if(!(--ind[v])){
				dep[v] = dep[u] + 1; Q.push(v);
			}
		}
	}
}

int main()
{
	cin>>ch; n = strlen(ch);
	
	for(int i=0;i<n;i++){
		int u = i + 1,v = i + 2;
		if(ch[i] == '<') add(u, v),ind[v]++;
		else add(v, u),ind[u]++;
	}
	n += 1;
	
	tpsort(); long long si = 0;
	for(int i=1;i<=n;i++) si += 1ll * dep[i];
	printf("%lld",si);
}

Measured memory_bytes: 13184
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<algorithm>

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

using namespace std;

const int CAPA_INF=1<<29;
const int COST_INF=1<<29;

template<class T,class U>
struct Edge{
	int v,rev;
	T capa;
	U cost;
	T flow;
};

template<class T,class U>
struct AdjList:public vector< vector< Edge<T,U> > >{
	AdjList(int n):vector< vector< Edge<T,U> > >(n){}
};

template<class T,class U>
void add_edge(AdjList<T,U> &adj,int u,int v,T capa,U cost){
	adj[u].push_back((Edge<T,U>){v,adj[v].size()  ,capa, cost});
	adj[v].push_back((Edge<T,U>){u,adj[u].size()-1,   0,-cost});
}

template<class T,class U>
pair<T,U> augment(AdjList<T,U> &adj,int s,int t,vector<U> &pot,bool first){
	int n=adj.size();
	static int pre[6006];
	static U d[6006];
	rep(u,n) d[u]=COST_INF; d[s]=0;

	if(first){
		rep(u,n) rep(i,adj[u].size()) {
			Edge<T,U> &e=adj[u][i];
			U cost2=d[u]+e.cost;
			if(e.capa-e.flow>0 && cost2<d[e.v]){
				d[e.v]=cost2;
				pre[e.v]=e.rev;
			}
		}
	}
	else{
		bool ok=false;
		static bool vis[6006];
		rep(u,n) vis[u]=false;
		rep(_,n){
			int u=-1;
			rep(v,n) if(!vis[v] && (u==-1 || d[v]<d[u])) u=v;
			vis[u]=true;

			if(u==t) ok=true;

			rep(i,adj[u].size()){
				Edge<T,U> &e=adj[u][i];
				U cost2=d[u]+e.cost+pot[u]-pot[e.v];
				if(e.capa-e.flow>0 && cost2<d[e.v]){
					d[e.v]=cost2;
					pre[e.v]=e.rev;
				}
			}
		}

		if(!ok) return make_pair(0,0);
	}

	T water=CAPA_INF;
	for(int v=t;v!=s;){
		Edge<T,U> &e1=adj[v][pre[v]];
		Edge<T,U> &e2=adj[e1.v][e1.rev];
		water=min(water,e2.capa-e2.flow);
		v=e1.v;
	}

	U cost=0;
	for(int v=t;v!=s;){
		Edge<T,U> &e1=adj[v][pre[v]];
		Edge<T,U> &e2=adj[e1.v][e1.rev];
		e1.flow-=water;
		e2.flow+=water;
		cost+=water*e2.cost;
		v=e1.v;
	}

	rep(u,n) pot[u]+=d[u];

	return make_pair(water,cost);
}

template<class T,class U>
pair<T,U> primal_dual(AdjList<T,U> &adj,int s,int t){
	T ans1=0;
	U ans2=0;
	vector<U> pot(adj.size());
	rep(i,2){
		pair<T,U> tmp=augment(adj,s,t,pot,i==0);
		ans1+=tmp.first;
		ans2+=tmp.second;
	}
	return make_pair(ans1,ans2);
}

struct mogu{
	int x,t,p;
	bool operator<(const mogu &mg)const{ return t<mg.t; }
};

int main(){
	int n,v,xl,xr; scanf("%d%d%d%d",&n,&v,&xl,&xr);
	mogu mg[3002];
	rep(i,n) scanf("%d%d%d",&mg[i].x,&mg[i].t,&mg[i].p);
	mg[n++]=(mogu){xl,0,0};
	mg[n++]=(mogu){xr,0,0};

	sort(mg,mg+n);

	AdjList<int,int> adj(2*n+2);

	int s=0,t=2*n+1;
	add_edge(adj,s,1,1,0);
	add_edge(adj,s,3,1,0);
	rep(i,n){
		add_edge(adj,2*i+2,t,1,0);

		add_edge(adj,2*i+1,2*i+2,1,-mg[i].p);

		rep(j,n) if(i!=j && abs(mg[i].x-mg[j].x)<=v*(mg[j].t-mg[i].t)) {
			add_edge(adj,2*i+2,2*j+1,1,0);
		}
	}

	printf("%d\n",-primal_dual(adj,s,t).second);

	return 0;
}

Measured memory_bytes: 209000
n=int(input())
l=0
center=(n-1)//2
r=n-1
print(center,flush=True)
ct=input()
if ct=='Vacant':
  exit()
print(l,flush=True)
lt=input()
if lt=='Vacant':
  exit()
print(r,flush=True)
rt=input()
if rt=='Vacant':
  exit()
flag=False
if (center-l)%2==0:
  if lt!=ct:
    r=center
    rt=ct
    flag=True
else:
  if lt==ct:
    r=center
    rt=ct
    flag=True
if flag==False:
  if (r-center)%2==0:
    if rt!=ct:
      l=center
      lt=ct
  else:
    if rt==ct:
      l=center
      lt=ct
while 1:
  center=(l+r)//2
  print(center,flush=True)
  ct=input()
  if ct=='Vacant':
    exit()
  flag=False
  if (center-l)%2==0:
    if lt!=ct:
      r=center
      rt=ct
      flag=True
  else:
    if lt==ct:
      r=center
      rt=ct
      flag=True
  if flag==False:
    if (r-center)%2==0:
      if rt!=ct:
        l=center
        lt=ct
    else:
      if rt==ct:
        l=center
        lt=ct

Measured memory_bytes: 3780