akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::Chars;

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       N: usize,
       M:usize,
       a:[usize;M],
    }

    let mut ans: usize = 0;
    let sum = a.iter().fold(0, |a, x| a + x);
    if N < sum {
        echo!(-1);
    } else {
        echo!(N - sum);
    }
}


Measured memory_bytes: 2288
#include<cstdio>
#include<algorithm>
int a[100002];
int d(int i,int j) {
	return std::abs(a[i] - a[j]);
}
int main() {
	int n, i, sum = 0;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	a[0] = 0;
	a[n + 1] = 0;
	for (i = 1; i < n + 2; i++) {
		sum += d(i, i - 1);
	}
	for (i = 1; i <= n; i++) {
		printf("%d\n", sum - d(i, i - 1) - d(i, i + 1) + d(i - 1, i + 1));
	}
	return 0;
}


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int n,m;cin>>n>>m;

	vector<int> vc[m];
	vector<int> p(m);

	for(int i=0; i<m; i++){
		int tmp; cin>>tmp;

		for(int j=0; j<tmp; j++){
			int s; cin>>s;
			s--;

			vc[i].push_back(s);
		}
	}
	rep(i,m){
		int tmp; cin>>tmp;
		p[i] =tmp;
	}

	int ans =0;
	for(int bit=0; bit<1<<n; bit++){

		bool judge =true;
		for(int j=0; j<m; j++){

			int cnt =0;

			for(int k=0; k<vc[j].size(); k++){
				if(bit & 1<<vc[j][k])cnt++;
			}
			if(cnt%2 !=p[j]){
				judge =false;
			}

		}
		if(judge)ans++;

	}

	writeln(ans);


}


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]
A = list(map(lambda x:x-1, A))
ex = [0]*10**5
light = 0
for i in range(N) :
    if light == 1 :
        print(i)
        exit()
    elif ex[light] == 1 :
        print('-1')
        exit()
    ex[light] = 1
    light = A[light]

print('-1')

Measured memory_bytes: 16924
let () = Scanf.scanf "%d\n" @@ fun n ->
  let ls = Array.init n @@ fun _ -> Scanf.scanf "%d " Fun.id in
  Printf.printf "%d\n" @@
  List.fold_left (List.fold_left (List.fold_left ( + ))) 0 @@
  List.init n @@ fun i ->
    List.init i @@ fun j ->
      List.init j @@ fun k ->
        if
          ls.(i) <> ls.(j) &&
          ls.(j) <> ls.(k) &&
          ls.(k) <> ls.(i) &&
          ls.(i) + ls.(j) > ls.(k) &&
          ls.(j) + ls.(k) > ls.(i) &&
          ls.(k) + ls.(i) > ls.(j)
        then 1
        else 0



Measured memory_bytes: 9780
# coding: utf-8
# Your code here!

N, L = map(int, input().rstrip().split(' '))

S = []
min_value = int(1e9)
for i in range(N):
    S.append(L+i)
    if abs(min_value) > abs(L+i):
        min_value = L + i
    
print(sum(S) - min_value)

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

int N; vector<int>vec, vec2;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a; cin >> a; a--; vec.push_back(a);
	}
	while (vec.size() >= 1) {
		int flag = -1;
		for (int i = 0; i < vec.size(); i++) {
			if (vec[i] == i) flag = i;
		}
		if (flag == -1) {
			cout << "-1" << endl;
			return 0;
		}
		vec2.push_back(flag + 1);

		vector<int>vec3;
		for (int i = 0; i < vec.size(); i++) {
			if (i == flag) continue;
			vec3.push_back(vec[i]);
		}
		vec = vec3;
	}
	for (int i = vec2.size() - 1; i >= 0; i--) cout << vec2[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }


int main(){
  bool exist[4][14];
  FILL2(exist,4,14,false);
  map<char,int> num_suit;
  map<int,char> chr_suit;
  num_suit['S'] = 0;
  num_suit['H'] = 1;
  num_suit['C'] = 2;
  num_suit['D'] = 3;
  chr_suit[0] = 'S';
  chr_suit[1] = 'H';
  chr_suit[2] = 'C';
  chr_suit[3] = 'D';
  
  int N; cin>>N;
  REP(i,N){
    char c; int x; cin>>c>>x;
    exist[ num_suit[c] ][ x ] = true;
  }
  REP(i,4){
    char c = chr_suit[i];
    for(int j=1;j<=13;++j){
      if( !exist[i][j] ){ printf("%c %d\n",c,j);}
    }
  }
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
	vector<int64> a(5);
	int64 k;
	REP(i, 5) cin >> a[i];
	cin >> k;
	sort(all(a));
	if (a[4]-a[0] > k) {
		cout << ":(" << endl;
	} else {
		cout << "Yay!" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int counter;

void Merge(int A[], int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i=0; i<n1; ++i) L[i] = A[left+i];
    for (int i=0; i<n2; ++i) R[i] = A[mid+i];
    L[n1] = R[n2] = SENTINEL;
    int i=0, j=0;
    for (int k = left; k<right; ++k) {
        counter++;
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}
void MergeSort(int A[], int left, int right)
{
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        MergeSort(A, left, mid);
        MergeSort(A, mid, right);
        Merge(A, left, mid, right);
    }
}
int main()
{
    int A[MAX];
    counter=0;
    int n; cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> A[i];
    }

    MergeSort(A, 0, n);

    for (int i=0; i<n; ++i) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;

    cout << counter << endl;
    return 0;
}



