akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


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

int main(){
  int a, b;
  cin >> a >> b;
  int ans = 0;

  for(int i = a; i <= b; ++i){
    string str = to_string(i);
    int l = 0, r = str.length() - 1;
    while(true){
      if(l >= r){
        ans++;
        break;
      }

      if(str[l] != str[r])  break;

      l++;
      r--;
    }
  }

  cout << ans << endl;


}


Measured memory_bytes: 256
void main() {
	auto n = ri;
	auto a = readAs!(long[]);
	"%d %d %d".writefln(a.reduce!min, a.reduce!max, a.sum);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string szLine = Console.ReadLine();
            string[] szArr = szLine.Split(' ');
            int nTotal = szArr.Length;
            long[] arr = new long[nTotal];

            long sum = 0;
            for (int i = 0; i < arr.Length; ++i)
            {
                arr[i] = long.Parse(szArr[i]);
                sum += arr[i];
            }

            //long a = arr[0];
            //long b = arr[1];
            //long c = arr[2];
            //long sum = a + b + c;

            long max = 0;
            for (int i = 0; i < arr.Length; ++i)
            {
                if (arr[i] > max)
                {
                    max = arr[i];
                }
            }

            if ((max * 3) % 2 == sum % 2)
            {
                Console.WriteLine((max * 3 - sum) / 2);

            }
            else
            {
                Console.WriteLine(((max + 1) * 3 - sum) / 2);

            }

        }
    }
}


Measured memory_bytes: 13140
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int N, K;

	cin >> N >> K;
	vector<bool>flag(N, false);

	for (int i = 0; i < K; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int num;
			cin >> num;
			flag[num - 1] = true;
		}
	}

	int cnt = 0;
	for (int i = 0; i < flag.size(); i++) {
		if (flag[i] == false)cnt++;
	}

	cout << cnt << endl;


	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
 // freopen("input.txt","r",stdin);
#endif

  ll n,m;
  cin>>n>>m;
  vector<string> a(n+1,"NA");
  vector<ll> count(n+1);
  ll ac=0;
  ll wa=0;
  for(ll i=0;i<m;i++)
  {
    ll num;
    string s;
    cin>>num>>s;
    if(a[num]=="AC")
      continue;
    a[num]=s;
    if(s=="AC")
    {
      ac++;
      wa+=count[num];
    }
    else
    {
      count[num]++;
    }
  }

  cout<<ac<<" "<<wa<<endl;

  return 0;
}

Measured memory_bytes: 7128
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    bool zero = false;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i] == 0){
            zero = true;
        }
    }

    long long abs_sum = 0;
    for(int i=0;i<n;i++){
        abs_sum += abs(a[i]);
    }

    if(zero){
        cout << abs_sum << endl;
        return 0;
    }

    vector<int> neg_accum(n+1, 0);
    for(int i=0;i<n;i++){
        neg_accum[i+1] = neg_accum[i] + (a[i]<0?1:0);
    }
    long long maxx = 0;
    for(int i=0;i<n;i++){
        int neg_num = (neg_accum[i] % 2) + ((neg_accum[n] - neg_accum[i+1]) % 2) + (a[i] < 0 ? 1: 0);
        if(neg_num % 2 == 0){
            maxx = abs_sum;
        }
        else{
            maxx = max(maxx, abs_sum - 2 * abs(a[i]));
        }
    }
    cout << maxx << endl;
    return 0;
}

Measured memory_bytes: 1024
/*  ex7_3
    B30095    */
#include <stdio.h>
#include <stdlib.h>

void print_compressed(char ** grid, int rows, int cols);

int main(void){
    int rows, cols, isRowEmpty, isColEmpty, i, j;
    char ** grid;
    
    scanf("%d %d", &rows, &cols);
    
    // memory allocation
    grid = (char **)malloc(rows * sizeof(char *));
    for(i = 0; i < rows; i++){
        grid[i] = (char *)malloc(cols * sizeof(char));
    }

    // input grid
    for(i = 0; i < rows; i++){
        for(j = 0; j < cols; j++){
            scanf(" %c", &(grid[i][j]));
        }
    }

    print_compressed(grid, rows, cols);

    // memory deallocation
    for(i = 0; i < rows; i++){
        free(grid[i]);
    }
    free(grid);

    return 0;
}


