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

using namespace std;

using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll f = 0;
  int ans = 0;
  int l = 0, r = 0;
  ll ret = 0;
  for (int l = 0; l < n; l++) {
    for (; r < n; ++r) {
      for (int i = 0; i < 21; ++i) {
        if ((a[r] >> i) & 1 && (f >> i) & 1) {
          goto BREAK;
        }
      }
      f += a[r];
      ans++;
      ret += ans;
    }
  BREAK:
    ans--;
    f -= a[l];
  }
  cout << ret << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){
  char s[100];
  scanf("%s",s);
  int n=0;
  int i,yes=0;

  for(i=0;s[i]!='\0';i++)
    n++;
  for(i=0;i<(n-1)/2;i++){
    //printf("%c %c\n",s[i],s[n-1-i]);
    if(s[i]!=s[n-1-i])
      break;
    if(i==((n-1)/2)-1)
      yes++;
  }
  for(i=0;i<(n-1)/2;i++){
    //printf("%c %c\n",s[i],s[((n-1)/2)-(1+i)]);
    if(s[i]!=s[((n-1)/2)-(1+i)])
      break;
    if(i==((n-1)/2)-1)
      yes++;
  }
  
  if(yes==2)
    printf("Yes");
  else
    printf("No");
}

Measured memory_bytes: 128
function main()
    N = parse(Int, readline())
    a = parse.(Int, split(readline()))

    ans = 0
    for i in 1:length(a)-1
        if a[i+1] < a[i]
            ans += a[i] - a[i+1]
            a[i+1] = a[i] 
        end
    end
    println(ans)
end

main()

Measured memory_bytes: 198776
fun main(args: Array<String>){
    val maxQ = 100000
    val f = BooleanArray(maxQ + 1){ true }
    f[0] = false
    f[1] = false
    for(i in 2..maxQ){
        if(f[i]){
            for(j in 2*i..maxQ step i){
                f[j] = false
            }
        }
    }
    val sum = IntArray(maxQ + 1)
    for(i in 1..maxQ){
        sum[i] = sum[i - 1] + if(f[i] && f[(i+1) / 2]) 1 else 0
    }

    val Q = readLine()!!.toInt()
    repeat(Q){
        val (L, R) = readLine()!!.split(" ").map { it.toInt() }
        println(sum[R] - sum[L - 1])
    }
}

Measured memory_bytes: 56464
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

intmax_t f(const std::vector<intmax_t>& pos,
           const std::vector<intmax_t>& neg, size_t K) {

  intmax_t res = 1e14;
  for (size_t i = 0; i <= K; ++i) {
    size_t j = K-i;
    if (i >= pos.size()) break;
    if (j >= neg.size()) continue;
    res = std::min(res, 2*pos[i]+neg[j]);
  }
  return res;
}

int main() {
  size_t N, K;
  scanf("%zu %zu", &N, &K);

  std::vector<intmax_t> neg, pos{0};
  for (size_t i = 0; i < N; ++i) {
    intmax_t x;
    scanf("%jd", &x);
    if (x < 0) {
      neg.push_back(-x);
    } else if (x > 0) {
      pos.push_back(x);
    } else {
      --K;
    }
  }
  neg.push_back(0);
  std::reverse(neg.begin(), neg.end());

  if (K == 0)
    return puts("0"), 0;

  intmax_t res = std::min(f(neg, pos, K), f(pos, neg, K));
  printf("%jd\n", res);
}


Measured memory_bytes: 1656
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

//各種nil
template <class T>
constexpr T nil = static_cast<T>(-1);

constexpr int nil_i = nil<int>;
constexpr int nil_ll = nil<ll>;
constexpr double nil_d = nil<double>;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
struct Vec2D
{
    T x, y;
};

int SumOfDigits(int n)
{
    int sumOfDigits {};

    while (n > 0)
    {
        sumOfDigits += n % 10;
        n /= 10;
    }

    return sumOfDigits;
}