Measured memory_bytes: 7000
//C - Be Together

#include <stdio.h>
int N;
int a[101];

int computeCost(int target)
{
	int cost = 0;
	for(int i=1;i<=N;i++)
	{
		cost += (a[i]-target)*(a[i]-target);
	}
	return cost;
}	

int main()
{
	int min = -101,max = 101,mincost;
	scanf("%d",&N);

	for (int i=1;i<=N;i++)
	{
		scanf("%d",&a[i]);

		if (a[i]<min)
			min = a[i];
		if (a[i]>max)
			max = a[i];
	}

	mincost = computeCost(min);

	for (int j=min;j<=max;j++)
	{
		int cost = computeCost(j);
		if (cost<mincost)
			mincost = cost;
	}

	printf("%d",mincost);

}

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


int check(string str)
{

    int n = str.length();
    int digitSum = 0;
    for (int i=0; i<n; i++)
        digitSum += (str[i]-'0');

    return (digitSum % 9 == 0);
}


int main()
{
    string str ;
    cin>>str;
    check(str)?  cout << "Yes" : cout << "No ";
    return 0;
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 5001;
int n, dp[N][N];
char s[N];

int main(){
     scanf("%d %s", &n, s);
     int an = 0;
     for(int i = n-1; i>=0; --i){
	    for(int j = n-1; j>=0; --j){
		     if(s[i] == s[j])dp[i][j] = dp[i+1][j+1]+1;
		     else dp[i][j] = 0;
		     if(j > i)an = max(an, min(dp[i][j],j-i));
		}
	 }
	 printf("%d\n", an);
}


Measured memory_bytes: 97920
using System;
using System.Collections.Generic;

namespace Atcoder_program_test_Csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            //変数宣言・初期化
            int n;

            //標準入力
            string[] str = Console.ReadLine().Split(' ');
            n = int.Parse(str[0]);
            Console.Write(n * n * n);
        }
    }
}

Measured memory_bytes: 11092
import java.io.InputStream;
import java.io.IOException;

class MyScanner{
    InputStream stream;
    public MyScanner(){
        stream = System.in;
    }
    
    public long nextLong(){
        long ret = 0;
        try{
            while(true){
                char readed = (char)stream.read();
                if(readed < '0' || readed > '9'){
                    break;
                }
                ret = ret * 10 + (readed - '0');
            }
        }catch(IOException e){
            e.printStackTrace();
        }finally{
            return ret;
        }
    }
}

class Main {
    public static void main(String args[]) {
        MyScanner sc = new MyScanner();
        long n = sc.nextLong(), a = sc.nextLong(), b = sc.nextLong();
        long min = b + a * (n - 1);
        long max = a + b * (n - 1);
        if(max < min){
            System.out.println(0);
        }else{
            System.out.println(max - min + 1);
        }
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<ll,ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<ll,ll>
#define mii map<pii,ll>
#define ms map<string,ll>
#define itr ::iterator
#define all(x) x.begin(),x.end()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fe(i,a,b) for(ll i=a;i<=b;i++)
#define fn(i,a,b) for(ll i=a;i>b;i--)
#define fm(it,m) for(it = m.begin();it != m.end();++it)
#define db(i) cout<<i<<"  "
#define M 1000000007

int main()
{ ll t=1;
  //cin>>t;
  while(t--)
  { ll h=0,n=0,k=0,s=0;
    cin>>n>>k;
    ll a[n];
    f(i,0,n)
     {cin>>a[i];
     }
    if(k>=n)
        cout<<0;
    else
     {sort(a,a+n);
      f(i,0,n-k)
       s=s+a[i];
      cout<<s;
     }

  }
return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
struct queue {
	int i;
	int left;
}q[100005];
bool cmp(const queue &a, const queue &b) {
	if (a.i != b.i)
		return a.left < b.left;
}
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> q[i].left;
		q[i].i = i;
	}
	sort(q + 1, q + n + 1, cmp);
	for (int i = 1; i <= n; i++)
		cout << q[i].i << ' ';
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>

using namespace std;

int ldp[200001][21];
int mdp[200001][21];


bool getBit(int byte, int position)
{
    return (byte >> position) & 0x1;
}

long long solve() {
    long long ans = 0;
    long N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        
        int dd = N;
        for (int j = 0; j < 21; j++) {
            if (i == 0) {
                ldp[i][j] = 1;
                mdp[i][j] = getBit(A, j)?1:2;
            } else {
                if (getBit(A, j)) {
                    ldp[i][j] = mdp[i-1][j];
                    mdp[i][j] = 1;
                } else {
                    ldp[i][j] = ldp[i-1][j]+1;
                    mdp[i][j] = mdp[i-1][j]+1;
                }
            }
            dd = min(dd, ldp[i][j]);
        }
        ans += dd;
    }
    return ans;
}

int main() {
    cout << solve() << endl;
#ifdef DEBUG
    while (1) {
        cout << solve() << endl;
    }
#endif
}


Measured memory_bytes: 33024
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function arrayIn(){
		$buf = explode(" ", fgets(STDIN));
		return $this->killNewLine($buf);
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->arrayIn();
	
		$ans = $s[0] * $s[1];

		if(0 == $ans % 2){
			echo "No\n";
		}else{
			echo "Yes\n";
		}
	}
}
?>

