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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int h,w;
int c[11][11];

int main(){
	cin>>h>>w;
  rep(i,10)rep(j,10)cin>>c[i][j];
  rep(k,10)rep(i,10)rep(j,10)minch(c[i][j],c[i][k]+c[k][j]);
  int res=0;
  rep(i,h)rep(j,w){
    int a;
    cin>>a;
    if(a!=-1)res+=c[a][1];
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n,m;
  cin >> n >> m;
  int ans = n*(n-1)/2 + m*(m-1)/2;
  cout << ans << endl;
  
  return 0;
    

}


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

int main(){
    vector<int> a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(a.begin(),a.end());
    int ans=0;
    ans+=a[2]-a[1];
    a[0]+=a[2]-a[1];
    if((a[2]-a[0])%2==0) ans+=(a[2]-a[0])/2;
    else ans+=(a[2]+1-a[0])/2+1;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main extends App {
  val w = readLine.trim
  var line = ""
  var cnt = 0

  while( { line = readLine.trim;line } != "END_OF_TEXT") {
      line.split(" ").foreach( t => if(w.equalsIgnoreCase(t)) cnt += 1 )
  }
  println(cnt)
}

Measured memory_bytes: 43804
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;

int main() {
  int N;
  cin >> N;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  cpp_int ans = 1;
  for (auto a : A) {
    ans *= a;
    if (ans > (long) 1e18) return cout << -1 << "\n", 0;
  }
  cout << ans << "\n";
}

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

using namespace std;

const int N = 100 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
int p[N];

bool read() {
    if (!(cin >> n))
        return false;

    for (int i = 0; i < n; ++i)
        cin >> p[i];

    return true;
}

void solve() {
    sort(p, p + n);
    cout << p[n / 2] - p[n / 2 - 1] << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
using namespace std;

const int maxn = 111;
char gra[maxn][maxn];
int h, w;
int cnt;

void dfs(char ch, int row, int col);

int main(){
    while(scanf("%d%d", &h, &w)!=EOF &&(h||w)){
        for(int i = 0; i < h; ++i){
            scanf("%s", gra[i]);
        }
        cnt = 0;

        for(int i = 0; i < h; ++i){
            for(int j = 0; j < w; ++j){
                if(gra[i][j] == '#'){
                    dfs(gra[i][j], i, j);
                    ++cnt;
                }
                else if(gra[i][j] == '@'){
                    dfs(gra[i][j], i, j);
                    ++cnt;
                }
                else if(gra[i][j] == '*'){
                    dfs(gra[i][j], i, j);
                    ++cnt;
                }
            }
        }

        printf("%d\n", cnt);
    }
    return 0;
}

void dfs(char ch, int row, int col){
    gra[row][col] = 'v';
    if(gra[row+1][col] == ch && row+1 < h){
        dfs(ch, row+1, col);
    }
    if(gra[row-1][col] == ch && row-1 > -1){
        dfs(ch, row-1, col);
    }
    if(gra[row][col+1] == ch && col+1 < w){
        dfs(ch, row, col+1);
    }
    if(gra[row][col-1] == ch && col-1 > -1){
        dfs(ch, row, col-1);
    }
}

Measured memory_bytes: 1508
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define ushi int
#define tapu main
#define nichia (
#define kunn void
#define wara )

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main(){

	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", a + b / 2);

	Please AC;
}


Measured memory_bytes: 256
package main

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

func main() {
	_, M := ReadInt(), ReadInt()
	maxL := -1
	minR := 1 << 62
	for i := 0; i < M; i++ {
		L, R := ReadInt(), ReadInt()
		maxL = Max(maxL, L)
		minR = Min(minR, R)
	}
	if minR-maxL >= 0 {
		fmt.Println(minR - maxL + 1)
	} else {
		fmt.Println(0)
	}
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 5136
#include <algorithm>
#include <iostream>
#include <vector>

#define int long long int
using namespace std;

void solve() {
  int N;
  cin >> N;

  vector<int> v;

  while (N--) {
    int A;
    cin >> A;

    auto itr = upper_bound(v.begin(), v.end(), A, std::greater<int>());
    if (itr == v.end()) {
      v.push_back(A);
    } else {
      *itr = A;
    }
  }
  cout << v.size() << endl;
}

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


Measured memory_bytes: 1400
#include<stdio.h>

unsigned short scan_sentence(unsigned char * str, unsigned short length_max);
void count_alphabet(unsigned char * str, unsigned short * num_check, unsigned short length);

int main(){

	unsigned short length;
	unsigned char str[1200];
	unsigned short num_check[26];
	unsigned short i;
	
	for(i = 0;i < 1200;i++){
		str[i] = 0;
	}
	for(i = 0;i < 26;i++){
		num_check[i] = 0;
	}
	
	length = scan_sentence(str, 1200);
	
	count_alphabet(str, num_check, length);
	
	for(i = 0;i < 26;i++){
		printf("%c : %d\n", (i + 97), *(num_check + i));
	}
	
	return 0;
}

/* 関数名：文字列入力 */
/* 概要：文字列を入力する。その長さを返す */
/* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：入力された文字列の長さ */
unsigned short scan_sentence(unsigned char * str, unsigned short length_max)
{
	unsigned short count_text = 0;
	unsigned short i;

	for(i = 0;i < length_max;i++){
		scanf("%c", str + i);
		if(*(str + i) == EOF){
			break;
		}
		count_text++;
	}

	return count_text;
}

/* 関数名：アルファベットカウント */
/* 概要：渡された文字列に各アルファベットが何文字含まれるか調べる */
/* 引数：文字列が格納された配列の先頭アドレス、アルファベットの数を記録する配列の先頭アドレス、文字列の長さ */
/* 戻り値：なし */
void count_alphabet(unsigned char * str, unsigned short * num_check, unsigned short length)
{
	unsigned short i;
	char alphabet;
	for(i = 0;i < length;i++){
		if(((65 <= *(str + i)) && (*(str + i) <= 90)) || ((97 <= *(str + i)) && (*(str + i) <= 122))){
			alphabet = *(str + i) & 0x1F;
			*(num_check + (alphabet - 1)) += 1;
		}
	}
}




Measured memory_bytes: 2036
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
    }
    const M: u64 = 1_000_000_007;
    let mut a = 1;
    let mut b = 1;
    let mut c = 1;
    for _ in 0..n {
        a = a * 10 % M;
        b = b * 9 % M;
        c = c * 8 % M;
    }
    let ans = (a + (M - b) * 2 + c) % M;
    println!("{}", ans);
}


Measured memory_bytes: 2200
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

EPS = 1e-9

#http://www.deqnotes.net/acmicpc/2d_geometry/lines
def dot(a, b):
    return a.real * b.real + a.imag * b.imag

def cross(a, b):
    return a.real * b.imag - a.imag * b.real

def distance(a, b, c):
    if dot(b-a, c-a) <= EPS:
        return abs(c-a)
    if dot(a-b, c-b) <= EPS:
        return abs(c-b)
    return abs(cross(b-a, c-a)/(b-a))

r = n()
A = ln()

A.sort()

c = collections.Counter(A)

key = c.keys()
i = 0
j = len(key) - 1

cost = 0
while i <= j:
    while i < len(key) and c[key[i]] <= 1:
        i += 1
    while j >= 0 and c[key[j]] <= 1:
        j -= 1
    if i > j:
        break
    c[key[i]] -= 1
    c[key[j]] -= 1
    cost += 2

print r - cost


Measured memory_bytes: 33968
#include<bits/stdc++.h>
using namespace std;
struct node
{
    double x,y;
}a[8];
int n,v[10],o=1,h[10];
double ans=0;
double f(double x)
{
    return x*x;
}
void cal()
{
    for(int i=2;i<=n;i++)
        ans+=sqrt(f(a[h[i]].x-a[h[i-1]].x)+f(a[h[i]].y-a[h[i-1]].y));
}
void dfs(int x)
{
    if(x==n+1)
        cal();
    else
    {
        for(int i=0;i<n;i++)
        {
            if(v[i])
                continue;
            v[i]=1;
            h[x]=i;
            dfs(x+1);
            v[i]=0;
        }
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        o*=i;
    for(int i=0;i<n;i++)
        scanf("%lf%lf",&a[i].x,&a[i].y);
    dfs(1);
    printf("%lf",ans/o);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map> // STL
#include <string> 
#include <vector>
#include <queue>
#include <stack>
#define mpr make_pair
#define debug() puts("okkkkkkkk")

using namespace std;

typedef long long LL;

const int inf = 1 << 26;

int n,a[200005];

int dfs(int cnt,int mut){
//	printf("%d %d\n",cnt,mut);
	if(cnt==n+1){
//		printf("%d %d\n",cnt,mut);
		return mut%2==0;
	}
	int ans=0;
	ans=dfs(cnt+1,mut*(a[cnt]-1))+dfs(cnt+1,mut*(a[cnt]))+dfs(cnt+1,mut*(a[cnt]+1));
	
//	printf("%d\n",ans);
	return ans;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int ans=dfs(1,1);
	printf("%d\n",ans);

	return 0;
}


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

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

  //         a ------ b
  // c --- d
  //      c --- d
  //          c --- d
  //               c --- d
  //                    c --- d
  //      c ------------- d

  int ans = 0;
  // 時間帯が被っている場合
  if (b >= c && a <= d) {
    if (c <= a && d >= a && d <= b) {
      ans = d - a;
    } else if (c >= a && d <= b) {
      ans = d - c;
    } else if (c >= a && c <= b && d >= b) {
      ans = b - c;
    } else if (c <= a && d >= b) {
      ans = b - a;
    }
  }

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


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

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

vector<edge> tree[20];
bool visited[20];

int dfs1(int now)
{
    visited[now] = true;
    int sum = 0;

    for (auto e : tree[now])
    {
        if (tree[e.to].size() == 1)
            continue;

        if (visited[e.to])
            continue;

        sum += (dfs1(e.to) + e.cost * 2);
    }

    return sum;
}

int dfs2(int now)
{
    visited[now] = true;

    int sum = 0;

    for (auto e : tree[now])
    {
        if (tree[e.to].size() == 1)
            continue;
        if (visited[e.to])
            continue;

        sum = max(sum, dfs2(e.to) + e.cost);
    }

    return sum;
}

int main()
{

    int N;

    while (cin >> N && N)
    {
        rep(i, 20) tree[i].clear();

        rep(i, N - 1)
        {
            int a, b, c;
            cin >> a >> b >> c;

            a--;
            b--;

            tree[a].push_back({b, c});
            tree[b].push_back({a, c});
        }

        memset(visited, false, sizeof(visited));

        int cost1 = dfs1(0);

        memset(visited, false, sizeof(visited));

        int cost2 = dfs2(0);

        cout << cost1 - cost2 << endl;
    }

    return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, Q; cin >> N >> Q;
    string s; cin >> s;
    vector<char> T(Q), D(Q);
    for (int i = 0; i < Q; i++) cin >> T[i] >> D[i];
    auto simulate = [&](int x) {
        for (int i = 0; i < Q; i++) {
            if (s[x] == T[i]) {
                x += (D[i] == 'L' ? -1 : +1);
                if (x < 0) return -1;
                if (x >= N) return 1;
            }
        }
        return 0;
    };
    int A, B;
    {
        int ok = -1, ng = N;
        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            (simulate(mid) < 0 ? ok : ng) = mid;
        }
        A = ok;
    }
    {
        int ok = -1, ng = N;
        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            (simulate(mid) <= 0 ? ok : ng) = mid;
        }
        B = ok;
    }
    cout << (B - A) << endl;
    return 0;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long N, long long M){
    cout<<N*(N-1)/2+M*(M-1)/2<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#define ll int
#define MX 300000
using namespace std;
ll tr[4*MX+5],a[MX+5];
void update(ll pos,ll st, ll ed, ll x, ll val)
{
    if(st==ed && st==x)
    {
        tr[pos]=max(tr[pos],val);
        return;
    }
    ll mid = st+((ed-st)>>1);
    if(x<=mid)update(2*pos,st,mid,x,val);
    else update(2*pos+1,mid+1,ed,x,val);
    tr[pos]=max(tr[2*pos],tr[2*pos+1]);
}
ll query(ll pos, ll st, ll ed, ll l, ll r)
{
    if(st>r||ed<l)return 0;
    if(st>=l && ed<=r)
    {
        return tr[pos];
    }
    ll mid = st+((ed-st)>>1);
    return max(query(2*pos,st,mid,l,r),query(2*pos+1,mid+1,ed,l,r));
}
int main()
{
    ll n,k;
    cin >> n >> k;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
        a[i]++;
    }
    for(int i=1; i<=n; i++)
    {
        ll l = max(1, a[i]-k);
        ll r = min(300001, a[i]+k);
        ll p = query(1,1,300001,l,r);
        update(1,1,300001,a[i],p+1);
    }
    cout << query(1,1,300001,1,300001) << "\n";
    return 0;
}



Measured memory_bytes: 8904
#include<stdio.h>

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

char s[100];	

int max_between_len(char target) {
	int i = 0, res = 0, tmp = 0;
	while (s[i] != '\0') {
		if (s[i] == target) {
			res = max(res, tmp);
			tmp = 0;
		}
		else {
			tmp++;
		}
		i++;
	}
	res = max(res, tmp);
	return res;
}

int main(void) {
	int ans = 100;
	char c;
	scanf("%s", s);

	for (c = 'a'; c <= 'z'; c++) {
		int len = max_between_len(c);
		ans = min(ans, len);
	}

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n - 1));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n - 1; j++)
            cin >> a[i][j], a[i][j]--;

    vector<int> q;
    for (int i = 0; i < n; i++)
        if (a[a[i][0]][0] == i)
            q.push_back(i);

    vector<int> c(n);
    int res = 0;
    while (!q.empty())
    {
        res++;
        vector<int> q2;

        for (auto each : q)
        {
            c[each]++;
            if (c[each] < n - 1)
            {
                int x = a[each][c[each]];
                if (a[x][c[x]] == each)
                {
                    q2.push_back(x);
                    q2.push_back(each);
                }
            }
        }

        q = q2;
    }

    for (int i = 0; i < n; i++)
        if (c[i] < n - 1)
        {
            cout << "-1\n";
            return 0;
        }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>

