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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  if (N*A < B) {
    cout << N*A << endl;
  }
  else if (N*A == B) {
    cout << B << endl;
  }
  else {
    cout << B << endl;
  }
 
}

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

using namespace std;

vector<vector<int>> areas = {{-1, -1}, {-1, 0}, {-1, 1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}};

int countMines(vector<string> G, int i, int j) {
    int n = 0;
    for (auto& area : areas) {
        int ii = i + area[0], jj = j + area[1];
        if (ii < 0 || jj < 0) continue;
        else if (ii >= G.size() || jj >= G[0].size()) continue;
        if (G[ii][jj] == '#') n++;
    }
    return n;
}

int main(){
    int H, W;
    cin >> H >> W;
    string s;
    vector<string> G;
    for (int i = 0; i < H; ++i) {
        cin >> s;
        G.push_back(s);
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (G[i][j] == '.') cout << countMines(G, i, j);
            else cout << '#';
        }
        cout << '\n';
    }

    cout << endl;
    return 0;
}

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

int main() {
  int n, r;
  cin >> n >> r;
  if (n < 10) cout << r + 100 * (10 -n) << endl;
  else cout << r << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()
#define maxn 1000001
#define gc getchar()
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair 
#define ll long long
#define ull unsigned ll 
#define pb push_back
#define db double
 int mod=-99999;
int read()
{
	int x=0,f=1;char ch=gc;
	while(!isdigit(ch)){ch=gc;if(ch=='-')f=-1;}
	while(isdigit(ch))x=x*10+ch-48,ch=gc;
	return x*f;
}
void print(int x)
{
	if(x>9)print(x/10);
	putchar(x%10+48);
}
int n,m;
int main()
{  
   scanf("%d %d",&n,&m);
   printf("%d\n",max(n+m,max(n-m,n*m)));
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {

		final long MOD = 1000000007;

		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int M = sc.nextInt();

		long answer = 0;

		if (Math.abs(N - M) > 1) {
			answer = 0;
		} else if (N == M) {
			long permutations = 1;
			for (int i = 0; i < N; i++) {
				permutations = (permutations * (i + 1)) % MOD;
			}
			answer = ((permutations * permutations) * 2) % MOD;

		} else {
			long dogPerm = 1;
			long monkeyPerm = 1;
			for (int i = 0; i < N; i++) {
				dogPerm = (dogPerm * (i + 1)) % MOD;
			}
			for (int i = 0; i < M; i++) {
				monkeyPerm = (monkeyPerm * (i + 1)) % MOD;
			}
			answer = (dogPerm * monkeyPerm) % MOD;
		}
		System.out.println(answer);
		sc.close();
	}
}

Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = ReadLongs();
            var h = ReadLongs();

            Array.Sort(h);
            Array.Reverse(h);
            if (nk[0] < nk[1])
            {
                WriteLine(0);
                return;
            }
            else
            {
                for (int i = 0; i < nk[1]; i++)
                {
                    h[i] = 0;
                }
            }
            WriteLine(h.Sum());
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 34128
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MOD = 1000000007;

vector<string> node;
vector<vector<int> > edges;

long long solve(int curr)
{

    long long ans;
    if(node[curr][0] == 'E'){
        ans = 1;
        for(int next : edges[curr]){
            ans *= solve(next);
            ans %= MOD;
        }
    }
    else if(node[curr][0] == 'A'){
        ans = 0;
        for(int next : edges[curr]){
            ans += solve(next);
            ans %= MOD;
        }
    }
    else{
        ans = 1;
        for(int next : edges[curr]){
            ans *= solve(next) + 1;
            ans %= MOD;
        }
        ans += MOD - 1;
        ans %= MOD;
    }
    
    if(node[curr].size() == 2){
        ++ ans;
        ans %= MOD;
    }

    return ans;
}

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

    node.resize(n);
    for(int i=0; i<n; ++i)
        cin >> node[i];

    edges.assign(n, vector<int>());
    for(int i=0; i<n-1; ++i){
        int s, t;
        cin >> s >> t;
        -- s;
        -- t;
        edges[s].push_back(t);
    }

    cout << solve(0) << endl;

    return 0;
}

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


int n, k, l;
const int MAX_N = 2 * 1e5;

struct UF {
  std::vector<int> par, rank;
  UF(int n) : par(n), rank(n, 0) {
    for (size_t i = 0; i < n; ++i) par[i] = i;
  }