Measured memory_bytes: 4728
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(void){
	int n,m;
	string s,t;
	cin>>s;
	if(s[0] != 'A'){
		cout<<"WA"<<endl;
		return 0;
	}
	if(s[1] <= 'Z'){
		cout<<"WA"<<endl;
		return 0;
	}
	int count = 0;
	for(int i=2;i<s.size();i++){
		if(s[i] <= 'Z'){
			if(s[i]=='C'){
				if(i == s.size()-1){
					cout<<"WA"<<endl;
					return 0;
				}
				count++;
			}else{
				cout<<"WA"<<endl;
				return 0;
			}
		}
	}
	if(count == 1){
		cout<<"AC"<<endl;
	}else{
		cout<<"WA"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    string s;
    cin >> s;
    int g = s.length();
    for(int i = 0; i < g; i++){
        if(s[i] == s[i + 1]){
            cout << "Bad";
            return 0;
        }
    }
    cout << "Good";
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using std::vector;
using std::printf;

template<typename T>
void dump(vector<T> vec) {
    for (auto x : vec) {
        std::cout << x << " ";
        std::cout << std::endl;
    }
}

int main() {
    int N;
    std::cin >> N;

    vector<int> v(N);
    for (int i = 0; i < N; ++i) {
        std::cin >> v.at(i);
    }

    //sort
    std::sort(v.begin(), v.end());

    // //dump
    // dump<int>(v);

    //calc
    float ret = (float) v[0];
    for (int i = 0; i < N; ++i) {
        ret += (float) v[i];
        ret /= 2.;
    }

    printf("%f", ret);

    return 0;
}

Measured memory_bytes: 256
def change_num(x, y)
  (x-y)**2
end

l = gets.to_i
n = gets.chomp.split(" ").map(&:to_i)

if n.uniq.length == 1
  puts 0
  exit
end

arr = {}
(-100).upto(100) do |i|
  x = 0
  n.each do |z|
    x += change_num(z, i)
  end
  arr[i.to_s] = x
end

puts arr.min { |a, b| a[1] <=> b[1] }[1]

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

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


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

int main()
{
	int n, a, tmp;
	cin >> n;
	cin >> a;
	tmp = ((n % 500) - a);
	if (tmp <= 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
A.sort()
d = defaultdict(int)
for a in A:
    d[a] += 1

cnt = 0
for a in reversed(A):
    if d[a] > 0:
        d[a] -= 1
        pair = (1 << a.bit_length()) - a
        if d[pair] > 0:
            cnt += 1
            d[pair] -= 1
print(cnt)


Measured memory_bytes: 55996
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N, M,K;
	std::cin >> N >> M>>K;

	ll ans = 0;
	vll A(N+2,0);
	A[N + 1] = 99999999999;
	map<ll, ll> dic;
	rep(i, 0, N) {
		ll tmp;
		std::cin >> tmp;
		A[i + 1] = A[i] + tmp;
		dic[A[i + 1]] = i + 1;
		if (A[i + 1] <= K) {
			ans = i + 1;
		}
	}
	vll B(M+1,0);
	rep(i, 0, M) {
		ll tmp;
		std::cin >> tmp;
		B[i + 1] = B[i] + tmp;
		auto itr = upper_bound(A.begin(), A.end(), K-B[i + 1]);
		if (*itr > 0) {
			itr--;
			ans = max(ans, i + 1 + dic[*itr]);
		}
	}

	std::cout << ans << endl;

	
	return 0;
}


Measured memory_bytes: 18740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 int n;
 cin>>n;
 vector<int> a(n);
 for(int i=0;i<n;i++) cin>>a[i];
 vector<ll> sum(n);
 for(int i=0;i<n;i++) sum[i]=a[i];
 for(int i=1;i<n;i++) sum[i]+=sum[i-1];
 vector<vector<ll>> dp(n,vector<ll>(n));
 for(int i=0;i<n;i++){
  dp[i][i]=0;
 }
 const ll INF=1e18;
 for(int i=n-1;i>=0;i--){
  for(int j=i+1;j<n;j++){
   dp[i][j]=INF;
   for(int k=i;k<j;k++){
    dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+sum[j]-(i>0?sum[i-1]:0));
   }
  }
 }
 cout<<dp[0][n-1]<<endl;
 return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
     
    using namespace std;
     
    #define ld long double
    #define ll long long
     
    const int N = 1002;
     
    int n,m,ans;
    char g[N][N];
    vector<pair<int,int>> src;
    int d[N][N];
    bool vis[N][N];
     
    int dx[] = {0,0,-1,1};
    int dy[] = {-1,1,0,0};
     
    void bfs(vector<pair<int,int>> s){
        queue<pair<int,int>> q;
        for(int i=0;i<s.size();i++){
            q.push(s[i]);
            vis[s[i].first][s[i].second] = 1;
            d[s[i].first][s[i].second] = 0;
        }
        while(!q.empty()){
            int x = q.front().first;
            int y = q.front().second;
            q.pop();
            for(int i=0;i<4;i++){
                if(!vis[x + dx[i]][y + dy[i]] && g[x + dx[i]][y + dy[i]] != '#'){
                    q.push({x + dx[i], y + dy[i]});
                    vis[x + dx[i]][y + dy[i]] = 1;
                    d[x + dx[i]][y + dy[i]] = d[x][y] + 1;
                    ans = d[x + dx[i]][y + dy[i]];
                }
            }
        }
    }
     
    int main(){
        /*#ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
        #endif*/
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.precision(10);
        cout<<fixed;
     
        cin>>n>>m;
        for(int i=0;i<=n+1;i++){
            for(int j=0;j<=m+1;j++){
                g[i][j] = '#';
            }
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                cin>>g[i][j];
                if(g[i][j] == '#'){
                    src.push_back({i, j});
                }
            }
        }
     
        bfs(src);
     
        cout<<ans;
     
        return 0;
    }

Measured memory_bytes: 29928
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long int ll;

int main() {
    int N;
    cin >> N;
    priority_queue<double, vector<double>, greater<double> > pq;
    for (int i = 0; i < N; i++) {
      	double v; cin >> v;
        pq.push(v);
    }

    while(pq.size() > 1) {
        double a = pq.top();
        pq.pop();
        double b =  pq.top();
        pq.pop();

        double c = (a + b) / 2;
        pq.push(c);
    }

    cout << fixed << setprecision(5) << pq.top() << endl;
}

Measured memory_bytes: 256
def main():
    mn = [['L', 'U', 'D'], ['R', 'U', 'D']]
    steps = input()
    for i in range(0, len(steps)):
        if steps[i] not in mn[(i + 1) % 2]:
            print('No')
            return
    print('Yes')
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
h, w = [int(i) for i in input().split()]

if h %3 == 0 or w%3 == 0:
    print(0)
elif h == 1 or w == 1:
    print(1)
else:
    s1 = round(h / 3)*w
    h1 = h - round(h/3)
    if w % 2 == 0 or h1 % 2 == 0:
        s2 = h1*w//2
        s3 = s2
    else:
        s2 = max(w, h1)//2 * min(w, h1)
        s3 = h1*w-s2
    ans = max([s1, s2, s3])-min([s1, s2, s3])
    s1 = round(w / 3)*h
    w1 = w - round(w/3)
    if w1 % 2 == 0 or h % 2 == 0:
        s2 = h*w1//2
        s3 = s2
    else:
        s2 = max(w1, h)//2 * min(w1, h)
        s3 = h*w1-s2
    ans = min(max([s1, s2, s3])-min([s1, s2, s3]), ans)
    print(ans)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n,mi=10000000000,ma=-10000000000,r;
  cin >> n;
  for(int i=0;i<n;i++){
    cin>>r;
    ma=max(ma,r-mi);
    mi=min(mi,r);
  }
  cout << ma << endl;
  return 0;
}


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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
const long long INF = 1LL<<60;
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;
}