using namespace std;

template<class T>
bool Linear_Search(vector<T> V, T x){
  int V_len = V.size();
  for(int i = 0; i < V_len; i++){
    if(V[i] == x) return true;
  }
  return false;
}

int main(){
  int n;
  cin >> n;
  vector<int> S;
  int x,i;
  for(i = 0; i < n; i++){
    cin >> x;
    S.push_back(x);
  }
  int q;
  cin >> q;
  vector<int> T;
  for(i=0; i < q; i++){
    cin >> x;
    T.push_back(x);
  }
  int count = 0;
  for(i = 0; i < q; i++){
    if(Linear_Search<int>(S,T[i])) count++;
  }

  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 3280
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef vector<int> VI;
typedef vector<long long> VLL;


int n, m;
string s;

int main() {
	cin >> n;
	cout << n * n * 3 << endl;
}

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

#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)

using lint = long int;
using llint = long long int;
using namespace std;

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

    int cnt = 0;
    for (size_t i = 0; i < s.size() - 2; i++) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
            cnt++;
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define N 9
void reads(string& x) {char kk[N]; scanf("%s", kk); x = kk;}

string s;

int main () {
    reads(s);
    if (s[2] == s[3] && s[4] == s[5]) {
        printf("%s\n", "Yes");
    } else {
        printf("%s\n", "No");
    }
    return 0;
}

Measured memory_bytes: 3648
from collections import defaultdict as dd
n = int(input())
A = list(map(int, input().split()))

L = dd(set)
R = dd(set)
for i, a in enumerate(A):
    x = i + a
    L[x].add(i)
    x = i - a
    R[x].add(i)

#print(L)
#print(R)

counter = 0
for num in list(set(L.keys()) & set(R.keys())):
    counter += len(L[num]) * len(R[num])

print(counter)

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;
#define debug(x) cerr << #x << ": " << (x) << "\n";

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
};

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k, x;
  cin >> k >> x;

  if (k * 500 >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
};