void print_compressed(char ** grid, int rows, int cols){
    int isRowEmpty, isColEmpty, i, j;

        // substitue empty rows with whitespaces
    for(i = 0; i < rows; i ++){
        isRowEmpty = 1;
        
        // check if the row is empty
        for(j = 0; j < cols; j++){
            if(grid[i][j] == '#') {
                isRowEmpty = 0;
            }
        }

        // fill in empty rows with whitespaces
        if(isRowEmpty){
            for(j = 0; j < cols; j++){
                grid[i][j] = ' ';
            }
        }
    }

    // substitue empty columns with whitespaces
    for(j = 0; j < cols; j ++){
        isColEmpty = 1;
        
        // check if the column is empty
        for(i = 0; i < rows; i++){
            if(grid[i][j] == '#') {
                isColEmpty = 0;
            }
        }

        // fill in empty columns with whitespaces
        if(isColEmpty){
            for(i = 0; i < rows; i++){
                grid[i][j] = ' ';
            }
        }
    }


    // print compressed result
    for(i = 0; i < rows; i++){
        isRowEmpty = 1;

        for(j = 0; j < cols; j++){
            if(grid[i][j] == '#') isRowEmpty = 0;
            if(grid[i][j] != ' ') printf("%c", grid[i][j]);
            
        }

        if(!isRowEmpty) printf("\n");  // new line should not be printed when the row is empty
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  vector<int>val(n);
  rep(i,n){
    val[i]=a[i];
  }
  sort(val.rbegin(),val.rend());
  vector<int>ans(n);
  rep(i,n){
    if(val[0]==a[i])ans[i]=val[1];
    else ans[i]=val[0];
    cout << ans[i] << endl;
  }
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  vector<tuple<string, int, int>> rest(N);
  
  for (int i = 0; i < N; i++) {
    string s;
    int p;
    cin >> s >> p;
    rest.at(i) = make_tuple(s, -p, i+1);
  }
  
  sort(rest.begin(), rest.end());
  
  for (int i = 0; i < N; i++) {
    cout << get<2>(rest.at(i)) << endl;
  }
}

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


int main() {
  int a, b;
  cin >> a >> b;
  string ans="";
  
  if (a < b){
    for(int i = 0; i < b; i++){
      ans += to_string(a);
    }
  }else{
    for(int i = 0; i < a; i++){
      ans += to_string(b);
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
S = list(input())
N = len(S)
for i in range(N):
	n = N - i - 1	#i+1文字消したときの長さ
	if n % 2 == 0:	#それが偶数のとき処理する
		h = n // 2	#半分のところ
		if S[:h]==S[h:n]:
			ans = S[:h]+S[h:n]
			break

print(len(ans))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  long long int n,m,d;
  cin >> n >> m >> d;

  long long int c = 0;
  for(long long int i=1;i<=n;i++){
    if(d==0){
      c++;
      continue;
    }
    if(i+d<=n)
      c++;
    if(i-d>=1)
      c++;
  }
  long double r = 0.0;
  r = (long double)c*(m-1);
  r /= (n*n);
  cout << fixed;
  cout << setprecision(6) << r << endl;

  return 0;
}


Measured memory_bytes: 888
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

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 S(): return input()

def count_inside(x1, x2, y1, y2, points):
    cnt = 0
    if x2 < x1:
        x1, x2 = x2, x1
    if y2 < y1:
        y1, y2 = y2, y1

    for p in points:
        if x1 <= p[0] <= x2 and y1 <= p[1] <= y2:
            cnt += 1
    return cnt

def main():
    N, K = LI()
    points = []
    for _ in range(N):
        x, y = LI()
        points.append((x, y))
    points = sorted(points, key=lambda x: (x[0], x[1]))
    X = [p[0] for p in points]
    Y = [p[1] for p in points]
    area = inf
    for i in range(N):
        x1 = X[i]
        for j in range(i+1, N):
            x2 = X[j]
            for k in range(N):
                y1 = Y[k]
                for l in range(k+1, N):
                    y2 = Y[l]
                    if K == count_inside(x1, x2, y1, y2, points):
                        _area = abs(x1-x2) * abs(y1-y2)
                        area = min(_area, area)
    print(area)

main()



Measured memory_bytes: 75864
N,K=map(int,input().split())
V=list(map(int,input().split()))
ans=0

for i in range(1,N+1):#何個取るか
    if i>K:
        break
    for r in range(i+1):

        l=i-r
        a=V[:r]
        b=V[N-l:]
        f=max(0,K-i)
        c=a+b
        c.sort()
        k=0
        t=0
        for j in c:
            if t<f and j<0:
                t+=1
                continue
            k+=j
        ans=max(ans,k)
print(ans)


Measured memory_bytes: 39664
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
	  Scanner sc =new Scanner(System.in);
	  int a = sc.nextInt();
	  int b = sc.nextInt();
	  int area = a*b;
      int length = 2*(a+b);
      System.out.println(area+" "+length);
  }
}

Measured memory_bytes: 25844
#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1e9 + 7;

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

    int m = sqrt(n);
    vector<vector<long long int>> dp1(k+1, vector<long long int>(m+2)), dp2(k+1, vector<long long int>(m+2));
    for(int j=1; j<=m; j++){
        dp1[1][j] = 1;
        dp2[1][j] = 1;
    }
    for(int i=1; i<k; i++){
        for(int j=1; j<=m; j++){
            if(j == n/j) break;
            dp2[i+1][j] = dp2[i+1][j-1] + dp1[i][j];
            dp2[i+1][j] %= MOD;
        }

        if(m == n/m) dp1[i+1][m] = dp2[i+1][m-1] + dp1[i][m];
        else         dp1[i+1][m] = dp2[i+1][m] + dp2[i][m] * (n/m - n/(m+1));
        dp1[i+1][m] %= MOD;

        for(int j=m-1; j>0; j--){
            long long int num = n/j - n/(j+1);
            num %= MOD;
            dp1[i+1][j] = dp1[i+1][j+1] + dp2[i][j] * num;
            dp1[i+1][j] %= MOD;
            //cout << j << " " << num << endl;
        }
    }
    long long int ans = 0;
    for(int j=1; j<=m; j++){
        ans += dp1[k][j];
        ans %= MOD;
        //cout << "dp1[" << k << "][" << j << "] = " << dp1[k][j] << endl;
    }
    for(int j=1; j<=m; j++){
        ans += dp2[k][j] * (n/j - n/(j+1));
        ans %= MOD;
        //cout << "dp2[" << k << "][" << j << "] = " << dp2[k][j] << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 53248
class Node():
    def __init__(self,node_id,left,right):
        self.node_id = node_id
        self.parent = -1
        self.left = left
        self.right = right
        self.sibling = -1
        self.degree = 0
        self.depth = 0
        self.height = 0
        self.type = 'leaf'

    def set_attr(self,node_id,parent,sibling,depth):
        if node_id == -1:
            return -1
        self.parent = parent
        self.sibling = sibling
        self.depth = depth
        self.degree = (self.left != -1)+(self.right != -1)
        if self.degree:
            self.type = 'internal node'
        if self.parent == -1:
            self.type = 'root'
        self.height = max(
            tree[self.left].set_attr(
            self.left,
            self.node_id,
            self.right,
            self.depth+1
            ),
            tree[self.right].set_attr(
            self.right,
            self.node_id,
            self.left,
            self.depth+1
            )
        )+1
        return self.height

n = int(input())
tree = [None]*n
root = set(range(n))

for _ in range(n):
    node_id,left,right = map(int,input().split())
    tree[node_id] = Node(node_id,left,right)
    root -= set([left,right])

root_id = root.pop()
tree[root_id].set_attr(root_id,-1,-1,0)
for node in tree:
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(node.node_id, node.parent, node.sibling, node.degree, node.depth, node.height, node.type))



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

using namespace std;

const int MX = 6001;

long long f[MX], inv[MX], inv_f[MX], inv2[MX], inv3[MX];

int main() {
	int n, md;
	ignore = scanf("%d %d", &n, &md);
	
	f[0] = f[1] = inv[1] = inv_f[0] = inv_f[1] = 1;
	for (int i = 2; i <= 3 * n; i++) {
		inv[i] = md - inv[md % i] * (md / i) % md;
		f[i] = f[i - 1] * i % md;
		inv_f[i] = inv_f[i - 1] * inv[i] % md;
	}
	
	inv2[0] = inv3[0] = 1;
	for (int i = 1; i <= 3 * n; i++) {
		inv2[i] = inv2[i - 1] * inv[2] % md;
		inv3[i] = inv3[i - 1] * inv[3] % md;
	}
	
	int ans = 0;
	for (int c3 = 0; c3 <= n; c3++)
		for (int c2 = 0; c2 + c3 <= n; c2++) {
			int c1 = 3 * n - c2 * 2 - c3 * 3;
			ans = (ans + f[3 * n] * inv3[c3] % md * inv2[c2] % md * inv_f[c1] % md * inv_f[c2] % md * inv_f[c3]) % md;
		}
	
	printf("%d\n", ans);
	
	return 0;
}


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

int main() {
	int s;
	set<int> tmp;
	cin >> s;
	while (tmp.count(s) == 0) {
		tmp.insert(s);
		if (s % 2) s = 3 * s + 1;
		else s /= 2;
	}
	cout << tmp.size() + 1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int lg(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
string s;
set<char>st;
signed main(){
    cin>>s;
    int l=s.size();
    if(l<26){
        rep(i,l){
            st.insert(s[i]);
        }
        rep(j,26){
            char c='a'+j;
            if(st.find(c)==st.end()){
                s=s+c;
                break;
            }
        }
    }
    else{
        for(int i=l-2;i>=0;i--){
            if(s[i]<s[i+1]){
                for(int j=l-1;j>=0;j--){
                    if(s[j]>s[i]){
                        s=s.substr(0,i)+s[j];
                        goto got;
                    }
                }
            }
            if(i==0){
                cout<<-1<<endl;
                return 0;
            }
        }
        got:;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//x,y
ll chocolate[1000][10];
ll h,w,k;
bool success(ll maxcuts){
	//cout<<"cuts: "<<maxcuts<<endl;
	for (ll w2 = 0; w2<(1<<(h-1)); w2++){
		vector<ll> pos;
		//cout<<"p: ";
		for (ll i = 0; i<(h-1); i++){
			if ((1<<i)&w2){
				pos.push_back(i);
				//cout<<i<<" ";
			}
		}//cout<<endl;
		pos.push_back(h-1);
		ll s = pos.size();
		if (s-1>maxcuts){
			continue;
		}
		ll numcuts = maxcuts-s+1;
		vector<ll> sums(s,0);
		ll ptr = 0;
		bool works = true;
		for (ll v = 0; v<s; v++){
			while (ptr<=pos[v]){
				sums[v]+=chocolate[0][ptr];
				ptr++;
			}
			if (sums[v]>k){
				works=false;
				break;
			}
			//cout<<sums[v]<<" ";
		}//cout<<endl;
		if (!works){
			continue;
		}
		for (ll x = 1; x<w; x++){
			//do we need to cut after row
			ll ptr = 0;
			bool cut = false;
			for (ll v = 0; v<s; v++){
				while (ptr<=pos[v]){
					sums[v]+=chocolate[x][ptr];
					ptr++;
				}
				//cout<<sums[v]<<" ";
				if (sums[v]>k){
					cut=true;
					break;
				}
			}//cout<<endl;
			if (cut){
				//cout<<"false"<<endl;
				numcuts--;
				if (numcuts<0){
					works=false;
					break;
				}
				sums.assign(s,0);
				ptr = 0;
				for (ll v = 0; v<s; v++){
					while (ptr<=pos[v]){
						sums[v]+=chocolate[x][ptr];
						ptr++;
					}
					if (sums[v]>k){
						works=false;
						break;
					}
					//cout<<sums[v]<<" ";
				}//cout<<endl;
			}
			if (!works){
				break;
			}
		}
		if (works){
			//cout<<"works"<<endl;
			return true;
		}
	}
	return false;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cin>>h>>w>>k;
	for (ll y = 0; y<h; y++){
		for(ll x = 0; x<w; x++){
			char c;
			cin>>c;
			chocolate[x][y]=c-'0';
		}
	}
	ll l = 0, r = w-1+h-1;
	while (l<=r){
		ll mid = (l+r)/2;
		if (success(mid)){
			r=mid-1;
		} else {
			l=mid+1;
		}
	}
	cout<<l<<endl;
}

Measured memory_bytes: 384
n = "keyence"
s = input()

for i in s:
    if n[0] == i: #文字が一致するなら
        n = n[1:] #比較中の文字を削る
    else:
        break

n = n[::-1]

for i in s[::-1]:
    if n == "":
        break
    elif n[0] == i:
        n = n[1:]
    else:
        break

if n == "":
    print("YES")
else:
    print("NO")

Measured memory_bytes: 8992
n,c,k=list(map(int,input().split())) 
t_=sorted([int(input()) for x in range(n)])
cnt=1
num=[]
for i in t_:
	if len(num)==c:
		cnt+=1
		num=[i]
	elif len(num)!=0 and i>num[0]+k:
		cnt+=1
		num=[i]
	else:
		num.append(i)
print(cnt)

Measured memory_bytes: 8280
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("1500 2000 1600 3 2");
            //7900
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1500 2000 1900 3 2");
            //8500
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1500 2000 500 90000 100000");
            //100000000
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(pX => int.Parse(pX)).ToArray();

        int A = wkArr[0];
        int B = wkArr[1];
        int C = wkArr[2];
        int X = wkArr[3];
        int Y = wkArr[4];

        int Answer = int.MaxValue;
        for (int LoopAB = 0; LoopAB <= Math.Max(X, Y) * 2; LoopAB++) {
            int Cost = LoopAB * C;

            int RestA = X - LoopAB / 2;
            int RestB = Y - LoopAB / 2;

            RestA = Math.Max(RestA, 0);
            RestB = Math.Max(RestB, 0);

            Cost += RestA * A;
            Cost += RestB * B;

            if (Answer > Cost)
                Answer = Cost;
        }
        Console.WriteLine(Answer);
    }
}


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            // 入力
            var n = cin.ReadInt;
            var d = cin.ReadLongArray(n).ToList();
            d.Sort();
            long l = d[n / 2 - 1];
            long u = d[n / 2];
            long result = u - l;

            WriteLine(result);
        }  
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 22112
#include <stdio.h>

main(){
  int a, b, N, i, p, min, max=0;

  scanf("%d",&N);
  int A[N+1];

  for(i = 0; i < N; i++){
    scanf("%d", &A[i]);
    if(i == 1){
      min = A[i-1];
      p = A[i] - A[i-1];
      }
  }
  for(i = 1; i < N; i++){
    if(min > A[i]){
      min = A[i];
    }else if(A[i] - min > p){
      p = A[i] - min;
    }
  }
  printf("%d\n",p);
  return 0;
}

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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=1e5 +10, M=(ll)1e9+1 ;
const int mod =(ll)998244353 ,sz=5, MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";



void work(){
	ll x,y,z;
	cin >> x >> y >> z;
	swap(x,y);
	swap(x,z);
	cout << x << " " << y << " " << z ;
	return;
}

int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0);
 	
	ll t;
	// cin >> t;
	t=1;
	while(t--){
	        work();
	}
return 0;
}