bool isOK(vector<ll>& v, ll mid, ll key) {
    if (v[mid] >= key) return true;
    else return false;
}

ll binary_search(vector<ll>& v, ll key) {
    ll ng = -1;
    ll ok = v.size();
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (isOK(v, mid, key)) ok = mid;
        else ng = mid; 
    }
    return ok;
}

int main(){
    ll N; cin >> N;
    vector<ll> A(N, 0), B(N, 0), C(N, 0);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    //view(A);
    //view(B);
    //view(C);
    ll cnt = 0;
    rep(i, N) { //　中部を全てループする
        ll ok_A = binary_search(A, B[i]);
        // auto ok_A = lower_bound(A.begin(), A.end(), B[i]);
        ll ok_C = binary_search(C, B[i] + 1);
        // auto ok_C = lower_bound(C.begin(), C.end(), B[i] + 1);
        // cout << "i: " << i << " ok_A: " << ok_A << " ok_C: " << N - ok_C << endl;
        // cnt += distance(ok_A, A.begin())
        // cout << ok_A << endl;
        // cout << ok_C << endl;
        cnt += ok_A * (N - ok_C);
    }
    cout << cnt << endl;
}

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

using namespace std;

#define N 300000
#define LL long long

const LL mod=1000000007;
LL n,ans,fa[N],deep[N],a[N],f[N][2],pw[N],sum,tot,head[N],vis[N];
vector<LL> g[N];
struct edge{LL v,nxt;}e[N*2];

bool cmp(LL x,LL y){return deep[x]<deep[y];}