  int root(int x) {
    return (par[x] == x) ? x : par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    x = root(x); y = root(y);

    if (x == y) return;

    if (rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

int main() {
  cin >> n >> k >> l;
  UF u1(MAX_N), u2(MAX_N);
  for (int i = 0; i < k; ++i) {
    int p, q;
    cin >> p >> q;
    p--; q--;
    u1.unite(p, q);
  }
  for (int i = 0; i < l; ++i) {
    int p, q;
    cin >> p >> q;
    p--; q--;
    u2.unite(p, q);
  }
  map<pair<int, int>, int> chie;
  for (int i = 0; i < n; ++i) {
    chie[make_pair(u1.root(i), u2.root(i))]++;
  }

  for (int i = 0; i < n; ++i) {
    cout << chie[make_pair(u1.root(i), u2.root(i))] << (i == n - 1 ? '\n' : ' ');
  }
}


Measured memory_bytes: 15232
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		new Main().exec();
	}

	void exec() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double total = 0d;
		for (int i = 0; i < n; i++) {
			double d = sc.nextDouble();
			String unit = sc.next();
			switch (unit) {
				case "JPY":
					total += d;
					break;
				case "BTC":
					total += d * 380000d;
					break;
				default:
					break;
			}
		}
		System.out.println(total);
		sc.close();
	}

}


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

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

   int asi = x*4 ;
   if(asi==y)
   {
       cout << "Yes" << endl ;
       return 0;
   }
   for (int i = 0; i < x; i++)
   {
       asi -= 2 ;
       if(asi==y)
       {
           cout << "Yes" << endl;
           return 0;
       }
   }
   
   cout << "No" << endl ;
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int n ,l;
  cin >> n >> l;
  int sum=n*l;
  int min_val=300;
  for(int i = 0; i< n;i++){
    sum += i;
    if(abs(min_val) > abs(l+i)){
      min_val = l+i;
    }
  }

  std::cout << sum-min_val << std::endl;
  return 0;
}

Measured memory_bytes: 256
// AOJ ALDS1_7_B Binary Trees
// 2018.5.1 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

typedef struct { int parent; int sibling; int depth, height; int k; int c[2]; } TREE;
TREE tree[30];

void calc_depth(int node, int d)
{
	int i;
	tree[node].depth = d;
	for (i = 0; i < tree[node].k; i++) calc_depth(tree[node].c[i], d+1);
}

int calc_height(int node)
{
	int i, h, t;

	h = 0;
	for (i = 0; i < tree[node].k; i++) {
		if ((t = calc_height(tree[node].c[i])+1) > h) h = t;
	}
	tree[node].height = h;
	return h;
}

int main()
{
	int n, i, id;
	int root, left, right;

	n = in();
	for (i = 0; i < n; i++) {
		id = in(), left = in(), right = in();
		if (left < 0 && right < 0) tree[id].k = 0;
		else if (left >= 0 && right >= 0) {
			tree[id].k = 2;
			tree[id].c[0] = left, tree[id].c[1] = right;
			tree[left].parent = id+1;
			tree[left].sibling = right+1;
			tree[right].parent = id+1;
			tree[right].sibling = left+1;
		} else {
			if (left < 0) left = right;
			tree[id].k = 1;
			tree[id].c[0] = left;
			tree[left].parent = id+1;

		}
	}
	for (root = 0; root < n; root++) {
		if (tree[root].parent == 0) break;
	}
	calc_depth(root, 0);
	calc_height(root);

	for (i = 0; i < n; i++) {
		printf("node %d:", i);
		printf(" parent = %d,", tree[i].parent-1);
		printf(" sibling = %d,", tree[i].sibling-1);
		printf(" degree = %d,", tree[i].k);
		printf(" depth = %d,", tree[i].depth);
		printf(" height = %d,", tree[i].height);
		if (i == root)          printf(" root");
		else if (tree[i].k == 0) printf(" leaf");
		else                    printf(" internal node");
		putchar('\n');
	}
	return 0;
}


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

int main(){
    string a, b, c;
    cin >> a >> b >> c;

    char who = 'a';
    int i, j, k = 0;
    while(true){
        if(who == 'a'){
            if(a[i] == '\0'){
                who = 'A';
                break;
            }
            who = a[i];
            i++;
        }
        else if(who == 'b'){
            if(b[j] == '\0'){
                who = 'B';
                break;
            }
            who = b[j];
            j++;
        }
        else if(who == 'c'){
            if(c[k] == '\0'){
                who = 'C';
                break;
            }
            who = c[k];
            k++;
        }
    }
    cout << who << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int i, c = 0, n;
    char array[10], array_n[11];
    for(i = 0; i < 11; i++){
        scanf("%c", &array[i]);
        if(array[i] == '\n'){
            n = i;
            break;
        }
    }
    for(i = 0; i < n + 1; i++){
        scanf("%c", &array_n[i]);
    }
    for(i = 0; i < n; i++){
        if(array[i] == array_n[i]){
            c++;
        }
    }
    if(c == n){
        printf("Yes");
    }
    else{
        printf("No");
    }

    return 0;
}


Measured memory_bytes: 1668
///***Bismillahir Rahmanir Rahim***///

///*********************************///
///******Ashraful Haque Toni********///
///********Dept. of CSE,JnU*********///
///email:ashrafulhaquetoni@gmail.com///
///*******contact:01640690531*******///
///*********************************///


#include<bits/stdc++.h>

using namespace std;