Measured memory_bytes: 256
#include <iostream>


int LCM(int a, int b) {
  int xa, yb;
  int x = 1, y = 1;
  while (true) {
    xa = x * a;
    yb = y * b;
    if (xa == yb) {
      break;
    } else if (xa < yb) {
      x += 1;
    } else {
      y += 1;
    }
  }
  return xa;
}


int GCD(int a, int b) {
  int gcd = 1;
  int num = 2;
  while (num < a / 2 || num < b / 2) {
    if ((a % num) == 0 && (b % num) == 0) {
      gcd *= num;
      a /= num;
      b /= num;
    } else {
      num += 1;
    }
  }
  return gcd;
}

int main () {
  int a, b;
  int lcm, gcd;
  while (std::cin >> a >> b) {
    gcd = GCD(a, b);
    lcm = LCM(a, b);
    std::cout << gcd << " " << lcm << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3068
from collections import Counter

N,K = map(int,input().split())
A = list(map(int,input().split()))

d = Counter(A)
dic = sorted(d.items(), key=lambda x:x[1])
if len(dic)<=K:
    print(0)
else:
    ans = 0
    cnt = len(dic)
    for key,value in dic:
        if cnt-1==K:
            ans += value
            print(ans)
            break
        else:
            ans += value
            cnt -= 1

Measured memory_bytes: 39344
from itertools import product
H, W, K = map(int, input().split())
C = [input() for _ in range(H)]

ans = 0
# 全パターン検索 真偽値表
for rows in product([True, False], repeat=H):
    # print(rows)
    for cols in product([True, False], repeat=W):
        # print(cols)
        black = 0
        for r, c in product(range(H), range(W)):
            # print("{}:{}".format(r,c))
            if rows[r] and cols[c] and C[r][c] == '#':
                black += 1
        if black == K:
            ans += 1

print(ans)


Measured memory_bytes: 8996
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
int prime[1000001];
main(){
    int N;
    while(cin >> N){
        fill(prime,prime+1000001,0);
        for(int i = 2;i*i <= N;i++){
            if(prime[i])continue;
            for(int j = i*2;j <= N;j+=i){
                prime[j] = 1;
            }
        }
        int cnt = 0;
        for(int i = 2;i <= N;i++)if(!prime[i])cnt++;
        cout << cnt << endl;
    }
}

Measured memory_bytes: 7004
import java.util.Scanner;
import java.math.*;


/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
	       
        int a;
        int b;
        int d,r;
        double f;

       
           
        a = as.nextInt();
        b = as.nextInt();

        d=a/b;
        r=a%b;
        double fa=(double)a;
        double fb=(double)b;
        f=fa/fb;
        
        //System.out.println(f);
        BigDecimal fr = new BigDecimal(f);
        
        
        //System.out.println(fr);
        
        fr = fr.setScale(6,BigDecimal.ROUND_HALF_UP);
        
        
       


        

    System.out.println(d+" "+r+" "+fr);

	}

}