void add(LL x,LL y){e[++tot].v=y; e[tot].nxt=head[x]; head[x]=tot;}

LL inv(LL x){return x==1?x:(mod-mod/x)*inv(mod%x)%mod;}

void dfs(LL u){
	deep[u]=deep[fa[u]]+1;
	for (LL i=0;i<(LL)g[u].size();i++) dfs(g[u][i]);
}

void dp(LL u,LL s){
	f[u][0]=f[u][1]=0;
	if (deep[u]==s){f[u][0]=f[u][1]=1; return;}
	LL c1=1,c2=1;
	for (LL i=head[u],v;i;i=e[i].nxt){
		v=e[i].v; dp(v,s);
		c1=c1*f[v][0]%mod;
		c2=c2*(f[v][0]+f[v][1])%mod;
	}
	LL cnt=0;
	for (LL i=head[u],v;i;i=e[i].nxt){
		v=e[i].v; cnt++;
		f[u][1]=(f[u][1]+f[v][1]*c1%mod*inv(f[v][0]))%mod;
	}
	if (cnt==1) fa[e[head[u]].v]=fa[u];
	f[u][0]=((c2-f[u][1])%mod+mod)%mod;
	head[u]=0;
}
		
int main(){
	scanf("%lld",&n);
	for (LL i=1;i<=n;i++){
		scanf("%lld",&fa[i]); g[fa[i]].push_back(i);
	}
	pw[0]=1; for (LL i=1;i<=n+1;i++) pw[i]=pw[i-1]*2%mod;
	dfs(0);
	for (LL i=0;i<=n;i++) a[i]=i;
	sort(a+1,a+n+1,cmp);
	LL j=0;
	for (LL i=1;i<=n+1;i++){
		tot=0; sum=0;
		for (;j<=n && deep[a[j]]==i;j++){
			LL k=a[j]; sum++;
			while(k!=0 && vis[k]!=i) add(fa[k],k),vis[k]=i,k=fa[k];
		}
		dp(0,i);
		ans=(ans+f[0][1]*pw[n-sum+1])%mod;
	}
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 39424
package main

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

func main() {
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Scan()
	var n, _ = strconv.Atoi(scanner.Text())
	var minR int;
	var maxDiff int = -10000000000;
	for i := 0; i < n; i++ {
		scanner.Scan()
		var r, _ = strconv.Atoi(scanner.Text())
		if i == 0 {
			minR = r
		} else {
			var diff = r - minR
			if maxDiff < diff {
				maxDiff = diff
			}
			if r < minR {
				minR = r
			}
		}
	}
	fmt.Println(maxDiff)
}



Measured memory_bytes: 4092
n = int(input())
s = [input() for i in range(n)]
lst = ["M","A","R","C","H"]
dct = {c:0 for c in lst}
ans = 0

for name in s:
    if name[0] in dct:
        dct[name[0]] += 1

for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans += dct[lst[i]]*dct[lst[j]]*dct[lst[k]]

print(ans)


Measured memory_bytes: 9752
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(map(str, input().split()))
def pl(a): print(" ".join(list(map(str, a))))
def ma():return map(int,input().split())
def nli(x):return [input for _ in range(x)]
def hukusuu(): 
  listA=[] #appendのために宣言が必要
  while True:
    try:listA.append(list(map(int,input().split())))
    except:break #または、quit(),os.exit()をして止める。
  return listA

n,k=ma()
h=rli()

from itertools import accumulate as acc 
import operator as op
import copy as cp
import math
from bisect import bisect_left as bisl
from bisect import bisect_right as bisr
def ifif(s):
  if s:print("Yes")
  else:print("No")

h.sort()
inde=bisl(h,k)
print(n-inde)  





Measured memory_bytes: 11904
# ENV[Z = 'RUBY_THREAD_VM_STACK_SIZE'] || exec( { Z => '50000000' },'ruby',$0)
# readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }
# gets.split.map(&:to_i)

a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

count = 0
(a+1).times do |i|
  (b+1).times do |j|
    (c+1).times do |k|
      sum = (i)*500 + (j)*100 + (k)*50
      count += 1 if sum == x
    end
  end
end

puts count


Measured memory_bytes: 1788
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  tmp = input[0].split(" ");
  //文字列から10進数に変換するときはparseIntを使います
  var S = tmp[0];
  //出力
  if(S[S.length - 1] == "s") {
    console.log("%s", S + "es");
  } else {
    console.log("%s", S + "s");
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29540
n = input()
n = n.split()
m = int(n[1])
n = int(n[0])
a = input()
a = a.split()
c = int(a[0])
for b in range(n-1):
    c = c + int(a[b+1])
c = c / (4 * m)
e = 0
for d in range(n):
    if int(a[d]) >= c :
        e = e + 1
if e >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9224
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <math.h>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <iomanip>
#include <unordered_map>
using namespace std;
typedef long long ll;
ll ans, mx, sum,temp, mn = 1e14, flag,cnt;





int main(){
	string s;
	cin>>s;
	ll q;
	cin>>q;
	set<string> s1;
	ll n=s.size();

	for(ll i=0; i<n; i++){
		string t;
		for(ll j=i; j<i+q; j++){
			if(j>=n) break;
			t+=s[j];
			s1.insert(t);
		}
	}

    set<string> :: iterator it;
    for(it=s1.begin(); it!=s1.end(); it++){
    	cnt++;
    	if(cnt==q){
    		cout<<*it;
    		return 0;
    	}
    }
	
}

Measured memory_bytes: 4812
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int dp[55][55];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	int tot = 0;
	rep(i, h) rep(j, w) if(s[i][j] == '.') tot++;
	rep(i, 55) rep(j, 55) dp[i][j] = 1e9;
	dp[0][0] = 0;
	rep(k, 1000) rep(i, h) rep(j, w) if(s[i][j] == '.'){
		if(!i && !j) continue;
		if(i > 0) dp[i][j] = min(dp[i - 1][j] + 1, dp[i][j]);
		if(j > 0) dp[i][j] = min(dp[i][j - 1] + 1, dp[i][j]);
		if(i < (h - 1)) dp[i][j] = min(dp[i + 1][j] + 1, dp[i][j]);
		if(j < (w - 1)) dp[i][j] = min(dp[i][j + 1] + 1, dp[i][j]);
	}
	if(dp[h - 1][w - 1] == 1e9) cout << -1 << endl;
	else cout << tot - dp[h - 1][w - 1] - 1 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc())if(ch=='-')positive=0;
	for(;isdigit(ch);ch=gc())x=x*10+ch-'0';
	return positive?x:-x;
}