#define         ash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define         pb push_back
#define         mp make_pair
#define         sc(n) scanf("%d",&n);
#define         scl(n) scanf("%I64d",&n);
#define         sc2(m,n) scanf("%d%d",&m,&n);
#define         sc2l(m,n) scanf("%I64d%I64d",&m,&n);
#define         pf printf
#define         Big(x,y) max(x,y);
#define         Small(x,y) min(x,y);
#define         input(array,size) for(int i=0;i<size;i++)cin>>array[i];
#define         newline pf("\n");
#define         f(s,l,in) for(ll i=s;i<l;i+=in)
#define         Max INT_MAX
#define         Min INT_MIN
#define         pi acos(-1.0)
#define         Memset(a,val) memset(a,val,sizeof(a));

const int mod =1e9+7;
const int N =5e6+5;
typedef long long ll;



int main()
{

    ash;

    int n;
    cin>>n;
    vector<pair<ll,ll> >v;

    while(n--)
    {
        ll a,b;
        cin>>a>>b;
        v.pb({b,a});
    }

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

    ll sum=0;

    for(int i=0;i<v.size();i++)
    {
        sum+=v[i].second;
        if(sum>v[i].first){
            cout<<"No\n";
            exit(0);
        }
    }

    cout<<"Yes\n";

    return 0;
}




Measured memory_bytes: 6384
# import sys
# sys.setrecursionlimit(20000)


N = int(input())
COR = [tuple((map(int, input().split()))) for _ in range(N)]


class Group:
    
    def __init__(self):
        self.n = 0
        self.x = 0
        self.y = 0
        self.xy = {}
        
    def new_cor_n(self):
        return self.x * self.y - self.n
        

def grouping(group, x, xcor, ycor):
    x_list = []
    group.x += 1
    for y in xcor[x][0]:
        if (x, y) not in group.xy:
            group.n += 1
            group.xy[(x, y)] = None
        if ycor[y][1]:
            continue
        ycor[y][1] = True
        group.y += 1
        for x_ in ycor[y][0]:
            if (x_, y) not in group.xy:
                group.n += 1
                group.xy[(x_, y)] = None
            if xcor[x_][1]:
                continue
            xcor[x_][1] = True
            x_list.append(x_)
    return x_list

if N <= 2:
    print(0)
else:
    xcor, ycor = {}, {}
    for xi, yi in COR:
        if xi in xcor:
            xcor[xi][0].append(yi)
        else:
            xcor[xi] = [[yi], False]
        if yi in ycor:
            ycor[yi][0].append(xi)
        else:
            ycor[yi] = [[xi], False]
    group_list = []
    for i, v in xcor.items():
        if v[1]:
            continue
        group = Group()
        group_list.append(group)
        xcor[i][1] = True
        x_list = [i]
        while True:
            new_x_list = []
            for x in x_list:
                new_x_list += grouping(group, x, xcor, ycor)
            if new_x_list == []:
                break
            x_list = new_x_list
    s = 0
    for group in group_list:
        s += group.new_cor_n()
    print(s)


Measured memory_bytes: 59000
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    long N, K;
    long[] A, B;
    void Solve() {
        //input
        N = io.Long;
        K = io.Long;
        A = new long[N];
        B = new long[N];
        for (var i = 0; i < N;++i){
            A[i] = io.Long;
            B[i] = io.Long;
        }
        //cal
        var ans = 0L;
        //Kのbitwise_orを変更しない範囲での最大値を求める
        //i番目について調べる
        for (var i = 0; i < N;++i){
            var f = true;
            for (int j = 0; j <= 30;++j){
                //Kの該当するビットが1じゃないのにA[i]の該当するビットが1
                //->bitwise_orを変更してしまうので加えない
                if(((K>>j)&1)==0&&((A[i]>>j)&1)==1){
                    f = false;
                    break;
                }
            }
            if (f)
                ans += B[i];
        }
        //Kのbitwise_orを小さくしたほうが総和が大きくなるかもしれない
        //最終的な形から考える
        //K=5=(101)のとき,(100),(10?),(0??)が他の最終状態として考えられる(?はどっちでもいい)
        for (var i = 0; i <= 30; ++i) {
            //iビットを0に反転して，以降を1にしたK
            if (((K >> i) & 1) == 1) {
                var converted_K = (K & ~(1 << i)) | ((1 << i) - 1);
                var cur = 0L;
                for (int j = 0; j < N; ++j) {
                    var f = true;
                    for (int k = 0; k < 30; ++k) {
                        if (((converted_K >> k) & 1) == 0 && ((A[j] >> k) & 1) == 1) {
                            f = false;
                            break;
                        }
                    }
                    if (f)
                        cur += B[j];
                }
                //更新
                ans = Math.Max(ans, cur);
            }
        }
        //ret
        Console.WriteLine(ans);

    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}
class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
// const ll INF = 1e18;
const int INF = 1001001001;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  int ans = INF;
  for (int i = 0; i <= N - K; i++) {
    int dist;
    if (0 <= x[i]) {
      dist = x[i + K - 1];
    } else if (x[i + K - 1] <= 0) {
      dist = -x[i];
    } else {
      dist = x[i + K - 1] - x[i] + min(abs(x[i]), abs(x[i + K - 1]));
    }
    dump(x[i], x[i + K - 1], dist);
    ans = min(ans, dist);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; string S;
    cin >> N >> S;
    vector<int> West(300010), East(300010);
    for(int i = 1; i <= N; i++) {
        if(S.at(i-1)=='W') {
            West.at(i) = West.at(i-1) + 1;
            East.at(i) = East.at(i-1);
        }
        else {
            West.at(i) = West.at(i-1);
            East.at(i) = East.at(i-1) + 1;
        }
    }
    
    int ans = N;
    for(int i = 1; i <= N; i++) ans = min(ans, West.at(i-1) + East.at(N) - East.at(i));
    cout << ans << endl;
}