void solve()
{
    using namespace std;
    int n; cin >> n;
    
    if (n % SumOfDigits(n) == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;



}

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

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int T1, T2;
        Int A1, A2;
        Int B1, B2;
        cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
        Int P = T1 * (B1 - A1);
        Int Q = T2 * (B2 - A2);

        if (P + Q == 0ll) {
            cout << "infinity" << endl;
            return;
        }
        if (P < 0) {
            P = -P;
            Q = -Q;
        }
        if (P + Q > 0) {
            cout << 0 << endl;
            return;
        }
//        if ((P >= 0 && Q >= 0) || (P <= 0 && Q <= 0)) {
//            cout << 0 << endl;
//            return;
//        }

        Int dec = -(P + Q);


        Int ans = (P / dec + 1) * 2 - 1;

        if (P % dec == 0) ans--;
        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  llong ans=0;

  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];

  SORT(a);
  REP(i,n-1) {
    if (a[i]<0) {
      a[i]*=-1;
      a[i+1]*=-1;
    }
  }
  SORT(a);
  if (abs(a[0])>abs(a[1])) {
    a[0]*=-1;
    a[1]*=-1;
  }
  REP(i,n) {
    ans += a[i];
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef int LL;
const LL maxn=59,Maxn=1e7+9,inf=0x3f3f3f3f;
inline LL Read(){
    LL x(0),f(1); char c=getchar();
    while(c<'0' || c>'9'){
        if(c=='-') f=-1; c=getchar();
    }
    while(c>='0' && c<='9'){
        x=(x<<3)+(x<<1)+c-'0'; c=getchar();
    }return x*f;
}
LL A,ret;
int main(){
	A=Read(); ret=Read();
	ret+=A*3;
	printf("%d\n",ret/2);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define N 1000001
using namespace std;
 
int n,m;
long long pnt[N]={},a,b[300000],c[300000];
 
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    pnt[a]++;
  }
 
  for(int i=0;i<N;i++) pnt[i]=pnt[i]*i;
  for(int i=1;i<N;i++)pnt[i]+=pnt[i-1];
 
  cin>>m;
  for(int i=0;i<m;i++)cin>>b[i];
  for(int i=0;i<m;i++) cin>>c[i];
 
   for(int i=0;i<m;i++){
    if(pnt[b[i]]>=c[i]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
 
  return 0;
}

Measured memory_bytes: 13660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 vector<int> vec(3); cin >> vec[0] >> vec[1] >> vec[2];
  sort(vec.begin(),vec.end());
  if( vec[0]+vec[1] == vec[2]){ cout << "Yes" << endl;}
  else{ cout << "No" << endl;}
  return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
void solve()
{
	int a, b;
	cin >> a>>b;
	cout << max(0, a - 2 * b);
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val o = sc.next()
    val e = sc.next()
    println(problem058b(o, e))
}

fun problem058b(o: String, e: String): String {
    val length = Math.max(o.length, e.length)
    var result = ""
    (0 until length).forEach { i ->
        if (o.length > i) {
            result += o[i]
        }
        if (e.length > i) {
            result += e[i]
        }
    }
    return result
}

Measured memory_bytes: 31260
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func permutation(n int, k int) int {
	v := 1
	if 0 < k && k <= n {
		for i := 0; i < k; i++ {
			v *= (n - i)
		}
	} else if k > n {
		v = 0
	}
	return v
}

func factorial(n int) int {
	return permutation(n, n-1)
}

func combination(n int, k int) int {
	return permutation(n, k) / factorial(k)
}

func homogeneous(n int, k int) int {
	return combination(n+k-1, k)
}


func main() {
	N := oneInt()
	D := oneInt()

	ra := D*2 + 1
	ans := N / ra

	if N%ra > 0 {
		ans = ans + 1
	}

	fmt.Print(ans)
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	cout << a[N-1] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	ll N, D;
	cin >> N >> D;
	ll ans = 0;
	for(int i = 0; i < N; i++){
		ll X, Y;
		cin >> X >> Y;
		if(X*X + Y*Y <= D*D){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

signed main(){
  int K,N;
  cin>>K>>N;
  if(K%N!=0)cout<<'1'<<endl;
  else cout<<'0'<<endl;
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if (a<=0 && b>=0) return cout<<"Zero",0;
	b=min(b,-1);
	if (a>b || (b-a+1)%2==0) return cout<<"Positive",0;
	cout<<"Negative";
}

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

void display( std::vector<int> A ){
    for( int i = 0; i < A.size(); i++ ){
      std::cout << A[i];
      if( i < A.size()-1 ) std::cout << " ";
      else std::cout << std::endl;
  }
}

int bubblesort( std::vector<int>& A, int N ){
  int cnt = 0;
  for( int i = 1; i < N; i++ ){
    for( int j = i; j > 0; j-- ){
      if( A[j-1] > A[j] ){
        std::swap( A[j], A[j-1] );
        cnt++;
      } else  break;
    }
  }
  return cnt;
}

int selectionSort( std::vector<int>& A, int N ){
  int cnt = 0;
  for( int i = 0; i < N-1; i++ ){
    int minj = i;
    for( int j = i+1; j < N; j++ ){
      if( A[minj] > A[j] ){
        minj = j;
      }
    }
    if( i != minj ){
      std::swap( A[minj], A[i] );
      cnt++;
    }
  }
  return cnt;
}

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for( auto &a : A ) std::cin >> a;

  int cnt = selectionSort( A, N );

  display( A );

  std::cout << cnt << std::endl;

}



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

using namespace std;

typedef long long ll;
int main()
{
    int n;  cin >> n;
    unordered_map<string, int> mp;
    while (n--)
    {
        string cad; cin >> cad;
        mp[cad]++;
    }
    cout << "AC x " << mp["AC"] << "\n";
    cout << "WA x " << mp["WA"] << "\n";
    cout << "TLE x " << mp["TLE"] << "\n";
    cout << "RE x " << mp["RE"] << "\n";
}



Measured memory_bytes: 3560
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
def main():
    A, B, C, D = [int(n) for n in input().split()]
    min_c = A // C if A % C == 0 else (A // C)+1
    max_c = B // C if B % C == 0 else (B // C)
    min_d = A // D if A % D == 0 else (A // D)+1
    max_d = B // D if B % D == 0 else (B // D)
    pro = lcm(C, D)
    min_pro = A // (pro) if A % (C*D) == 0 else (A // (pro))+1
    max_pro = B // (pro) if B % (C*D) == 0 else (B // (pro))
    

    print((B-A+1) - (max_c-min_c+1) - (max_d-min_d+1) + (max_pro-min_pro + 1))
main()



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

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n;
int h[N];

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }
    int mn = -1e9;
    for(int i = 1; i <= n; i++){
        if(h[i - 1] > h[i]){
            puts("No");
            return 0;
        }
        if(h[i - 1] <= h[i] - 1 && h[i] - 1 >= 1)
            h[i] = h[i] - 1;
    }
    puts("Yes");
}


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

using namespace std;

int
main(void){
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int x = tx - sx;
	int y = ty - sy;
	for(int i = 0; i < x; i++) cout << "R";
	for(int i = 0; i < y; i++) cout << "U";
	
	for(int i = 0; i < x; i++) cout << "L";
	for(int i = 0; i < y; i++) cout << "D";
	
	cout << "D";
	for(int i = 0; i < x + 1; i++) cout << "R";
	for(int i = 0; i < y + 1; i++) cout << "U";
	cout << "L";
	cout << "U";
	for(int i = 0; i < x + 1; i++) cout << "L";
	for(int i = 0; i < y + 1; i++) cout << "D";
	cout << "R";
}

Measured memory_bytes: 256
s = input()

if len(s)<26:
        st = set(s)
        for c in "abcdefghijklmnopqrstuvwxyz":
                if not c in st:
                        print(s+c)
                        break
        else: print(-1)
else:
        prev = ord('a') - 1
        i = len(s)
        for c in s[::-1]:
                if ord(c)>prev: i -= 1
                else: break
                prev = ord(c)
        if i==0: print(-1)
        else:
                for c in sorted(s[i-1:]):
                        if ord(c)>ord(s[i-1]):
                                print(s[:i-1] + c)
                                break

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
ll dp[N],n;
signed main()
{
	Very_fast;
	cin>>n;
	dp[0]=1;
	for(int i=0;i<=n;i++)
	{
		for(int j=3;j<=i;j++)
		{
			dp[i]=(dp[i]+dp[i-j])%mod;
		}
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 3640
// 5/14
// 過去問ガリガリ
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    int N, M;
    cin >> N >> M;

    if (N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer k = Integer.parseInt(scanner.next());
        Integer x = Integer.parseInt(scanner.next());

        Integer range =  k - 1;

        if (k == 1) {
            System.out.println(x);
            System.exit(0);
        }

        String sum = new String();
        Integer start = x - range;
        Integer end = x + range;

        while(start <= end) {
            sum += start.toString() + " ";
            start++;
        }

        System.out.println(sum.trim());
    }
}

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

int main () {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  bool u = false, d = false;
  int count = 1;
  for(int i = 0; i < N-1; i++) {
    if (u == false && d == false && a.at(i) < a.at(i+1)) u = true;
    else if (u == false && d == false && a.at(i) > a.at(i+1)) d = true;
    else if (u == true && a.at(i) > a.at(i+1)) {
      count++;
      u = false;
    }
    else if (d == true && a.at(i) < a.at(i+1)) {
      count++;
      d = false;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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

int main()
{
  string s;
  cin >> s;
  REP(i,sz(s)-1){
    if(s[i]==s[i+1]){
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
  }
  REP(i,sz(s)-2){
    if(s[i]==s[i+2]){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<59)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

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

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>ar[i];
	int col = 1;
	MOSI ofdx;
	for(int i=0;i<n;i++)
	{
		auto it = ofdx.find_by_order(ofdx.order_of_key(ar[i])-1);
		ofdx.erase(it);
		ofdx.ins(ar[i]);	
	}
	cout<<(int)ofdx.sz()<<"\n";
	return;	
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 5376
#include                        <bits/stdc++.h>
#include                        <ext/pb_ds/assoc_container.hpp>
#define lb                      lower_bound
#define ub                      upper_bound
#define pb(x)                   push_back((x))
#define pb2(x,y)                push_back({x,y})
#define pb3(x,y,z)              push_back({x,y,z})
#define load(node,n)            bool operator < (const node &n) const
#define fbo(x)                  find_by_order(x)
#define ook(x)                  order_of_key(x)
#define all(x)                  (x).begin(),(x).end()
#define FOR(i,n)                for(int i = 1; i<=n; i++)
#define REP(i,n)                for(int i = 0; i<n;  i++)
#define dbg(a)                  cout<<#a <<" --> "<<(a)<<endl;
#define TT                      int TC;  scanf("%d",&TC);  while(TC--)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define set(x)                  tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
#define IO                        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using                           namespace std;
using                           namespace __gnu_pbds;
typedef                         long long ll;
typedef                         pair<ll,ll> pll;
typedef                         pair<int,int> pii;
#define mx 100005
ll x,y,a,b,p[mx],q[mx],r[mx],c;
vector<ll> v;

main(){
//read;
IO;

cin>>x>>y>>a>>b>>c;
REP(i,a)    cin>>p[i];
REP(i,b)    cin>>q[i];
REP(i,c)    cin>>r[i];
sort(p,p+a);
sort(q,q+b);
ll ans = 0;
for(ll i = 0; i<x; i++) v.pb(p[a-1-i]);
for(ll i = 0; i<y; i++) v.pb(q[b-1-i]);
for(ll i = 0; i<c; i++) v.pb(r[i]);
sort(all(v));
reverse(all(v));
for(ll i = 0; i<x+y; i++)   ans+=v[i];
cout<<ans;

return 0;
}



Measured memory_bytes: 8560
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(N == 1) {
			System.out.println("Hello World");
		}else if(N == 2) {
			int A = sc.nextInt();
			int B = sc.nextInt();
			System.out.println(A + B);
		}
	}
}


Measured memory_bytes: 21972
#ifndef DEBUG
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,popcnt,tune=native")
#endif // DEBUG
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <stack>
using namespace std;
typedef long long ll;
inline ll read()
{
    int ch=getchar(),f=1;
    ll ans=0;
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=0;
    for(;ch>='0'&&ch<='9';ch=getchar())
        ans=(((ans<<2)+ans)<<1)+(ch^'0');
    return f?ans:-ans;
}
const int maxn=100005;
char s[maxn];
char t[maxn];
int n,m;
vector<int> pos[100];

int main()
{
    scanf("%s%s",s+1,t+1);
    n=strlen(s+1);
	m=strlen(t+1);
	for(int i=1;i<=n;i++)
        pos[s[i]-'a'].push_back(i);
	for(int i=1;i<=n;i++)
        pos[s[i]-'a'].push_back(i+n);
    for(int i=0;i<26;++i)
        pos[i].push_back(0x3f3f3f3f);
    ll ans=0;
	int now=0;
	for(int i=1;i<=m;i++)
	{
	    int c=t[i]-'a';
		int nxt=*upper_bound(pos[c].begin(),pos[c].end(),now);
		if(nxt==0x3f3f3f3f)
		{
			puts("-1");
			return 0;
		}
		now=nxt;
		if(now>n)ans+=n,now-=n;
	}
	printf("%lld\n",ans+now);
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

vvi to;
v(bool) used;
vi vs;

void dfs(int k) {
  used[k]=true;
  for(int t:to[k]) {
    if(!used[t]) {
      dfs(t);
    }
  }
  vs.push_back(k);
}
  
int main() {
  int N,M;
  cin >> N >> M;
  to = vvi(N+1);
  used = v(bool)(N+1,false);
  rep(i,N+M-1) {
    int a,b;
    cin >> a >> b;
    to[a].push_back(b);
  }
  srep(i,1,N+1) {
    if(!used[i]) {
      dfs(i);
    }
  }
  reverse(rng(vs));
  vi ans(N+1,0);
  for(int n:vs) {
    for(int t:to[n]) {
      ans[t] = n;
    }
  }
  srep(i,1,N+1) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 10360
card = input().split(" ")
turn = int(input())

red = int(card[0])
green = int(card[1])
blue = int(card[2])

for i in range(turn):
  if green <= red:
    green = green*2
  elif blue <= green:
    blue = blue*2

if green > red and blue > green:
  print("Yes")
else:
  print("No")



Measured memory_bytes: 9168
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2e5+10;
int n,bin[N],a,ans;
int main()
{
	int i;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	  scanf("%d",&a),bin[a-1]++,bin[a]++,bin[a+1]++;
	for (i=0;i<=2e5;i++)  ans=max(ans,bin[i]);
	printf("%d",ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    ll asum = 0;
    ll bsum = 0;
    rep(i, n) {cin >> a[i]; asum+=a[i];}
    rep(i, n) {cin >> b[i]; bsum+=b[i];}

    ll act = bsum-asum;
    if (act < 0) {cout << "No" << endl; return 0;}

    ll need_act = 0;
    rep(i, n){
        if (a[i] > b[i]){
            need_act += a[i]-b[i];
        } else if ((b[i]-a[i])%2 == 1){
            need_act += 1;
        }
    }
    if (need_act > act) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<string.h>
#include<iostream>
using namespace std;
int m, n;
int main(){
	scanf("%d %d", &m, &n);
	if(m == 1 && n == 1) puts("Draw");
	else if(m == 1) puts("Alice");
	else if(n == 1) puts("Bob");
	else if(m > n) puts("Alice");
	else if(m == n) puts("Draw");
	else if(m < n) puts("Bob");


}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<bitset>
#define MN 100
#define ull unsigned long long
#define F(a,b,c,d) ((a>b||c>d)?ans:f[num[a][b]][num2[c][d]])
#define N 65535
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
char st[MN+5][MN+5];
int f[5505][5505],num[MN+5][MN+5],num2[MN+5][MN+5],n,m,ans,cnt[1<<16],s[MN+5][MN+5];
inline void R(int&x,int y){y>x?x=y:0;}
/*struct Bitset
{
    ull a,b;
    Bitset(){a=b=0;}
    Bitset(ull c,ull d):a(c),b(d){}
    void Mod(int y){y>=64?(b|=1ULL<<y-64):(a|=1ULL<<y);}
    Bitset operator & (const Bitset&c){return Bitset(a&c.a,b&c.b);}
    int Count(){return cnt[a&N]+cnt[a>>16&N]+cnt[a>>32&N]+cnt[a>>48&N]
                      +cnt[b&N]+cnt[b>>16&N]+cnt[b>>32&N]+cnt[b>>48&N];}
    Bitset operator << (int y){return y>=64?Bitset(0,a<<y-64):Bitset(a<<y,b<<y|(a>>64-y));}
};*/
bitset<105> lru[MN+5][MN+5],lrd[MN+5][MN+5],udl[MN+5][MN+5],udr[MN+5][MN+5],a[MN+5],b[MN+5];
inline int C(int u,int l,int d,int r){return s[d][r]-s[u-1][r]-s[d][l-1]+s[u-1][l-1];}
int main()
{
    for(int i=1;i<=N;++i) cnt[i]=cnt[i>>1]+(i&1);
    n=read();m=read();
    for(int i=1,k=0;i<=n;++i)for(int j=i;j<=n;++j)num[i][j]=++k;
    for(int i=1,k=0;i<=m;++i)for(int j=i;j<=m;++j)num2[i][j]=++k;
    for(int i=1;i<=n;++i) scanf("%s",st[i]+1);
    for(int i=1;i<=n;++i) for(int j=1;j<=m;++j)
    {
        if(st[i][j]=='o') a[i][j]=1,b[j][i]=1;
        s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(st[i][j]=='E');
    }
    for(int i=1;i<=m;++i) for(int j=1;j<=n;++j)
        for(int k=1;k<=i;++k)
        {
            if(C(1,k,n-j+1,m-(i-k))) lru[i][j][k]=1;
            if(C(j,k,n,m-(i-k)))     lrd[i][j][k]=1;
        }
    for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)
        for(int k=1;k<=i;++k)
        {
            if(C(k,1,n-(i-k),m-j+1)) udl[i][j][k]=1;
            if(C(k,j,n-(i-k),m))     udr[i][j][k]=1;
        }
    for(int i=1;i<=n;++i) for(int j=n;j>=i;--j)
        for(int k=1;k<=m;++k) for(int l=m;l>=k;--l)
        {
            int v=F(i,j,k,l);
            R(F(i+1,j,k,l),v+(a[i]&(lru[l-k+1][j-i+1]<<k-1)).count());
            R(F(i,j-1,k,l),v+(a[j]&(lrd[l-k+1][j-i+1]<<k-1)).count());
            R(F(i,j,k+1,l),v+(b[k]&(udl[j-i+1][l-k+1]<<i-1)).count());
            R(F(i,j,k,l-1),v+(b[l]&(udr[j-i+1][l-k+1]<<i-1)).count());
        }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 110848
N,A,B,C=gets.split.map &:to_i
L=N.times.map{gets.to_i}
I=1<<30

def dfs(cur, a, b, c)
	if cur==N
		return [a,b,c].min>0 ? (a-A).abs+(b-B).abs+(c-C).abs-30 : I
	end
	[
		dfs(cur + 1, a, b, c),
		dfs(cur + 1, a + L[cur], b, c) + 10,
		dfs(cur + 1, a, b + L[cur], c) + 10,
		dfs(cur + 1, a, b, c + L[cur]) + 10,
	].min
end
p dfs 0,0,0,0

Measured memory_bytes: 1788
q, h, s, d = map(int, input().split())
n = int(input())
q_cp = q*8
h_cp = h*4
s_cp = s*2
d_cp = d
ans = 0
if min(q_cp,h_cp,s_cp,d_cp)==q_cp:
    ans+=n*q*4
elif min(q_cp,h_cp,s_cp,d_cp)==h_cp:
    ans+=n*h*2
elif min(q_cp,h_cp,s_cp,d_cp)==s_cp:
    ans+=n*s
else:
    ans += n//2*d
    amari = n%2
    if min(q_cp, h_cp, s_cp) == q_cp:
        ans += amari*q*4
    elif min(q_cp, h_cp, s_cp) == h_cp:
        ans += amari*h*2
    elif min(q_cp, h_cp, s_cp) == s_cp:
        ans += amari*s
print(int(ans))

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
void pri(vll vec){
  ll n = vec.size();
  REP(i,n){
    if(i) cout << " ";
    cout << vec[i];
  }
  cout <<endl;
}
//-----------------------------------------

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n, q;
  cin >> n >> q;
  vector<vector<ll>> vec(n);
  REP(i,q){
    ll com;
    cin >> com;
    if(com == 0){
      ll t, x;
      cin >> t >> x;
      vec[t].push_back(x);
    }
    else if(com == 1){
      ll t;
      cin >> t;
      pri(vec[t]);
    }
    else{
      ll t;
      cin >> t;
      vec[t].clear();
    }
  }


  return 0;
}




Measured memory_bytes: 10896
using System;
using System.Linq;
using System.Numerics;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
      BigInteger a=BigInteger.Parse(str[0]);
      BigInteger b=BigInteger.Parse(str[1]);
      BigInteger c=BigInteger.Parse(str[2]);
      BigInteger d=BigInteger.Parse(str[3]);
      BigInteger[] arr=new BigInteger[4];
   arr[0]=a*c;
   arr[1]=b*c;
      arr[2]=a*d;
      arr[3]=b*d;
    Array.Sort(arr);
      Console.WriteLine(arr[3]);
    }
    
  }

}


Measured memory_bytes: 28036
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] p = new int[N];

        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }

        Arrays.sort(p);

        int result = 0;

        for (int i = 0; i < K; i++) {
            result += p[i];
        }

        System.out.println(result);

    }
}


Measured memory_bytes: 39032
#include<bits/stdc++.h>
#define ll long long int
#define ve vector<int>
#define vl vector<long long int>
#define all(a) a.begin(),a.end()
using namespace std;

int main(){
  ll n,L=0;
  cin>>n;
  vl a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    L+=a[i];
  }
  ll A=0,B=0;
  for(int i=0;A<L/2;i++){
    A+=a[i];
  }
  for(int i=n-1;B<L/2;i--){
    B+=a[i];
  }
  ll ans=min(A,B);
  ans=2*ans-L;
  //cout<<L<<endl;
  //cout<<A<<endl;
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll N,M;
    cin >> N >> M;
    vector<ll> A(N);
    ll all = 0;
    for (ll i = 0;i<N;i++) {
        ll a; cin >> a;
        A.at(i) = a;
        all += a;
    }
    ll cnt = 0;
    for (ll i = 0;i<N;i++) {
        if (A.at(i)*4*M >= all) cnt++;
    }
    if (cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 1e4+10;

LL n, a, b;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n >> a >> b;
    if (a > b) swap(a, b);
    LL len = (b-a+1);
    if (len&1) cout << len/2 << "\n";
    else cout << min(a-1, n-b)+len/2 << "\n";

    return 0;
}



Measured memory_bytes: 256
PROGRAM forbiddenList
      IMPLICIT NONE
      INTEGER,PARAMETER :: prec = 16
      integer(prec) :: x,n,ans,ansi,tempAns
      integer(prec), allocatable :: p(:)
      integer(prec) :: i, j
      
      read*,x,n
      allocate( p(n) )
      read*,p
      
      ans = 100000
      ansI = 10000
      
      outer:&
      do i = -200,300
        do j = 1,n
          if( i==p(j) )then
            cycle outer
          end if
        end do
        
        tempAns = abs( i-x )
        
        if( tempAns<=ans )then
          if( tempAns==ans )then
            if( i>ansI )then
              cycle outer
            end if
          end if
          
          ans = tempAns
          ansI = i
          
        end if
        
      end do outer
      
      print*,ansI
      
      
      
      stop
      !debugg
      
      print*,ans
      
      
      END PROGRAM

Measured memory_bytes: 2868
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let cs: Vec<char> = s.chars().collect();

    if n % 2 == 0 {
        let m = n / 2;
        let mut ans = true;
        for i in 0..m {
            if cs[i] != cs[i + m] {
                ans = false;
            }
        }
        println!("{}", if ans { "Yes" } else { "No" });
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
using namespace std;
#include <stdio.h>
#include<iostream>
#include<math.h>
int main()
{   
    int n,y,cnt=0,X,Y;
    cin>>n>>y;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(y==10000*i+5000*j+(n-i-j)*1000 and n-i-j>=0){
            cnt++;
            X=i;
            Y=j;
            break;
            }
        }
    }
    if(cnt==0) cout<<"-1 -1 -1"<<endl;
    else cout<<X<<" "<<Y<<" "<<n-X-Y<<endl;
    return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
l1=len(s)
l2=len(t)
dp=[[-1]*(l2+1) for i in range(l1+1)]   

for i in range(l1+1):
    for j in range(l2+1):
        if i==0 or j==0:
            dp[i][j]=0
            
        elif s[i-1]==t[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
            

size=dp[l1][l2]
i,j=l1,l2
ans=[0]*size
while i>0 and j>0:
    if s[i-1]==t[j-1]:
        ans[size-1]=(s[i-1])
        i-=1
        j-=1
        size-=1
    elif dp[i-1][j]>dp[i][j-1]:
        i-=1
    else:
        j-=1
        
    
print(''.join(ans))



Measured memory_bytes: 112988
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int n;
    cin >> n;
    vector<vector<vector<int>>> H(4, vector<vector<int>>(3, vector<int>(10)));
    rep(i, n) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        H.at(b - 1).at(f - 1).at(r - 1) += v;
    }
    rep(i, 4) {
        if (i) cout << "####################\n";
        rep(j, 3) {
            rep(k, 10) {
                cout << " ";
                cout << H.at(i).at(j).at(k);
            }
            cout << "\n";
        }
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pii;

signed main()
{
    int x;
    cin>>x;
    vector<int> a{399,599,799,999,1199,1399,1599,1799,1999};
    int count=8;
    for(int i=0;i<a.size()-1;i++)
    {
        if(a[i]+1<=x && a[i+1]>=x)
        {
            break;
        }
        count--;
    }
    cout<<count<<endl;
}


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

int main() {
	int n, m;
	ios::sync_with_stdio(0);
	cin >> n >> m;
	int cnt[100005] = {};
	int a = 0, b = 0;
	for (int i = 1; i <= m; i++) {
		int x; string s;
		cin >> x >> s;
		if (s[0] == 'A') {if (cnt[x]>= 0) b += cnt[x], a++, cnt[x] = -1000000;}
		else cnt[x] ++; 
	}
    cout << a << " " << b << endl;
}

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

void solve() {
    int n, w;
    cin >> n >> w;
    vector<vector<int>> s(n, vector<int>(w));
    for (int i = 0; i < n; ++i) {
        string st;
        cin >> st;
        for (int j = 0; j < w; ++j) {
            if (st[j] == '#') {
                s[i][j] = 1;
            } else {
                s[i][j] = 0;
            }
        }
    }
    vector<vector<int>> dp(n, vector<int>(w));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < w; ++j) {
            dp[i][j] = n + w - 1;
        }
    }
    dp[0][0] = s[0][0];
    for(int i = 0; i < n; i++) {
        for (int j = 0; j < w; j++) {
            if (i == 0 && j == 0) {
                continue;
            }
            if (i == 0) {
                dp[i][j] = dp[i][j - 1] + abs(s[i][j] - s[i][j - 1]);
            } else if (j == 0) {
                dp[i][j] = dp[i - 1][j] + abs(s[i][j] - s[i - 1][j]);
            } else {
                dp[i][j] = min(dp[i][j - 1] + abs(s[i][j] - s[i][j - 1]), dp[i - 1][j] + abs(s[i][j] - s[i - 1][j]));
            }
        }
    }
    // for (int i = 0; i < n; i++) {
    //     for (int j = 0; j < w; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << (dp[n - 1][w - 1] + 1) / 2;
}

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

Measured memory_bytes: 384
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
const ll MAX_N = 3000;
/**/
int main() {
	// 入力
	ll N;cin>>N;
	set<string> se;
    REP(i,N){
		string tmp;cin>>tmp;
		se.insert(tmp);
	}
    
	//出力
	cout << se.size() << endl;
}


Measured memory_bytes: 19256
#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100000+10;

int n,m;
int s,t;
vector<int> a[maxn*3];
int q[maxn*3],front,rear;
int d[maxn*3];
int kq;

int main(){
  scanf("%d%d",&n,&m);
  for(int i=1;i<=m;i++){
    int u,v;
    scanf("%d%d",&u,&v);
    a[u*3+0].push_back(v*3+1);
    a[u*3+1].push_back(v*3+2);
    a[u*3+2].push_back(v*3+0);
  }
  scanf("%d%d",&s,&t);
  //--------
  front=1;rear=0;
  for(int i=0;i<3*(n+1);i++) d[i]=-1;
  rear++;q[rear]=s*3+0;d[s*3+0]=0;
  while(front<=rear){
    int u=q[front];front++;
//    cout<<"U= "<<u<<endl;
    for(int i=0;i<a[u].size();i++){
      int v=a[u][i];
      if (d[v]==-1){
//        cout<<"---------> V= "<<v<<endl;
        rear++;q[rear]=v;d[v]=d[u]+1;
      }
    }
  }
  if (d[t*3+0]==-1) kq=-1;
  else kq=d[t*3+0]/3;
  cout<<kq;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<string, int> mp;
  REP(i, n){
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 3536
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  val s = StdIn.readLine()
  
  val r = s.foldLeft((0, 0)){ (acc, c) =>
    (scala.math.max(acc._1, acc._2 + (if(c == 'I') 1 else -1)),
      acc._2 + (if(c == 'I') 1 else -1))
  }
  
  println(r._1)
  
}


Measured memory_bytes: 27316
import io.StdIn

object Main {
  def main(argv: Array[String]): Unit = {
    val vertexCount = StdIn.readLine.toInt

    val matrix = new Array[Array[Int]](vertexCount)

    (1 to vertexCount) foreach { n =>
      matrix(n-1) = new Array[Int](vertexCount)
      val line = StdIn.readLine.split(" ").map(_.toInt).toArray
      line.drop(2) foreach { k =>
        matrix(line(0) - 1)(k - 1) = 1
      }
    }

    matrix.foreach { line => println(line.mkString(" ")) }
  }
}



Measured memory_bytes: 45724