inline void write(int x){
	if(x<0)x=-x,putchar('-');
	if(x>9)write(x/10);putchar(x%10+'0');
}

inline void writeln(int x){
	write(x);puts("");
}
#define Max 100001

int a[Max],n,sum;

int main(){
	n=read();
	a[0]=0;
	for(int i=1;i<=n;i++){
		a[i]=read();
		sum+=abs(a[i-1]-a[i]);
	}
	sum+=abs(a[n]);
	for(int i=1;i<=n;i++){
		writeln(sum+abs(a[i-1]-a[i+1])-abs(a[i]-a[i-1])-abs(a[i]-a[i+1]));
	}
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<iomanip>
using namespace std;

 double dp[17][1<<16]={};
   
int main(){
    int n,m;
    cin >> m >>n;
    vector<vector<double > > p(m+1,vector<double>(n+1));
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin >> p[i][j];
        }
    }
    double s[17][17][17]={};
    for(int i=0;i<m;i++){
        for(int j=0;j<=n;j++){
            for(int k=j;k<=n;k++){
                double tmp = 1.0;
                for(int x = j;x<k;x++){
                    tmp *= p[i][x];
                }
                if(k!=n)tmp *= 1.0-p[i][k];
                s[i][j][k] = tmp;
                //cout << i << " " << j << " " << k << " " << tmp << endl;
            }
        }
    }
    for(int i=0;i<(1<<m);i++){
        dp[n][i] = 1.0;
    }
    for(int i=(1<<m)-1;i>=0;i--){
        for(int j=n;j>=0;j--){
            for(int k=0;k<m;k++){
                if((i>>k&1)==0){
                    double tmp = 0.0;
                    for(int z=n;z>=j;z--){
                        tmp += dp[z][i+(1<<k)]*s[k][j][z];
                    }
                    //cout << j << " " << i << " " <<  tmp << endl;
                    dp[j][i] = max(dp[j][i],tmp);

                }
            }
        }
    }
    cout <<fixed << setprecision(15) <<  dp[0][0] << endl;
    return 0;
}


Measured memory_bytes: 12040
import math

N = int(input())
A_list = list(map(int, input().split()))

A_list.sort()

topvalue = A_list[-1] + 1
counts = [0] * topvalue
hits = [False] * topvalue

for A in A_list:
	counts[A] += 1
	n = A + A
	while n < topvalue:
		hits[n] = True
		n += A

count = 0
for A in A_list:
	if counts[A] == 1 and hits[A] == False:
		count += 1
print(count)


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

int main()
{
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    ll req = 0;
    if (2*c < a+b) {
        req = 2 * min(x, y) * c;
        ll tmp = 2 * max(x, y) * c;

        if (x > y) req += a * (x-y);
        else req += b * (y-x);

        if (tmp < req) req = tmp;
    }


    else {
        req = x * a;
        req += y * b;
    }

     cout << req << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#define ll long long
#define mod 1000000007
#define N 4010
using namespace std;
ll f[N][N],g[N][N];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	g[n+1][0]=1;
	ll res=1;
	for(int i=1;i<=n-k-1;i++) res=res*2%mod;
	for(int i=n;i>=1;i--)
	{
		for(int j=0;j<=n;j++)
		{
			(g[i][j+1]+=f[i+1][j]+g[i+1][j])%=mod;
			(f[i][j]+=f[i+1][j]+g[i+1][j])%=mod;
		}
		if(i!=1) for(int j=n;j>=0;j--) (f[i][j]+=f[i][j+1])%=mod;
	}
	printf("%lld\n",f[1][n-k]*res%mod);
	return 0;
}


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