Measured memory_bytes: 3076
N, K = map(int, input().split())

Map = [[[0]*K for i in range(K)] for j in range(2)]
for i in range(N):
  x, y, c = input().split()
  x, y = int(x), int(y)
  if c == 'B':
    c = 0
  else:
    c = 1
  nx, ny = x//K, y//K
  if (nx + ny) % 2:
    c = 1 - c
  x %= K
  y %= K
  Map[c][x][y] += 1

def get_v(c, x, y):
  global Map
  if x < 0 or y < 0:
    return 0
  else:
    return Map[c][x][y]

for c in range(2):
  for x in range(K):
    for y in range(K):
      Map[c][x][y] += get_v(c, x-1, y) + get_v(c, x, y-1) - get_v(c, x-1, y-1)

ans = 0
for x in range(K+1):
  for y in range(K+1):
    b2 = get_v(0, x-1, K-1) + get_v(0, K-1, y-1) - 2*get_v(0, x-1, y-1)
    w1 = get_v(1, x-1, K-1) + get_v(1, K-1, y-1) - 2*get_v(1, x-1, y-1)
    b1 = Map[0][K-1][K-1] - b2
    w2 = Map[1][K-1][K-1] - w1
    ans = max(ans, b1+w1, b2+w2)

print(ans)

Measured memory_bytes: 67544
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	string a,b,c;

	cin>>a>>b>>c;

	cout<<"A"<<b.at(0)<<"C"<<endl;


	return 0;
}