Measured memory_bytes: 26312
#include<stdio.h>
int main(void)
{
    int a, b, c;
    int i, j;
    int y[100]={0}, z, w=0;
    scanf("%d%d", &a, &b);
    int x[a][b];
    for(i = 0; i < a; i++){
        for(j = 0; j < b; j++){
            scanf("%d", &x[i][j]);
        }
    }
    for(i = 0; i < a; i++){
        z = 0;
        for(j = 0; j < b; j++){
            printf("%d ", x[i][j]);
            z += x[i][j];
            y[j] += x[i][j];
        }
        printf("%d\n", z);
    }
    for(j = 0; j < b; j++){
        printf("%d ", y[j]);
        w += y[j];
    }
    printf("%d\n", w);
    return 0;
}

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

using namespace std;

typedef long long ll;


int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
    cin >> N;
    ll start = 100;
    ll ret = 0;
    for(int i = 0 ; i < 3760; ++i){
        start += (start / 100);
        if(start >= N){
            ret = i+1;
            break;
        }
    }
    cout << ret << endl;

    return 0;


}

Measured memory_bytes: 3652
import sys
def input():
    return sys.stdin.readline()[:-1]
a, b= input().split()
a = int(a)
b = int(b.replace(".", ""))
# floatをそのまま掛け算すると大きい計算で誤差が生じるため、.を消してintにする。
output = a * b // 100
# 小数点は2桁までで確定なので、100で切り捨て除算する。
print(output)