int main(){


    long long n, i, t;

    long long k = 0;

    vector<long long> a;

    vector<long long> x(100000);


    cin >> n;


    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> t;

         a.push_back(t);

         }


    for( i = 0 ; i < n ; i = i + 1 ){

         if( i % 2 == 0 ) k += a.at(i);

         else k -= a.at(i);

         }


    x.at(0) = k / 2;


    for( i = 1 ; i < n ; i = i + 1 ){

         x.at(i) = a.at(i - 1) - x.at(i - 1);

         }


    cout << 2 * x.at(0);


    for( i = 1 ; i < n ; i = i + 1 ){

         cout << " " << 2 * x.at(i);

         }


    cout << endl;

    
    return 0;


    }


Measured memory_bytes: 3060
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n,m; cin >>n>>m;
  if(n==1){
    if(m==1){
      cout<<1<<endl;
      return 0;
    }
    cout<<m-2<<endl;
    return 0;
  }
  if(m==1){
    if(n==1){
      cout<<1<<endl;
      return 0;
    }
    cout<<n-2<<endl;
    return 0;
  }
  
  
    cout<<(n-2)*(m-2)<<endl;
    return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int n,l,bbq,ans=0;
  vector<int> vec;
  cin>>n;
  for(int i=0;i<n*2;i++){
    cin>>l;
    vec.push_back(l);
  }

  sort(vec.begin(),vec.end());
  bbq = vec.size();
 
  for(int i=0;i<n*2;i+=2)
    ans+=min(vec[i],vec[i+1]);
  
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
a = 0
list = []
if n == 1:
  print(0)
  exit()
for i in range(1, n):
  if h[i] <= h[i-1]:
    a += 1
  else:
    a = 0
  list.append(a)
print(max(list))

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


int main() {
  int N; cin >> N;
  vector<int> ans;
  int r;
  int m;

  if(N==0){
    cout << 0 << endl;
    return 0;
  }


  while(N != 0){
    r = N%(-2);
    N /= (-2);

    if(r==-1){
      r=1;
      N++;
    }

    ans.push_back(r);
  }

  for(int i=ans.size()-1; i>=0; i--){
    cout << ans[i];
  }

  cout << endl;
  return 0;
}


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

public class Main {
    char[] cs;

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

    void run() {
        FastReader sc = new FastReader();
        cs = sc.next().toCharArray();
        solve();
    }