Measured memory_bytes: 256
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 100005;
const ll mm = 1e+18;
void solve()
{
    int n;
    cin>>n;
    cout<<(1000-n%1000)%1000;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}


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

int main() {
  int n,m,x;
  int sum=0;
  cin>>n>>m;
  for(int i=0;i<m;i++) {
    cin>>x;
    sum+=x;
  }
  if(sum<=n) {
    cout<<n-sum<<endl;
  }
  else {
    cout<<-1<<endl;
  }
  return 0;
}

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

using namespace std;

int main(){
	int n,k;
	int price[1001];
	int ans = 0;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> price[i];
	}
	sort(price, price+n);
	for(int i = 0; i < k; i++){
		ans += price[i];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>

#define LEFT_CHILD(i)	(((i) + 1) * 2 - 1)
#define RIGHT_CHILD(i)	(((i) + 1) * 2)
#define PARENT(i)		(((i) + 1) / 2 - 1)

void swap(unsigned long arr[], int i, int j){
  unsigned long tmp = arr[i];
  arr[i] = arr[j];
  arr[j] = tmp;
}

void add_elem(unsigned long arr[], int n){
  int n_parent;
  
  while(n > 0){
    n_parent = PARENT(n);
    
    if(arr[n] > arr[n_parent]){
      swap(arr, n, n_parent);
    }else{
      break;
    }
    
    n = n_parent;
  }
}

void renew_arr(unsigned long arr[], int n_elems){
  int n = 0; 
  int n_left, n_right;
  int n_bigger;
  
  for(;;){
    n_left = LEFT_CHILD(n);
    n_right = RIGHT_CHILD(n);
    
    if(n_left >= n_elems){
      break;
    }else if(n_right >= n_elems){
      n_bigger = n_left;
    }else{
      n_bigger = (arr[n_left] > arr[n_right]) ? n_left : n_right;
    }
    
    if(arr[n] < arr[n_bigger]){
      swap(arr, n, n_bigger);
    }else{
      break;
    }
    
    n = n_bigger;
  }
}

int main(){
  int n_goods, n_tickets;
  scanf("%d %d", &n_goods, &n_tickets);
  
  unsigned long *price_goods;
  price_goods = (unsigned long *)malloc(n_goods*sizeof(unsigned long));
  
  int i;
  for(i=0; i<n_goods; i++){
    scanf("%lu", &price_goods[i]);    
    add_elem(price_goods, i);
  }
  
  while(n_tickets > 0){
    price_goods[0] /=2;
    
    renew_arr(price_goods, n_goods);
    n_tickets--;
  }
  
  unsigned long sum = 0;
  for(i=0; i<n_goods; i++){
    sum += price_goods[i];
  }
  printf("%lu", sum);
}


Measured memory_bytes: 896
#### import ####
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):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

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