Measured memory_bytes: 256
(let ((n (read))
      (end 2000000000)
      (lst (make-array 0 :element-type 'list
                         :adjustable t
                         :fill-pointer 0))
      s-lst)
  (dotimes (i n)
    (vector-push-extend (list (read) (read)) lst))
  (setf s-lst (sort lst #'(lambda (x y) (> (second x) (second y)))))
  (loop for i across s-lst do
        (if (< (second i) end) (setf end (second i)))
        (decf end (first i)))
  (princ (if (< end 0) "No" "Yes")))


Measured memory_bytes: 65988
n,m,q = gets.split.map(&:to_i)
as = q.times.map{gets.split.map(&:to_i)}

nums = [1]*n
keta = 1
ans = 0
while nums[0] <= m
  tmp = 0
  as.each do |a|
    if nums[a[1]-1] - nums[a[0]-1] == a[2]
      tmp += a[3]
    end
  end
  j = 0
  nums[(-j-1)] += 1
  if nums[(-j-1)] > m
    while nums[(-j-1)] > m && j < n-1
      nums[(-j-1)] = 1
      nums[(-j-2)] += 1
      j += 1
    end
    nums[(-j)..-1] = nums[(-j)..-1].map{nums[(-j-1)]}
  end
  keta += 1

  ans = tmp if tmp > ans
end

puts ans


Measured memory_bytes: 14372
class Dice

  def initialize(dice)
    @top  = dice[0]
    @side   = [ dice[2], dice[1], dice[3], dice[4] ]
    @bottom = dice[5]
  end

  def roll(action)
    b = @bottom
    u = @top
    case action
    when "N"
      @top   = @side[2]
      @bottom  = @side[0]
      @side[2] = b
      @side[0] = u
    when "E"
      @top   = @side[3]
      @bottom  = @side[1]
      @side[3] = b
      @side[1] = u
    when "S"
      @top   = @side[0]
      @bottom  = @side[2]
      @side[0] = b
      @side[2] = u
    when "W"
      @top   = @side[1]
      @bottom  = @side[3]
      @side[1] = b
      @side[3] = u
    end
  end

  def same_dice?(sub)
    i = 0
    while true
      if south == sub.south
        4.times do
          if all_num == sub.all_num
            puts "Yes"
            return
          end
          roll("E")
        end
      end
      if i > 6
        puts "No"
        return
      elsif i == 3
        roll("E")
        roll("N")
      else
        roll("N")
      end
      i += 1
    end
  end

  def top
    @top
  end

  def bottom
    @bottom
  end

  def north
    @side[0]
  end

  def east
    @side[1]
  end

  def south
    @side[2]
  end

  def west
    @side[3]
  end

  def all_num
    [@top, @bottom, @side[2], @side[1], @side[3], @side[4]]
  end
end

d = Dice.new(gets.split.map(&:to_i))
sub = Dice.new(gets.split.map(&:to_i))

d.same_dice?(sub)

Measured memory_bytes: 6128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=0,m,k,s=0;
    cin>>n;
    m=n;
    while(n>0)
    {
        k=n%10;
        s=s+k;;
        n/=10;
    }
    if(m%s==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

A=sorted(A)

ans=1
now=A[0]
sums=A[0]
for i in range(N-1):
    if 2*sums>=A[i+1]:
        ans+=1
        #now+=A[i+1]
    else:
        ans=1
        #now=A[i+1]
    sums+=A[i+1]
print(ans)

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

int main() {
  int A, N;
  cin >> N >> A;
  
  if(N % 500 == 0)
  {
    cout << "Yes" << endl;
  } else {
    if(N % 500 <= A)
    {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,e) for(int i = a;i < e;++i)
using LL = long long;

int main() {

	int N;
	cin >> N;
	vector<string> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	auto b = a;
	FOR(i, 0, N) {
		sort(b[i].begin(), b[i].end());
	}
	map<string, LL> m;
	FOR(i, 0, N) {
		m[b[i]]++;
	}
	LL ans = 0;
	for (auto it : m) {
		LL ret = it.second * (it.second - 1) / 2;
		ans += ret;
	}
	cout << ans << endl;

}




Measured memory_bytes: 23680
#include<cstdio>
#include<cstring>
#define MIN(X,Y) ((X)>(Y) ? (Y) : (X))

int d[200][200];

int main(void) {
    while(1) {
        int n,m,s,g1,g2;
        scanf("%d%d%d%d%d",&n,&m,&s,&g1,&g2);
        if(!n) break;

        s--, g1--, g2--;
        memset(d, 0x20, sizeof(d));
        for(int i=0;i<n;i++)
            d[i][i] = 0;

        for(int i=0;i<m;i++) {
            int b,e,c;
            scanf("%d%d%d",&b,&e,&c);
            b--, e--;
            d[b][e] = c;
        }

        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
                for(int k=0; k<n; k++)
                    d[j][k] = MIN(d[j][k], d[j][i] + d[i][k]);

        int res=0x5FFFFFFF;
        for(int i=0; i<n; i++)
            res = MIN(d[s][i]+d[i][g1]+d[i][g2], res);
        printf("%d\n", res);
    }

    return 0;
}

Measured memory_bytes: 2760
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

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

ll N;
ll X;
ll b[100000], l[100000], u[100000];
ll base = 0;
P p[100000];

bool judge(ll c){
    ll m = c/X;
    ll score = 0;
    for(int i = 0; i < m; i++){
        ll s = p[i].first;
        int idx = p[i].second;
        score += s;
    }
    if(c%X != 0){
        ll rem = c%X;
        vector<P> v;
        for(int i = m; i < N; i++){
            int idx = p[i].second;
            v.push_back(P(u[idx]*(rem-b[idx]) + b[idx]*l[idx], idx));
            v.push_back(P(l[idx]*(rem-b[idx]) + b[idx]*l[idx], idx));
            //cout << (u[idx]*(rem-b[idx])) << endl;
        }
        sort(v.begin(), v.end(), greater<P>());
        score += v[0].first;

        //もうひとパターン
        ll score1 = 0, score2 = 0;
        vector<P> v1, v2;
        for(int i = 0; i <= m; i++){
            score1 += p[i].first;
            score2 += p[i].first;
        }
        for(int i = 0; i <= m; i++){
            int idx = p[i].second;
            v1.push_back(P(-u[idx]*X+u[idx]*rem, idx));
            v2.push_back(P(-u[idx]*X+l[idx]*rem+u[idx]*b[idx]-l[idx]*b[idx], idx));
        }
        sort(v1.begin(), v1.end(), greater<P>());
        score1 += v1[0].first;
        sort(v2.begin(), v2.end(), greater<P>());
        score2 += v2[0].first;
        score = max({score, score1, score2});
    }
    //cout << base+score << endl;
    if(base+score >= 0) return true;
    else return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> X;
    ll b_sum = 0;
    for(int i = 0; i < N; i++){
        cin >> b[i] >> l[i] >> u[i];
        b_sum += b[i];
        base -= b[i]*l[i];
        p[i] = P(u[i]*X-u[i]*b[i]+l[i]*b[i], i);
    }
    if(b_sum == 0){
        cout << 0 << endl;
        return 0;
    }
    sort(p, p+N, greater<P>());
    // for(int i = 0; i < N; i++){
    //     cout << p[i].second << ' ' << p[i].first << endl;
    // }
    ll l = 0, r = N*X;
    while(r-l > 1){
        ll c = (l+r)/2;
        if(judge(c)) r = c;
        else l = c;
    }
    cout << r << endl;
}

Measured memory_bytes: 12456
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};
	

ll dp[2][200001];

void show(int n,ll sv){
	for(int i=0;i<2;i++){
		for(int j=0;j<sv+1;j++){
			if(dp[i][j]==LINF) cout << "∞";
			else				cout << dp[i][j];
			cout << " ";
		}
		cout << "\n";
	}
}

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

	string s;
	cin >> s;
	int len=s.size();

	int dict[26]={};
	for(int i=0;i<len;i++){
		dict[s[i]-'a']=1;
	}
	
	if(len<26){
		cout << s;
		for(auto i=0;i<26;i++){
			if(dict[i] == 0){
				cout << (char)(i+'a') << "\n";
				return 0;
			}
		}
	}else{
		for(int i=25;i>=0;i--){
			for(int j=25;j>i;j--){
				if(j==26) continue;
				if(s[i] < s[j] ){
					cout << s.substr(0,i) << s[j] << "\n";
					return 0;
				}
			}
		}
		cout << "-1\n";
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int p1 = N % 10;
  int p2 = (N / 10) % 10;
  int p3 = (N / 100) % 10;
  int p4 = (N / 1000);
  
  if (p1 == p2 && p2 == p3 || p2 == p3 && p3 == p4) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
int num[10]={};
bool judge(int n){
  bool flag=true;
  int pow[9]={0,1,10,100,1000,10000,100000,1000000,10000000};
  int keta=0;
  int buf=n;
  while(buf>0){
    buf/=10;
    keta++;
  }
  //cout<<keta<<"\n";
  for (int i = keta; i>=1; i--){
    if(num[n/pow[i]]==1){
      flag=false;
    }
    n%=pow[i];
  }
  return flag;
}
signed main(){
  int n,k;cin>>n>>k;
  rep(i,10){
    //num[i]=0;
  }
  rep(i,k){
    int buf;cin>>buf;
    num[buf]++;
  }
  int res=n;
  while(!judge(res)){
    res++;
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
struct card{
	char suit,value;
};
void bubblesort(card a[],int n){
	for(int i=1;i<=n-1;++i){				//1.i一定要能取到最后（原来打成i<n-1） 
		for(int j=n-1;j>=i;--j){
			if(a[j].value<a[j-1].value){
				swap(a[j],a[j-1]); 
			}
		}
	}
} 
void selectionsort(card a[],int n){
	int k;
	for(int i=0;i<n-1;++i){
		k=i;
		for(int j=i+1;j<n;++j){
			if(a[j].value<a[k].value){
				k=j;
			} 
		}
		if(k!=i){
			swap(a[k],a[i]);
		}
	}
}
void print(card a[],int n){
	for(int i=0;i<n;++i){
		cout<<a[i].suit<<a[i].value<<" \n"[i==n-1]; 
	}
} 
bool isstable(card a[],card b[],int n){
	for(int i=0;i<n;++i){
		if(a[i].suit!=b[i].suit){
			return 0;
		}
	}
	return 1;
}
int main(){
	card c1[36],c2[36]; 
	int n;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>c1[i].suit>>c1[i].value;
		c2[i]=c1[i];
	}
	bubblesort(c1,n);
	print(c1,n);
	cout<<"Stable"<<endl; 
	selectionsort(c2,n);
	print(c2,n);
	if(isstable(c1,c2,n)){
		cout<<"Stable"<<endl;
	} else{
		cout<<"Not stable"<<endl;
	}
	return 0;
}


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

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int X = sc.nextInt();
    int Y = sc.nextInt();
    
    System.out.println((Y >= 2*X && Y <= 4*X && Y%2==0)?"Yes":"No");
      
  }
}

Measured memory_bytes: 26960
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
using P = pair<int, int>;
const int INF = 1LL << 62;

signed main(){

  int n, K; cin >> n >> K;
  vector<int> x(n), y(n);
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i];
  }

  int ans = INF;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      for(int k = 0; k < n; k++){
        for(int l = 0; l < n; l++){
          int xmax = max({x[i], x[j], x[k], x[l]});
          int xmin = min({x[i], x[j], x[k], x[l]});
          int ymax = max({y[i], y[j], y[k], y[l]});
          int ymin = min({y[i], y[j], y[k], y[l]});
          int cnt = 0;
          for(int m = 0; m < n; m++){
            cnt += (xmin <= x[m] && x[m] <= xmax && ymin <= y[m] && y[m] <= ymax);
          }
          if(cnt >= K) ans = min(ans, (xmax - xmin) * (ymax - ymin));
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int n;
vector<vector<int>> test;

void func(vector<int> v){
	if(v.size() == n){
		test.push_back(v);
	}

	vector<bool> num(n, false);
	rep(i, v.size()){
		num[v[i]] = true;
	}
	
	rep(i, num.size()){
		if(!num[i]){
			vector<int> t = v;
			t.push_back(i);
			func(t);
		}
	}
}

int main(){
	cin >> n;

	vector<pair<double, double>> input(n);
	rep(i, n){
		cin >> input[i].first >> input[i].second;
	}

	rep(i, n){
		vector<int> v;
		v.push_back(i);
		func(v);
	}

	double ans = 0;
	rep(i, test.size()){
		rep(j, n - 1){
			double x = input[test[i][j + 1]].first - input[test[i][j]].first;
			double y = input[test[i][j + 1]].second - input[test[i][j]].second;
			ans += sqrt(x * x + y * y);
		}
	}

	printf("%.10f", ans / (double)test.size());

	return 0;
}

Measured memory_bytes: 6460
#define  _CRT_SECURE_NO_WARNiINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <cassert>
#include <set>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define cycle_per_sec 2806192512
int main() {
#define int long long
	int n;
	cin >> n;
	long long ans = 0;
	long long back = 0;
	long long geko = 0;
	vector<int> nyaw;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		nyaw.push_back(a);
		if ((a & geko) != 0) {
			while ((a & geko) != 0) {
				ans += i - back;
				geko ^= nyaw[back];
				back++;
			}
		}
		geko |= a;
	}
	while (back < nyaw.size()) {
		ans += nyaw.size() - back;
		geko ^= nyaw[back];
		back++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2420
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var HW = Sarray();
            var H = HW[0];
            var W = HW[1];
            var dct = new Dictionary<char, long>();
            for (var i = 0; i < H; ++i)
            {
                var A = ReadLine();
                foreach(var a in A)
                {
                    if (!dct.ContainsKey(a)) dct[a] = 0;
                    ++dct[a];
                }
            }
            var fNum = 0L;
            var tNum = 0L;
            var oNum = 0L;
            foreach(var d in dct)
            {
                fNum += d.Value / 4;
                tNum += (d.Value % 4) / 2;
                oNum += d.Value % 2;
            }
            var fNeed = (H / 2) * (W / 2);
            var tNeed = (H % 2) * (W / 2) + (W % 2) * (H / 2);
            var oNeed = (H % 2) * (W % 2);
            var flg = true;
            if (fNum < fNeed) flg = false;
            if ((fNum - fNeed) * 2 + tNum != tNeed) flg = false;
            if (oNeed != oNum) flg = false;
            if (flg)
                WriteLine("Yes");
            else
                WriteLine("No");
            Out.Flush();
        }
    }
}

Measured memory_bytes: 13280
#include <stdio.h>

int main(){
	int A1,A2,A3;
	scanf ("%d %d %d",&A1,&A2,&A3);
	int total = A1 + A2 + A3;
	if (total >= 22){
	printf ("bust\n");
	}
	else if (total < 22){
	printf ("win\n");
	}
	
	return 0;
}

Measured memory_bytes: 2072
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int x, y, z, k;
long long a[1000];
long long b[1000];
long long c[1000];


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

	cin >> x >> y >> z >> k;
	rep(i, x)cin >> a[i];
	rep(i, y)cin >> b[i];
	rep(i, z)cin >> c[i];

	sort(a, a + x, greater<long long>());
	sort(b, b + x, greater<long long>());
	sort(c, c + x, greater<long long>());

	priority_queue<pair<long long, int>> pq;
	rep(i,x) {
		rep(j,y) {
			pq.emplace(a[i] + b[j] + c[0], 0);
		}
	}

	rep(i, k) {
		auto p = pq.top();
		pq.pop();
		long long v = p.first;
		int idx = p.second;

		cout << v << endl;
		if (idx + 1 < z) {
			pq.emplace(v - c[idx] + c[idx + 1], idx + 1);
		}
	}


	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  int ans = 0;
  for (int i = 1; i <= b - a; i++) {
    ans += i;
  }
  ans -= b;
  
  cout << ans << endl;
}

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

// #define fi first
#define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define WHITE 0  // 未訪問
#define BLACK 1  // 訪問ずみ

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
const int N=100000;
//const ll M = 1000000000+7;


int main(){
  string s;
  cin>>s;

  ll st = 0;

  ll ans=0;
  rep(i, s.size()){
    if(s[i]=='S') st++;
    else if(st>0) {
      st--;
      ans++;
    }
  }
  
  cout << s.size()-2*ans <<endl;
    return 0;

}
 


Measured memory_bytes: 640
// https://atcoder.jp/contests/abc117/tasks/abc117_d

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")
#define DUMP2DLL(a, n, m) REP(_i, n) REP(_j, m) printf("%lld%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int K_MAX = 1e12;
const int A_I_MAX = 1e12;
const int BIT_LEN = 40;

int N;
ll K;
ll A[N_MAX];

int bs[BIT_LEN];
int cs[2][BIT_LEN];

ll dp[BIT_LEN + 1][2];

void solve() {
  REP(i, BIT_LEN) bs[i] = K >> i & 1;
  REP(k, N) REP(i, BIT_LEN) cs[1][i] += A[k] >> i & 1;
  reverse(bs, bs + BIT_LEN);
  reverse(cs[1], cs[1] + BIT_LEN);
  REP(i, BIT_LEN) cs[0][i] = N - cs[1][i];


  // printf("bs: "); DUMP(bs, BIT_LEN);
  // printf("cs:\n"); DUMP2D(cs, 2, BIT_LEN);

  fill(dp[0], dp[BIT_LEN+1], -1);
  dp[0][0] = 0;
  REP(i, BIT_LEN) {
    // printf("i:%d\n", i);
    REP(smaller, 2) FOR(j, 0, smaller ? 1 : bs[i]) {
      int smaller2 = smaller || j < bs[i];
      ll add = (1LL << BIT_LEN - 1 - i) * cs[1 - j][i];
      if (dp[i][smaller] >= 0) {
        // printf("  j:%d smaller:%d->%d add:%lld\n", j, smaller, smaller2, add);
        dp[i + 1][smaller2] = max(dp[i + 1][smaller2], dp[i][smaller] + add);
      }
    }
  }

  // DUMP2DLL(dp, BIT_LEN + 1, 2);

  printf("%lld\n", max(dp[BIT_LEN][0], dp[BIT_LEN][1]));
}

void input() {
  scanf("%d%lld", &N, &K);
  REP(i, N) scanf("%lld", A + i);
}

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


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

int main() {
	int n,r;
	int p,c;
	int a[50];
	int b[50];
	while(1)
	{
		cin>>n>>r;
		if(n==0||r==0)
		{
			break;
		}
		int i=1;
		for(i=0;i<n;i++)
		{
			a[i]=n-i;
			b[i]=0;
		}
		i=0;
		while(r!=i)
		{
			cin>>p>>c;
			int j;
			for(j=0;j<c;j++)
			{
				b[j]=a[j+(p-1)];
			}
			for(j=0;j<p-1;j++)
			{
				b[c+j]=a[j];
			}
			for(j=0;j<(p-1)+c;j++)
			{
				a[j]=b[j];
			}
			i++;
		}
		cout<<a[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;


template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
    arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
    for (auto& i : arr) {
        fill_all(i, v);
    }
}

std::string S;
int64_t dp[200][10][2];
int func(int i, int k, int can_over = false) {
    if (k < 0) { return 0; }
    if (i == S.size()) {
        return k == 0 ? 1 : 0;
    }
    auto& memo = dp[i][k][can_over?1:0];
    if (memo != -1) {
        return memo;
    }
    int si = can_over?10:(S[i] - '0');

    memo = func(i+1,k,0 < si);//v=0
    for (int v = 1; v <= si && v < 10; v++)
    {
        memo += func(i + 1, k-1, v < si);
    }
    return memo;
}

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    int K;
    in >> S >> K;
    fill_all(dp, -1);
    out << func(0, K) << endl;

    return 0;
}
#endif


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <vector>
#include <iostream>
using namespace std;
int main(){
  int N,Q;
  string S;
  
  cin >>N >>Q;
  cin >>S;
   vector<int> li(Q),ri(Q);
  for(int i=0;i<Q;i++){
    cin >>li.at(i) >>ri.at(i);
  }
  
  vector<int> sum(N+1, 0);
  
  for(int i=1;i<N;i++){
    if(S.at(i-1)=='A'&&S.at(i)=='C'){
  sum.at(i)=sum.at(i-1)+1;    
    }else{
      sum.at(i)=sum.at(i-1);
    }

  }
  
  for(int i=0;i<Q;i++){
   int ans=sum[ri[i]-1]-sum[li[i]-1];
    
  
cout <<ans <<endl;
  }
  
}

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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n;

bitset <10> colour;

void read() {
  cin >> n;
}

void solve() {
  int ans = 0, nrNutella = 0;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    x = x / 400;
    if (x >= 8)
      ++nrNutella;
    else if (!colour[x]) {
      ++ans;
      colour[x] = 1;
    }
  }
  cout << max(1, ans) << " " << ans + nrNutella << "\n";
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t;           // PLEASE REMOVE IT IF NEEDED
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

ll bin_pow(ll a, ll n) {
  ll ans=1;
  while (n>0) {
    if (n&1) ans=ans*a%mod;
    a = a*a%mod;
    n>>=1;
  }
  return ans%mod;
}

ll inv_mod(ll a) {
  return bin_pow(a, mod-2);
}

vector<ll> Fact(1000100+1,1);

ll fact(ll n) {
  return Fact[n]%mod;
}

ll comb(ll n, ll r) {
  return fact(n)*inv_mod(fact(r)*fact(n-r)%mod)%mod;
}

ll diff(ll a, ll b) {
  if (a >= b) return a-b;
  else return a+mod-b;
}

int main()
{
  for (int i = 1; i < Fact.size(); ++i)
  {
    Fact[i]=Fact[i-1]*i%mod;
  }

  ll n;
  cin>>n;
  ll ans=0;
  for (ll i = 0; i < n-1; ++i)
  {
    ans+=((comb(n,i)*bin_pow(8,i))%mod*diff(bin_pow(2,n-i),2))%mod;
    ans%=mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 10988
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

from bisect import bisect_right

N,M = II()
A = str(input())

B = A[::-1]

ans = []
place = 0
while place!=N:
    for i in range(1,M+1)[::-1]:
        if place+i<=N:
            if B[place+i]!='1':
                ans.append(i)
                place += i
                break
        if i==1 and B[place+i]=='1':
            print(-1)
            exit()

print(*list(reversed(ans)))

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

const int N = 2e5 + 10;
int n, K;
double p[N], sum[N], ans;

int main() {
    cin >> n >> K;
    rep(i, 1, n) {
        scanf("%lf", &p[i]);
        // p[i] = (p[i] + 1) / 2.0;
    }
    rep(i, 1, n) sum[i] = sum[i - 1] + p[i];
    rep(i, K, n) ans = max(ans, sum[i] - sum[i - K]);
    ans = (ans + K) / 2.0;
    printf("%.7lf\n", ans);
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    long long a, B, mult, ans;
    double b;
    cin >> a >> b;
    B = b * 100 + 0.5;
    mult = a * B;
    ans = mult / 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3676