    void solve() {
        char c = cs[0];
        int count = 0;
        for (int i = 1; i < cs.length; i++) {
            if (c != cs[i]) {
                count++;
                c = cs[i];
            }
        }
        System.out.println(count);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 string s,t;
 cin >> s;
 for(int i=0;i<s.length();i++) t.push_back('x'); 
 cout << t;
  return 0;
}

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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPR(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;

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

    cout << 180 * (n-2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y))

int list_sort(const void* a,const void* b)
{
	if((*(int**)a)[0] > (*(int**)b)[0])
	{
		return -1;
	}
	else if((*(int**)a)[0] == (*(int**)b)[0])
	{
		return 0;
	}
	return 1;
}

int list_sort2(const void* a,const void* b)
{
	if((*(int**)a)[1] > (*(int**)b)[1])
	{
		return 1;
	}
	else if((*(int**)a)[1] == (*(int**)b)[1])
	{
		return 0;
	}
	return -1;
}

int main()
{
	int n;
	scanf("%d",&n);
	int** score = mem(int*,n);
	int i;
	for(i = 0;i < n;i++)
	{
		score[i] = mem(int,2);
		score[i][0] = 0;
		score[i][1] = i+1;
	}
	int games = n*(n-1)/2;
	for(i = 0;i < games;i++)
	{
		int a,b,c,d;
		scanf("%d %d %d %d",&a,&b,&c,&d);
		if(c > d)
		{
			score[a-1][0]+=3;
		}
		else if(d > c)
		{
			score[b-1][0]+=3;
		}
		else
		{
			score[a-1][0]++;
			score[b-1][0]++;
		}
	}
	qsort(score,n,sizeof(int*),list_sort);
	int rank = 1;
	int oldscore = 0;
	for(i = 0;i < n;i++)
	{
		if(oldscore == score[i][0])
		{
			score[i][0] = rank;
		}
		else
		{
			oldscore = score[i][0];
			score[i][0] = rank = i+1;
		}
	}
	qsort(score,n,sizeof(int*),list_sort2);
	for(i = 0;i < n;i++)
	{
		printf("%d\n",score[i][0]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <utility>
#include <cstdio>
#include <vector>
#define pb push_back
#define MOD 1000000007
typedef long long ll;
inline ll quick_pow(ll a, int n)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}
std::vector<std::pair<int, int> > vec[200005];
std::vector<int> bel[200005];
int fa[200005], col[200005], app[200005], idx[200005];
int getfa(int u)
{
	if (u == fa[u])
		return u;
	return fa[u] = getfa(fa[u]);
}
inline void unite(int u, int v)
{
	fa[getfa(u)] = getfa(v);
}
int main()
{
	// freopen("AGC012-D.in", "r", stdin);
	int n, a, b, cnt = 0;
	scanf("%d%d%d", &n, &a, &b);
	for (int i = 0; i < n; i++)
	{
		int w;
		scanf("%d%d", col + i, &w);
		vec[--col[i]].pb({w, i});
		fa[i] = i;
	}
	for (int i = 0; i < n; i++)
	{
		if (vec[i].empty())
			continue;
		idx[cnt++] = i;
		std::sort(vec[i].begin(), vec[i].end());
		for (int j = 1; j < vec[i].size() && vec[i][0].first + vec[i][j].first <= a; j++)
			unite(vec[i][0].second, vec[i][j].second);
	}
	std::sort(idx, idx + cnt, [&] (const int &x, const int &y)
	{
		return vec[x][0].first < vec[y][0].first;
	});
	for (int i = 0; i < n; i++)
	{
		if (cnt && idx[0] != i)
		{
			for (auto x : vec[i])
			{
				if (x.first + vec[idx[0]][0].first <= b)
					unite(vec[idx[0]][0].second, x.second);
			}
		}
		if (cnt >= 2 && idx[1] != i)
		{
			for (auto x : vec[i])
			{
				if (x.first + vec[idx[1]][0].first <= b)
					unite(vec[idx[1]][0].second, x.second);
			}
		}
	}
	for (int i = 0; i < n; i++)
		bel[getfa(i)].pb(i);
	ll ans = 1;
	for (int i = 0; i < n; i++)
	{
		if (i != fa[i])
			continue;
		for (int j = 0; j < bel[i].size(); j++)
			ans = ans * (j + 1) % MOD * quick_pow(++app[col[bel[i][j]]], MOD - 2) % MOD;
		for (int x : bel[i])
			app[col[x]] = 0;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 22912
import numpy as np

N, H = list(map(int, input().split()))
a = []
b = []
for i in range(N):
    temp0, temp1 = list(map(int, input().split()))
    a.append(temp0)
    b.append(temp1)

b = np.array(b)
b = b[max(a) < b]
# b_temp = []
# for i in b:
#     if max(a) <= i:
#         b_temp.append(i)
# b = b_temp
if H <= sum(b):
    # b.sort()
    b = np.sort(b)
    for i in range(len(b)):
        H -= b[-1 - i]
        if H <= 0:
            result = i + 1
            break
else:
    if len(b) != 0:
        H -= sum(b)
    dev = int(H / max(a))
    if H % max(a) != 0:
        dev += 1
    result = len(b) + dev

print(result)


Measured memory_bytes: 20852
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    private static final long MOD = 998244353;

    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();
        final List<Pair> list = IntStream.range(0, k)
            .mapToObj(i -> new Pair(scanner.nextInt(), scanner.nextInt()))
            .collect(Collectors.toList());

        final long[] dp = new long[n + 1];
        dp[1] = 1;
        long current = 0;
        for (int i = 1; i <= n; i++) {
            current += dp[i];
            current %= MOD;
            for (final Pair pair : list) {
                if (pair.l + i <= n) {
                    dp[pair.l + i] += current;
                    dp[pair.l + i] %= MOD;
                }
                if (pair.r + i < n) {
                    dp[pair.r + i + 1] += MOD;
                    dp[pair.r + i + 1] -= current;
                    dp[pair.l + i] %= MOD;
                }
            }
        }

        System.out.println(dp[n]);
    }

    private static class Pair {
        final int l;
        final int r;

        Pair(final int l, final int r) {
            this.l = l;
            this.r = r;
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

Measured memory_bytes: 43692
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE LambdaCase #-}
module Main (main) where

import Control.Monad
import qualified Data.ByteString.Char8 as C8

main :: IO ()
main = readString >>= output . solve

solve :: String -> _
solve = \case
  "ABC" -> "ARC"
  "ARC" -> "ABC"

output :: _ -> IO ()
output = putStrLn

readString :: IO String
readString = C8.unpack <$> C8.getLine

Measured memory_bytes: 3736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int a[];

		a = new int[3];
		int max = 0, min = 1000000;
		int tmp = 0, tmp2 = 0, tmp3 = 0;

		Scanner sc = new Scanner(System.in);

		for (int i = 0; i < 3; ++i) {
			a[i] = sc.nextInt();
			if (max < a[i]) {
				max = a[i];
				tmp = i;
			}
			if (min > a[i]) {
				min = a[i];
				tmp2 = i;
			} else {
				tmp3 = i;
			}
		}
		sc.close();
		for (int i = 0; i < 3; ++i) {
			if (tmp != i && tmp2 != i) {
				tmp3 = i;
			}
		}
		max *= 10;
		max += a[tmp3];
		max += min;
		System.out.println(max);
	}

}


Measured memory_bytes: 22740
#include<iostream>
#include<cmath>

using namespace std;
int main()
{
    int h,r;
    cin >> h >> r;
    if(h+r==0){
        cout << "0" << endl;
    }else if(h+r>0){
        cout << "1" << endl;
    }else{
        cout << "-1" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3100