N = I()
V = III()
C = III()
ans = 0

for i in range(N):
    if V[i]>C[i]:
        ans += V[i]-C[i]
    
print(ans)

Measured memory_bytes: 38384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = 0;
			while ((n = int.Parse(Console.ReadLine())) != 0)
			{
				var ns = new List<int>();
				while (n-- != 0)
					ns.Add(int.Parse(Console.ReadLine()));
				int count = 0;
				for (int i = 0; i < ns.Count - 1; i++)
				{
					for (int j = ns.Count - 1; j > i; j--)
					{
						if (ns[j] < ns[j - 1])
						{
							int tmp = ns[j];
							ns[j] = ns[j - 1];
							ns[j - 1] = tmp;
							count++;
						}
					}
				}
				Console.WriteLine(count);
			}
		}
	}
}

Measured memory_bytes: 5680
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    ll n,k,a[10001],b[10001]={},c[10000]={},ans=0;
    map<ll,ll> mp;
    cin>>n>>k;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }
    rep(i,n){
        rep(j,i){
            if(a[j]>a[i]) b[i]++;
        }
        rep(j,n){
            if(a[j]>a[i]) c[i]++;
        }
    }
    rep(i,n){
        ans+=((b[i]*k%MOD)+(c[i]*(((k-1)*k)/2%MOD))%MOD)%MOD;
        ans%=MOD;
    }
    cout<<ans%MOD<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<Pii> xl(n);
  for (auto &x: xl) cin >> x.first >> x.second;

  vector<Pii> ab(n);
  for (int i = 0; i < n; i++) ab[i] = Pii(xl[i].first - xl[i].second, xl[i].first + xl[i].second);

  priority_queue<Pii, vector<Pii>, greater<Pii> > que;
  for (int i = 0; i < n; i++) que.emplace(ab[i].second, ab[i].first);
  int last = -1000000007;
  int ans = 0;
  while (!que.empty()) {
    auto now = que.top();
    que.pop();
    if (last <= now.second) {
      ans++;
      last = now.first;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2936
n, a, b, c, d = map(int, input().split())
# まずa本セットの方でいくらで買うことができるか確認する
if n % a == 0:
    s = n // a
else:
    s = n // a + 1
moneyA = s * b
# c本セットの方の値段も調べる
if n % c == 0:
    s = n // c
else:
    s = n // c + 1
moneyB = s * d
if moneyA <= moneyB:
    print(moneyA)
else:
    print(moneyB)


Measured memory_bytes: 5596
#include<stdio.h>
int make(int *,int);
void rec (int);
int solve(int ,int);
int x,a[20];
int main(){
  int b[200],y,i;
  scanf("%d",&x);
  for(i=0;i<x;i++)
    scanf("%d",&a[i]);
  //make(a,x);
  scanf("%d",&y);
  for(i=0;i<y;i++){
    scanf("%d",&b[i]);
    if((solve(0,b[i]))==1)
      printf("yes\n");
    else printf("no\n");
  }
  return 0;
}
/*int make(int *a){
  int i;
  for(i=0;i<x;i++)
    a[i]=0;
  rec(0);
}
void rec(i){
  if(i==x){
    printf("%d\n",s[i]);
    return ;
  }
  rec(i+1);
  s[i]=1;
  rec(i+1);
  s[i]=0;
  }*/
int solve(int i,int m){
  int res;
  if(m==0)
    return 1;
  if(i>=x)
    return 0;
  res=solve(i+1,m) || solve(i+1,m-a[i]);
  return res;
}



Measured memory_bytes: 2048
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;
const int M = 11;

int n;
int m;
int K[M];
int p[M];
int s[M][M];

int main(){
    scanf("%d%d" , &n , &m);
    for(int i = 1; i <= m; i++){
        int x;
        scanf("%d" , &x);
        K[i] = x;
        for(int j = 1; j <= x; j++){
            scanf("%d" , &s[i][j]);
        }
    }
    for(int i = 1; i <= m; i++){
        scanf("%d" , &p[i]);
    }
    int ways = 0;
    for(int mask = 0; mask < (1 << n); mask++){
        // we will switch on this mask "switches"
        int ison = 0;
        for(int i = 1; i <= m; i++){
            int switchesonme = 0;
            for(int j = 1; j <= K[i]; j++){
                if(mask & (1 << (s[i][j]-1)))
                    switchesonme++;
            }
            if(p[i] == switchesonme % 2)
                ison++;
        }
        if(ison == m)
            ways++;
    }
    printf("%d\n" , ways);
}


Measured memory_bytes: 256
from itertools import permutations

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

allp = p.copy()
allp.sort()
allperms = list(map(list, permutations(allp)))
print(abs(allperms.index(p) - allperms.index(q))) 


Measured memory_bytes: 10228
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007 
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   long long n;
   cin>>n;
  
   long long x[n];
   long long y[n];
   long long z[n];
   long long w[n];
   
   for(int i=0;i<n;i++){
       long long l,r;
    cin>>l>>r;
    x[i]=l+r;
    y[i]=l-r;
    z[i]=r-l;
    w[i]=-l-r;
   }
   sort(x,x+n);
   sort(y,y+n);
   sort(z,z+n);
   sort(w,w+n);
   cout<<max({x[n-1]-x[0],y[n-1]-y[0],w[n-1]-w[0],z[n-1]-z[0]})<<"\n";
   
   
   
  
   

   
}


Measured memory_bytes: 9904
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;
    sort(_all(a));
 
    ll res = a[n - 1] - a[0];
    rep(i, n / 2 - 1){
        res += a[n-1 - i - 1] - a[i];
        res += a[n-1 - i] - a[i + 1];
    }
    if(n % 2 == 1){
        res += max(a[n/2] - a[n/2 - 1], a[n/2 + 1] - a[n/2]);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 640
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long W = sc.nextLong();
		long[] w = new long[N];
		long[] v = new long[N];
		ArrayList<Long>[] lis = new ArrayList[4];
		for (int i = 0; i < 4; ++i)
			lis[i] = new ArrayList<>();
		for (int i = 0; i < N; ++i) {
			w[i] = sc.nextLong();
			v[i] = sc.nextLong();
			lis[(int) (w[i] - w[0])].add(-v[i]);
		}
		for (int i = 0; i < 4; ++i) {
			Collections.sort(lis[i]);
		}

		long[][] value = new long[4][];
		for (int i = 0; i < 4; ++i) {
			value[i] = new long[lis[i].size() + 1];
			for (int j = 0; j < lis[i].size(); ++j) {
				value[i][j + 1] = value[i][j] + (-lis[i].get(j));
			}
		}
		long ans = 0;
		for (int i = 0; i <= lis[0].size(); ++i) {
			for (int j = 0; j <= lis[1].size(); ++j) {
				for (int k = 0; k <= lis[2].size(); ++k) {
					for (int l = 0; l <= lis[3].size(); ++l) {
						if (w[0] * (i + j + k + l) + j + 2 * k + 3 * l > W)
							continue;
						ans = Math.max(ans, value[0][i] + value[1][j] + value[2][k] + value[3][l]);
					}
				}
			}
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 24532
import math
n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]

def explode(x):
    global n
    c=0
    for i in range(n):
        if h[i]-x*b>0:
            c+=math.ceil((h[i]-x*b)/(a-b))
    return c<=x

#二分探索用のコード

#(1)l,rは両端点でl<=r
l,r=1,10**9
#(2)l=rもしくはl=r-1のときにbreak
while l+1<r:
    #(3)その閉区間の中点(の小数部分を切り捨てたもの)
    #オーバーフローを考慮すると以下の書き方になる
    k=l+(r-l)//2
    #ここでは境目以上のxで真になるので、
    #x=kで真の場合は大きい方の端点をkにし、x=kで偽の場合は小さい方の端点をkにする
    if explode(k):
        r=k
    else:
        l=k

print(l if explode(l) else r)

Measured memory_bytes: 7088
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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 (b<a) { a = b; return 1; } return 0; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

ll a, b, c, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> a >> b >> c >> k;
    if (abs(a - b) >= (ll)1e18) cout << "Unfair" << endl;
    else if (k % 2 == 0) cout << a - b << endl;
    else cout << b - a << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct R{int a,b;}a[100050];
int n,m,f[100050];
int F(int x){return x==f[x]?x:f[x]=F(f[x]);}
bool cmp(R a,R b){return a.a>b.a;}
int main()
{
	cin>>n>>m;
	m++;
	for(int i=1;i<=m;i++)f[i]=i;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i].b,&a[i].a);
		a[i].b=m-a[i].b;
	}
	long long ans=0;
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		if(a[i].b<=0)continue;
		int d=F(a[i].b);
		if(d==0)continue;
		f[d]=F(d-1);
		ans+=a[i].a;
	}
	cout<<ans;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        String S = scan.next();
        int R = 0, B = 0;
        for (int i = 0; i < N; i++) {
            if (S.charAt(i) == 'R') {
                R++;
            } else {
                B++;
            }
        }
        if (R > B) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int main(int argc, char const *argv[])
{
	int k;
	cin>>k;
	set<pair<double,long long>> ans;
	for (int i = 1; i < 10000; ++i)
	{
		long long now=(long long)i,s=0LL;
		while (now>0LL)
		{
			s+=now%10LL;
			now/=10LL;
		}
		ans.insert({(double)i/s,i});
	}
	long long r=9LL;
	for (int i = 0; i < 12; ++i)
	{
		for (int j = 0; j < 10000; ++j)
		{
			long long now1=(long long)j*(r+1LL)+r,now2=now1,s=0LL;
			while (now1>0LL)
			{
				s+=now1%10LL;
				now1/=10LL;
			}
			ans.insert({(double)now2/s,now2});
		}
		r*=10LL;
		r+=9LL;
	}
	long long tmp=0LL;
	for (auto i = ans.begin(); i != ans.end(); ++i)
	{
		auto p=*i;
		if (p.second>tmp)
		{
			tmp=p.second;
			cout<<p.second<<endl;
			--k;
			if (k==0)
			{
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 7680
#!ruby --jit
require "set"

h, w, m = gets.split.map &:to_i

hs = [0] * h
ws = [0] * w
vs = Set.new

m.times do
  i, j = gets.split.map &:to_i
  hs[i-1] += 1
  ws[j-1] += 1
  vs << (i-1)*w+j-1
end

hmax = hs.max
wmax = ws.max

i_s = (0...h).select { |i| hs[i] == hmax }
j_s = (0...w).select { |j| ws[j] == wmax }

max = 0
i_s.each do |i|
  j_s.each do |j|
    unless vs.include? i*w+j
      p hmax + wmax
      exit
    end
  end
end

p hmax + wmax - 1


Measured memory_bytes: 37868
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll N, M;
  cin >> N >> M;
  map<ll, set<pair<ll, int>>> mp;
  rep(i, M) {
    ll P, Y;
    cin >> P >> Y;
    mp[P].insert(mp(Y, i));
  }
  
  vector<string> v(M);
  for(auto mm : mp) {
    int i = 1;
    for(auto s : mm.second) {
      ostringstream ss;
      ss << setw(6) << setfill('0') << mm.first;
      ss << setw(6) << setfill('0') << i;
      v[s.second] = ss.str();
      i++;
    }
  }
  
  for(auto s : v) {
    fin(s);
  }

}

Measured memory_bytes: 22528
n, m, x = gets.chomp.split(" ").map {|c| c.to_i}
clist = []
alist = []
n.times do |i|
  line = gets.chomp.split(" ").map {|c| c.to_i}
  clist.push line.shift
  alist.push line
end

min_cost = clist.sum + 1
(2**n).times do |i|
  ilen = i.bit_length
  i_total_points = Array.new(m, 0)
  i_cost = 0
  ilen.times do |pos|
    if i[pos] != 0
      m.times do |j|
        i_total_points[j] += alist[pos][j]
      end
      i_cost += clist[pos]
    end
  end

  if i_total_points.all? {|v| v >= x} \
      and i_cost < min_cost
    min_cost = i_cost
  end
end

if min_cost == clist.sum + 1
  puts "-1"
else
  puts min_cost
end

Measured memory_bytes: 14624
N = gets.to_i
A = []
N.times { A << gets.to_i }

max = A.max
max_index = A.find_index(max)
A.delete_at(max_index)
max2 = A.max

N.times do |i|
  if i == max_index
    puts max2
  else
    puts max
  end
end

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end

typedef pair<int,int> P;

int main(){
   int x,y,a,b,c; cin>>x>>y>>a>>b>>c;
   vector<P> apple;
   rep(i,0,a){
      int tmp; cin>>tmp;
      apple.push_back({tmp,0});
   }
   rep(i,0,b){
      int tmp; cin>>tmp;
      apple.push_back({tmp,1});
   }
   rep(i,0,c){
      int tmp; cin>>tmp;
      apple.push_back({tmp,2});
   }
   sort(ALL(apple),greater<P>());
   int cntx=0,cnty=0,cntz=0; ll res=0;
   rep(i,0,a+b+c){
      if(cntx<x&&cntx+cnty+cntz<x+y&&apple[i].second==0){cntx++; res+=apple[i].first;}
      if(cnty<y&&cntx+cnty+cntz<x+y&&apple[i].second==1){cnty++; res+=apple[i].first;}
      if(cntx+cnty+cntz<x+y&&apple[i].second==2){cntz++; res+=apple[i].first;}
   } printf("%lld\n",res);
   return 0;
}

Measured memory_bytes: 6128