Measured memory_bytes: 61844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;

bool b[1010];

void solve(){

    ll a,b,c;
    cin >> a >> b >> c;
    ll k;
    cin >> k;
    ll ma = max(a,max(b,c));
    ll t = ll(pow(2,k));
    cout << a+b+c+t*ma-ma << endl;

}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String str = scanner.nextLine();
		for(int i = 2 ; i < str.length(); i+=2){
			if(str.substring(0,(str.length()-i)/2).equals(str.substring((str.length()-i)/2,str.length()-i))){
				System.out.println(str.length()-i);
				return;
			}
		}
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int x;
	cin >> x;
	if (x)
		cout << 0 << en;
	else
		cout << 1 << en;


	return 0;
}




Measured memory_bytes: 3640
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	int w = tx - sx, h = ty - sy;
	string path;
	rep(i, 0, w)path.push_back('R');
	rep(i, 0, h)path.push_back('U');
	rep(i, 0, w)path.push_back('L');
	rep(i, 0, h + 1)path.push_back('D');
	rep(i, 0, w + 1)path.push_back('R');
	rep(i, 0, h + 1)path.push_back('U');
	path.push_back('L');
	path.push_back('U');
	rep(i, 0, w + 1)path.push_back('L');
	rep(i, 0, h + 1)path.push_back('D');
	path.push_back('R');
	cout << path << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    static int arr[];

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt(),k=s.nextInt();
        arr = new int[k];
        for(int i=0;i<k;i++)arr[i]=s.nextInt();
        for(int i=n; ;i++){
            if(ok(i+"")){
                System.out.println(i);
                break;
            }
        }

    }

    public static boolean ok (String word){
        //System.out.println(word);
        for(int i=0;i<word.length();i++){
            //System.out.println(Arrays.binarySearch(arr,10));
            if(Arrays.binarySearch(arr,word.charAt(i)-'0')>=0)return false;
        }
        return true;
    }
}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    string s,t;
    cin >> s >> t;
    string tes;
    bool flag;
    bool ans = false;
    int index;
    int num = s.size()-t.size();
    for(int i=0;i<=num;i++){
        flag = true;
        tes = s.substr(num-i,t.size());
        for(int j=0;j<t.size();j++){
            if(tes[j]!=t[j]&&tes[j]!='?')flag = false;
        }
        if(flag){
            index = num-i;
            ans = true;
            break;
        }
    }
    if(!ans){
        COUT("UNRESTORABLE");
        return 0;
    }
    for(int i=0;i<s.size();){
        if(i==index){
            cout << t;
            i+=t.size();
        }
        else{
            if(s[i]=='?'){
                cout << 'a';
                i++;
            }
            else{
                cout << s[i];
                i++;
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if (a == b) {
    if (b != c) {
      puts("Yes");
      return 0;
    }
  } else if (a == c) {
    puts("Yes");
    return 0;
  } else if (b == c) {
    puts("Yes");
    return 0;
  }
  puts("No");
  return 0;
}


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

int main()
{
	long long x, mod, cnt;
	cin >> x;
 
	cnt = x / 11 * 2;
	mod = x % 11;

	if (mod > 6)
		cnt += 2;
	else if (mod > 0)
		cnt += 1;

	cout << cnt << endl;

	return 0;
}






Measured memory_bytes: 256
import numpy as np
N = int(input())
S = [[] for I in range(0,N)]
for T in range(0,N):
    A = int(input())
    S[T] = np.zeros((A,2),dtype=int)
    for TT in range(0,A):
        S[T][TT,:] = np.array([int(X) for X in input().split()])
    
MAX = 0
for P in range(pow(2,N)-1,-1,-1):
    Bin    = [int(X) for X in list(('{:0'+str(N)+'b}').format(P,'b'))]
    BIndex = [I for I,N in enumerate(Bin) if N==1]
    Flag   = True
    for PT in BIndex:
        for PTB in range(0,S[PT].shape[0]):
            if S[PT][PTB,1]==0 and (S[PT][PTB,0]-1) in BIndex:
                Flag = False
                break
            if S[PT][PTB,1]==1 and (S[PT][PTB,0]-1) not in BIndex:
                Flag = False
                break
        if not Flag:
            break
    if Flag:
        MAX = len(BIndex)
        break
print(MAX)

Measured memory_bytes: 26668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
char q[2][100];
int n;

int main() {
	//freopen("i.txt","r",stdin);
	cin>>n;
	scanf("%s",q[0]);
	scanf("%s",q[1]);
	
	ll ans = 1; int sta = 0;
	for(int i=0;i<n;i++) {
		if(sta == 0) {
			if(q[0][i] == q[1][i])ans = ans * 3, sta = 1;
			else ans = ans * 6, i ++, sta = 2;
		}else if(sta == 1) {
			if(q[0][i] == q[1][i])ans = ans * 2 % mod, sta = 1;
			else ans = ans * 2 % mod, i++, sta = 2;
		}else {
			if(q[0][i] == q[1][i])sta = 1;
			else ans = ans * 3 % mod, sta = 2, i++;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N,M,X = map(int,input().split())
List = list(map(int,input().split()))
cnta = 0
cntb = 0
for i in range(M):
  if(List[i]>X):
    cnta +=1
  elif(List[i]<X):
    cntb +=1
print(min(cnta,cntb))

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

ll gcd(ll m, ll n) {
	int k = m % n;
	if (k != 0)
		return gcd(n, k);
	else
		return n;
}

ll lcm(ll m, ll n) {
	return m * n / gcd(m, n);
}

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

	ll a, b;
	cin >> a >> b;

	cout << lcm(a, b) << endl;

	return 0;
}


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

using namespace std;
using lint = long long;

struct tri{
  string a;
  int b;
  int c;

  bool operator<(const tri &another) const
  {
    if(a != another.a)
      return a < another.a;

    if(b != another.b)
      return b < another.b;

    return c < another.c;
  };
};

int main(void)
{
    int N, M;
    cin >> N >> M;
    int s[10][10] = {0};
    vector<int> p(M);
    for(int i = 0; i < M; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int t;
            cin >> t;
            s[i][t-1] = 1;
        }
    }
    for(int i = 0; i < M; i++){
        cin >> p[i];
    }
    int bin = 1;
    for(int i = 0; i < N; i++){
        bin *= 2;
    }
    int cnt = 0;
    //cout  << bin << endl;
    for(int i = 0; i < bin; i++){
        int n_switch = 0;
        int sum = 0;
        for(int k = 0; k < M; k++){
            n_switch = 0;
            int mask = 1;
            for(int j = 0; j < N; j++){
                if((mask & i) == mask){
                    if(s[k][j] == 1)
                        n_switch++;
                }
                mask = mask << 1;
            }
            //cout << n_switch << endl;
            if(p[k] == (n_switch % 2)){
                sum++;
            }
            //cout << p[k] << endl;
        }
        if(sum == M){
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

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

int lower(long k,long* A,int n);
int upper(long k,long* A,int n);

int main(void){
  int n;
  cin>>n;
  long A[n];
  for(long i=0;i<n;i++){
    cin>>A[i];
  }

  int q;
  cin>>q;
  long k;
  for(int i=0;i<q;i++){
    cin>>k;
    cout<<lower(k,A,n)<<" "<<upper(k,A,n)<<endl;;
  }
  return 0;
}

int lower(long k, long* A,int n){
  long low = 0;
  long high = n-1;
  long mid;
  while (high-low>10){
    mid = (high+low)/2;
    if(A[mid]>=k){
      high=mid;
    }
    else{
      low=mid;
    }
  }

  for(long i=low;i<=high;i++){
    if(A[i]>=k){
      return i;
    }
  }
  return n;
}

int upper(long k, long* A,int n){
  long low = 0;
  long high = n-1;
  long mid;
  while (high-low>10){
    mid = (high+low)/2;
    if(A[mid]<=k){
      low=mid;
    }
    else{
      high=mid;
    }
  }

  for(long i=high;i>=low;i--){
    if(A[i]<=k){
      return i+1;
    }
  }
  return 0;
}



Measured memory_bytes: 3812
/*16D8104015E Nobushige Sen 18.5.15*/
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define TABLE_SIZE 16777216
#define ORDER_LENGTH 7
#define STR_LENGTH 13
 
using namespace std;
 
int array[128];
 
int translateStr(char buf[]){
    int sum = -1,mult = 1;
    for(int i = 0; buf[i] != '\0'; i++){
        sum += array[buf[i]]*mult;
        mult *= 4;
    }
    return sum;
}
 
int main(){
 
    array['A']=1,array['C']=2,array['G']=3,array['T']=4;
 
    int n;
    scanf("%d",&n);
    char order[ORDER_LENGTH],str[STR_LENGTH];
 
    char* check_table = new char[TABLE_SIZE];
 
    for(int i = 0; i < n; i++){
        scanf("%s %s",order,str);
        if(order[0] == 'i'){
            check_table[translateStr(str)] = 'Y';
        }else{
            if(check_table[translateStr(str)] == 'Y'){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
}

/*
yes
no
no
yes
yes
yes
*/




Measured memory_bytes: 4500
from sys import stdin
input = stdin.readline

ans = 10 ** 10

N, M, X = map(int, input().strip().split())

C = []
A = [[]] * N

for i in range(N):
    tmp = list(map(int, input().strip().split()))
    C.append(tmp[0])
    A[i] = tmp[1:]

for i in range(2 ** N):
    tans = 0
    tA = [0] * M
    for j in range(N):
        if i & (1 << j):
            tans += C[j]
            for k in range(M):
                tA[k] += A[j][k]

    flag = True
    for k in range(M):
        flag &= (tA[k] >= X)

    #print(i, tA, tans)

    if flag:
        ans = min(ans, tans)

if ans == 10 ** 10:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9236
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ll n;
	cin>>n;
	ll q=n/500;
	ll rem=n%500;
	ll q1=rem/5;
	ll rem1=rem%5;
	cout<<q*1000+q1*5<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    long double L;
    cin >> L;
    long double x = L/(long double)3;

    cout << setprecision(15) << x*x*x << endl;
}


Measured memory_bytes: 256
n,m,x,y=map(int,input().split())
x_=list(map(int,input().split()))
y_=list(map(int,input().split()))
X=max(x_)
Y=min(y_)
if X<y and Y>x and X<Y:
    print("No War")
else:
    print("War")    


Measured memory_bytes: 2940
S = list(raw_input())
result = []
for s in S:
	if s == "0":
		result.append(0)
	elif s == "1":
		result.append(1)
	elif s == "B":
		if len(result) != 0:
			result.pop(len(result)-1)
txt = ""
for r in result:
	txt += str(r)
print txt


Measured memory_bytes: 2568