akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         //??\??????????????????int????????????
        int iNyuryoku = Integer.parseInt(br.readLine());
        //x?????\???????????°????????????
        double x = Math.pow(iNyuryoku, 3);
        //double??????x???int????????????????????????
        System.out.println("" + (int)x +"");
    }
}

Measured memory_bytes: 24272
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let a = String::from(s.trim());
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let b = String::from(s.trim());
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let c = String::from(s.trim());
    let mut s = [a, b, c];

    let mut next = 0;
    while s[next].len() > 0 {
        next = match s[next].remove(0) {
            'a' => 0,
            'b' => 1,
            _ => 2,
        };
    }

    println!(
        "{}",
        match next {
            0 => 'A',
            1 => 'B',
            _ => 'C',
        },
    );
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m, i, s = 0, c = 0, p;
	cin >> n >> m;
	int a[n];
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
		s = s + a[i];
	}
	if (s % (4 * m) == 0)
		p = s / (4 * m);
	else
		p = (s / (4 * m)) + 1;
	for (i = 0; i < n; i++)
	{
		if (a[i] >= p)
			c++;
	}
	if (c >= m)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 256
fun main() = Thread(null, ::aising2020d, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun aising2020d() {
    val n = readLine()!!.toInt()
    val x = readLine()!!

    val baseBitCount = x.count { it == '1' }.toLong()
    val bitCountToModded = mutableMapOf<Long, Long>()

    for (bitCount in baseBitCount - 1..baseBitCount + 1) {
        if (bitCount == 0L) {
            bitCountToModded[bitCount] = 0
            continue
        }

        var modByBitCount = 0L
        for ((index, c) in x.withIndex()) {
            if (c == '1') {
                modByBitCount += (2L).modPow(n - index - 1L, bitCount)
                modByBitCount %= bitCount
            }
        }
        bitCountToModded[bitCount] = modByBitCount
    }

    val answer = StringBuilder()

    for (i in 0 until n) {
        val currBitCount = baseBitCount + if (x[i] == '0') 1 else -1

        if (currBitCount == 0L) {
            answer.appendln(0)
            continue
        }

        val modPow = (2L).modPow(n - i - 1L, currBitCount)
        var modded = bitCountToModded[currBitCount]!! + if (x[i] == '0') modPow else -modPow
        modded += currBitCount
        modded %= currBitCount

        var currX = modded
        var count = 1

        while (currX > 0) {
            currX %= currX.countOneBits()
            count++
        }

        answer.appendln(count)
    }

    print(answer)
}

private fun Long.modPow(p: Long, m: Long): Long {
    var x = this % m
    var y = p
    var result = 1L
    while (y > 0) {
        if (y % 2 == 1L) result = (result * x) % m
        y = y shr 1
        x = (x * x) % m
    }
    return result
}


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

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


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

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var N = ReadInt();
            var an = ReadSplitInt();
            var hash = new HashSet<int>();
            foreach (var a in an)
                hash.Add(a);

            Console.WriteLine(hash.Max() - hash.Min());
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static IList<string> ReadSplit() => Read().Split().ToList();
        static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
    }
}

Measured memory_bytes: 11360
K = int(input())
dic = {}
x = 0
count = 0
while 1:
    x = (x * 10 + 7) % K
    count += 1
    if x == 0:
        print(count)
        exit()
    if x in dic:
        print(-1)
        exit()
    dic[x] = 1


Measured memory_bytes: 92764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
 
int main(){
  ll A;cin>>A;
  string B;cin>>B;
  ll B2 = (B[0]-'0')*100+(B[2]-'0')*10+(B[3]-'0');
  cout<<ll(A*B2/100)<<endl;
}

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

using namespace std;

int main(void)
{
  int N;
  cin >> N;
  vector<string>  vs(N);
  for(int i = 0; i < N; i++){
    cin >> vs[i];
  }
  for(int i = 1; i < N; i++){
    if(vs[i-1].back() != vs[i].front()){
      cout << "No" << endl;
      return 0;
    }
    for(int j = 0; j < i; j++){
      if(vs[j] == vs[i]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
for i in range(3500):
    for j in range(3500):
        if 4*i*j-n*(i+j)>0 and n*i*j%(4*i*j-n*(i+j))==0:
            print(i,j,n*i*j//(4*i*j-n*(i+j)))
            exit()

Measured memory_bytes: 9184
A,B=map(int,input().split())
A,B=A-1,B-1
print(100,100)

for i in range(50):
  print("."*50+"#"*50)
  a=min(24,A)
  b=min(24,B)
  print(".#"*b+"."*(50-2*b)+"#."*a+"#"*(50-2*a))
  A-=a
  B-=b

Measured memory_bytes: 3060
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h,w = na()

if w == 1 or h == 1:
    print(1)
    exit()

print((h*w+1)//2)

Measured memory_bytes: 3064
btc=[0,0,0,0]
while 1:
    try:
        n,bt=list(map(str,input().split(",")))
        if bt=="A":btc[0]+=1
        if bt=="B":btc[1]+=1
        if bt=="AB":btc[2]+=1
        if bt=="O":btc[3]+=1
    except:break
for i in range(4):
    print(btc[i])


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    cout << (n == m ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <map>
#include <fstream>
#include <bitset>
#include <stack>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;
pii gtmax(map<int, int> asd, int nots = 0) {
	int ans = 0;
	int numb = 0;
	for (auto&i : asd) { if (i.first == nots)continue; if (i.second > ans) { ans = max(ans, i.second); numb = i.first; } }
	return { ans,numb };
}
int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n; cin >> n;
	map<int, int> c1, c2;
	for (int i = 0; i < n; i++) {
		int x; cin >> x; if (i % 2)c1[x]++; else c2[x]++;
	}
	c1[-1] = 0;
	c2[-1] = 0;
	if (c2.rbegin()->second > c1.rbegin()->second)swap(c1, c2);

	pii a1 = gtmax(c1), a2 = gtmax(c2);
	if (a1.first < a2.first) {
		swap(a1, a2);
		swap(c1, c2);
	}
	a2 = gtmax(c2, a1.second);

	int ans1 = (n / 2 - a1.first), ans2 = ( n / 2 - a2.first);
	cout << ans1 + ans2;
	return 0;
}

Measured memory_bytes: 7296
n = int(input())
a = [int(i) for i in input().split()]
d = {}
for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1

ans = 0
for k, v in d.items():
    if (v < k):
        ans += v
    else:
        ans += v - k
print(ans)


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

int main() {
	string sss;
  	cin >> sss;
  int cnt;
  cnt =0;
  for(int i = 0; i < sss.size(); i++){
   	if(sss.at(i) == '1'){
    	cnt = cnt +1;
    	}
    
  }
  
  cout << cnt << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimization ("unroll-loops, no-stack-protector")
#pragma GCC target ("avx")
#pragma GCC target ("avx2")
#pragma GCC target ("fma")
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll dist[100005];
vpll adj[100005];
void bfs01(ll src){
	for (ll i = 0; i < 100005; i++) dist[i] = 1e18;
	dist[src] = 0;
	deque <ll> dq; dq.push_front(src);
	while (!dq.empty()){
		ll u = dq.front(); dq.pop_front();
		for (ll i = 0; i < (ll) adj[u].size(); i++){
			ll v = adj[u][i].fi, w = adj[u][i].se;
			if (dist[u] + w < dist[v]){
				dist[v] = dist[u] + w;
				if (w == 1) dq.pb(v); 
				else dq.push_front(v);
			}
		}
	}
}
int main(){
	fastio;
	ll k; cin >> k;
	for (ll i = 0; i < k; i++){
		adj[i].eb(mp((i + 1) % k, 1LL));
		adj[i].eb(mp((i * 10) % k, 0LL));
	}
	bfs01(1); cout << dist[0] + 1 << endl;
}

Measured memory_bytes: 11800
n,k=map(int,input().split())
INF=10**9+7
def modcomb(n,k,m):
    fac=[0]*(n+1)
    finv=[0]*(n+1)
    inv=[0]*(n+1)
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,n+1):
        fac[i]=fac[i-1]*i%m
        inv[i]=m-inv[m%i]*(m//i)%m
        finv[i]=finv[i-1]*inv[i]%m
    return fac[n]*(finv[k]*finv[n-k]%m)%m
for i in range(1,k+1):
    if n-k>=i-1:
        if k-1==0 and i-1==0:
            a=1
        else:
            a=modcomb(k-1,i-1,INF)
        if n-k+1==0 and i==0:
            b=1
        else:
            b=modcomb(n-k+1,i,INF)
        ans=(a*b)%INF
        print(ans)
    else:
        print(0)


Measured memory_bytes: 42096
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

////////////////////////////////////////////////////////////////////////

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val A = LongArray(N) { sc.next().toLong() }
        val A2 = LongArray(N)
        for (i in 0 until N) {
            A2[i] = A[i] + i
        }
        val m = mutableMapOf<Long, Long>()
        var ans = 0L
        m[A2[0]] = 1L
        for (i in 1 until N) {
            ans += (m[i - A[i]] ?: 0)
            m[A2[i]] = (m[A2[i]] ?: 0) + 1
        }
        pw.println(ans)
    }
}


Measured memory_bytes: 67676
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

answer = sum(B)
for i in range(N-1):
    if A[i+1] - A[i] == 1:
        answer += C[A[i]-1]

print(answer)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

#define INF 1000000009

long n, m, r, res;
long a[205][205];
long b[10];
int id[10];
int fr[10];

void Permutation(int n)
{
	if (n == r + 1)
	{
		long tmp = 0;

		for (int i = 1; i < r; ++i)
			tmp += a[b[id[i]]][b[id[i+1]]];

		if (tmp < res)
			res = tmp;
	}

	for (int i = 1; i <= r; ++i)
		if (!fr[i])
		{
			fr[i] = 1;
			id[n] = i;
			Permutation(n + 1);
			fr[i] = 0;
			id[n] = 0;
		}
}

int main()
{
	long i, j, k;
	long u, v, c;

	cin >> n >> m >> r;

	for (i = 1; i <= n; ++i)
		for (j = 1; j <= n; ++j)
			if (i != j)
				a[i][j] = INF;

	for (i = 1; i <= r; ++i)
		cin >> b[i];

	for (i = 0; i < m; ++i)
	{
		cin >> u >> v >> c;

		if (a[u][v] > c)
		{
			a[u][v] = c;
			a[v][u] = c;	
		}		
	}

	for (k = 1; k <= n; ++k)
		for (i = 1; i <= n; ++i)
			for (j = 1; j <= n; ++j)
				if (a[i][j] > a[i][k] + a[k][j])
					a[i][j] = a[i][k] + a[k][j];

	res = INF;
	Permutation(1);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long; //10^19 < 9223372036854775807
#define REP(i,n) for(ll i=0;i<ll(n);i++)

int main(void)
{
    int N, K;
    cin >> K >> N;

    vector<int> A(N);
    REP (i, N) {
        cin >> A[i];
    }

    vector<int> B(N);
    int maxValue = -1;
    int total = 0;

    REP (i, N) {

        if (i < N-1) {
            B[i] = abs(A[i] - A[i+1]);
        }
        else {
            B[i] = abs(K - A[N-1] + A[0]);
        }

        if (maxValue < B[i]) {
            maxValue = B[i];
        }

        total += B[i];

    }

    cout << total - maxValue << endl;

    return 0;
}


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

typedef long long int LLi;
typedef long long LL;
typedef vector<LLi> VLL;
typedef vector<string> VS;


#define For(i,n) for (LLi i = 0; i < (n); i++)
#define pb push_back

long long max_3(LLi a, LLi b, LLi c){
        return max(a,max(b,c));
        }

string concatenate(std::string const& name, int i)
{
    stringstream s;
    s << name << i;
    return s.str();
}


main()
{
    LLi a=0,b=0,c=0,d=0,e=0,f=0,g,h,j,k,l,m=0,n,o=0,p=0,q=0,r,s,t,u,w,x,y,z, sum=0;
    int i=0;
    LLi co=0, co1=0,co2,ar[5001];
    string str, str1, str2;
    LLi flag=0, flag1=0,flag2=0;
    char ch,ch1,ch2,ch3,ch4,ch5,ch6;
    double dou1,dou2,dou3;
    VLL v,v1,v2,v3,v4,v5,v6,v7,v8;
    VS vs, vs1, vs2;
    pair<char, int> pa12;
    list <LLi> li,li1,li2;
    LLi a1,a2,a3,a4;

    //char Ch[n];
    //strcpy(C, str.c_str());
    x=1;
   // cin>>t;
   //while(t--){
            flag=0,a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,co=0,co1=0,co2=0;
            v.clear(),v1.clear(), v2.clear(),str.clear(),str1.clear(), str2.clear(), vs.clear();
            vector<pair<string, LLi> >vps;
            vector<pair<LLi, LLi> > vp;
            vector<char> vc;
            map<LLi, LLi> mp;
            set<LLi> st;
            set<LLi>:: iterator it;
            dou1=0.0;
            LLi x1,x2,y1,y2;
            vector<int>::iterator its;


        cin>>a>>b>>c;

        swap(a,b);
        swap(a,c);
        cout<<a<<" "<<b<< " "<<c<<endl;





   //}



    return 0;

}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
import java.math.BigInteger;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    BigInteger D = scan.nextBigInteger();
    BigInteger X[] = new BigInteger[N];
    BigInteger Y[] = new BigInteger[N];
    int count = 0;
    BigInteger rlt1, rlt2, rlt;
    BigInteger dd = D.multiply(D);
    for (int i = 0;i < N;i++) {
      X[i] = scan.nextBigInteger();
      Y[i] = scan.nextBigInteger();
      rlt1 = X[i].multiply(X[i]);
      rlt2 = Y[i].multiply(Y[i]);
      rlt = rlt1.add(rlt2);
      if (rlt.compareTo(dd)<=0) {
        count += 1;
      }
    }
    System.out.println(count);
  }
}

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

using namespace std;

typedef long long int ll;

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

  int n;
  cin >> n;
  vector < int > a (n + 1);
  int x = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    x ^= a[i];
  }

  for (int i = 1; i <= n; i++) {
    cout << (a[i] ^ x) << " ";
  }
  cout << '\n';
}


Measured memory_bytes: 3984
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, K = get_ints

test = N / K
amari = N % K

if amari == 0
  puts 0
else
  puts 1
end


Measured memory_bytes: 14404
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] A = new long[n];
        long[] B = new long[n];
        long[] C = new long[n];
        for (int i=0;i<n;i++){
            A[i]=sc.nextInt();
        }
        for (int i=0;i<n;i++){
            B[i]=sc.nextLong();
        }
        for (int i=0;i<n;i++){
            C[i]=sc.nextLong();
        }
        Arrays.sort(A);
        Arrays.sort(B);
        Arrays.sort(C);
        long ans = 0;
        for (int i=0;i<n;i++){
            int min=-1;
            int max=n;
            long a;
            long c;
            while (min+1<max){
                int middle = (min+max)/2;
                if (A[middle]<B[i]){
                    min = middle;
                }else if (A[middle]>=B[i]){
                    max = middle;
                }
            }
            a = min+1;
            min = -1;
            max = n;
            while (min+1<max){
                int middle = (min+max)/2;
                if (C[middle]<=B[i]){
                    min = middle;
                }else if (C[middle]>B[i]){
                    max = middle;
                }
            }
            c = n-min-1;
            ans+=a*c;
        }
        System.out.println(ans);

    }

}


Measured memory_bytes: 66788
#include <stdio.h>
#include <stdlib.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) > (y) ? (y) : (x))

int dsc(const void *a, const void *b){
  long long *A = (long long *)a, *B = (long long *)b;
  if(*A > *B) return  1;
  if(*B > *A) return -1;
  return 0;
}

int
main(int argc, char *argv[])
{
  int n, k;
  long long v[50]; 
  scanf("%d%d", &n, &k);
  int j = 0;
  for(int i = 0; i < n; i++) scanf("%lld", &v[i]);

  long long ans = 0, vsum;

  int l = min(k / 2, n);
  for(int j = 0; j <= l; j++){
    vsum = 0;
    for(int i = 0; i < j; i++){
      vsum += max(v[i], 0);
    }
    for(int i = 0; i < l - j; i++){
      vsum += max(v[n - 1 - i], 0);
    }
    ans = max(ans, vsum);
  }
  

  
  for(l = k / 2 + 1; (l <= k && l <= n); l++){
    for(int j = 0; j <= l; j++){
      long long minus[50] = {};
      int c = 0;
      vsum = 0;
      for(int i = 0; i < j; i++){
	if(v[i] < 0) minus[c++] = v[i];
	vsum += v[i];
      }
      for(int i = 0; i < l - j; i++){
	if(v[n - 1 - i] < 0) minus[c++] = v[n - 1 - i];
	vsum += v[n - 1 - i];
      }
      qsort(minus, c, sizeof(long long), dsc);
      int e = 0;
      while(e < k - l && e < c){
	vsum -= minus[e++];
      }
      ans = max(ans, vsum);
    }
  }

  printf("%lld\n", ans);

  return 0;
}
      
      
		       

  


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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long a = sc.NextLong();
        long b = sc.NextLong();
        long c = sc.NextLong();

        long answer = 0;

        if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
        {
            answer = 0;
        }
        else
        {
            long[] nums = new long[] { a, b, c };
            nums = nums.OrderBy(i => i).ToArray();
            answer = nums[0] * nums[1];
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13396
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto N = readln.chomp.to!int;
    auto ss = new int[][](N, N);
    auto memo = new bool[][](N, N);
    foreach (i; 0..N) foreach (j; 0..N) {
        ss[i][j] = min(i, N-i-1, j, N-j-1);
        memo[i][j] = true;
    }

    void recalc(int i, int j) {
        auto d = ss[i][j] + (memo[i][j] ? 1 : 0);
        static foreach (s; [[1,0], [0,1], [-1,0], [0,-1]]) {{
            auto ii = i+s[0];
            auto jj = j+s[1];
            if (!(ii < 0 || ii >= N || jj < 0 || jj >= N) && ss[ii][jj] > d) {
                ss[ii][jj] = d;
                recalc(ii, jj);
            }
        }}
    }

    int r;
    foreach (p; readln.split.to!(int[])) {
        auto i = (p-1)/N;
        auto j = (p-1)%N;
        r += ss[i][j];
        memo[i][j] = false;
        recalc(i, j);
    }
    writeln(r);
}

Measured memory_bytes: 40288
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

const int MOD = 1e9+7;
class mint {
    ll x;
public:
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    
    mint operator -() const {
        return mint(-x);
    }
    
    mint &operator +=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator -=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator *=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator +(const mint &a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator *(const mint &a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(MOD - 2);
    }

    mint &operator /=(const mint &a) {
        return (*this) *= a.inv();
    }

    mint operator /(const mint &a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream &operator<<(ostream& os, const mint &m) {
        os << m.x;
        return os;
    }
};

const int MAX = 510000;
mint fac[MAX], finv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * mint(i);
        finv[i] = finv[i-1] * mint(i).inv();
    }
}

mint COM (int n, int k) {
    if (n < k) return mint(0);
    if (n < 0 || k < 0) return mint(0);
    // o(k)
    // if (k < MAX) {
    //     mint ret(1);
    //     Rep (i, k) {
    //         ret *= mint(n-i);
    //         ret /= mint(k-i);
    //     }
    //     return ret;
    // }

    return fac[n] * finv[k] * finv[n-k];
}


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

    ll N, A, B, C;
    cin >> N >> A >> B >> C;

    COMinit();

    mint a(A), b(B), c(C);
    a *= mint(100).inv();
    b *= mint(100).inv();
    c *= mint(100).inv();
    a *= (mint(1)-c).inv();
    b *= (mint(1)-c).inv();

    mint ans(0);

    Rep (i, N) {
        ans += mint(N+i) * COM(N-1+i, i) * a.pow(N) * b.pow(i);
    }

    Rep (i, N) {
        ans += mint(N+i) * COM(N-1+i, i) * a.pow(i) * b.pow(N);
    }

    ans *= (mint(1)-c).inv();

    cout << ans << endl;
}

Measured memory_bytes: 8192
// abc143_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int a,b;
  cin >> a >> b;
  if (a-2*b > 0) {
    cout << a-2*b << endl;
  } else {
    cout << "0" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct {int p, l, r;} Node;

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 6468
#include <cstdio>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <array>

int main() {
	
	// 変数宣言
	int N;
	int ans;
	
	// 入力
	scanf("%d", &N);
	
	if(N%2 == 0)
		ans = N;
	else
		ans = N * 2;

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


Measured memory_bytes: 256
import fractions
n, X = list(map(int, input().split()))
x = list(map(int, input().split()))

x = sorted(x+[X])
x_diff = [x[i+1]-x[i] for i in range(n)]
# print(x, x_diff)
ans = x_diff[0]
for i in range(1, n):
    ans = fractions.gcd(ans, x_diff[i])
print(ans)


Measured memory_bytes: 16280
// --------------
// Tejas Pandey  |
// 01 - 09 - 19  |
// ABC #139      |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		ll n;
		cin >> n;
		cout << (n*(n-1))/2 << "\n"; 
	}
	return 0;
}

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


void toposort(vector<vector<int>> &adj,vector<bool> &visited,int start,vector<int> &topo)
{
    visited[start]=true;
    for(int x:adj[start])
    {
        if(!visited[x])
        {
            toposort(adj,visited,x,topo);
        }
    }

    topo.push_back(start);
}



int dfs(vector<vector<int>> &adj,int start,vector<int> &dp)
{
    if(dp[start]!=-1)
    {
        return dp[start];
    }

    int ans=0;
    for(int x:adj[start])
    {
        ans=max(ans,dfs(adj,x,dp)+1);
    }

    dp[start]=ans;
    return ans;
}





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


    vector<vector<int>> adj(n,vector<int>(0));

    for(int x=0;x<m;x++)
    {
        int a,b;
        cin>>a>>b;
        adj[a-1].push_back(b-1);

    }

    // vector<int> dp(n);
    // vector<int> topo;
    // vector<bool> visited(n);
    // bool con=false;
    // int init=0;
    // while(!con)
    // {
    //     toposort(adj,visited,init,topo);
    //     con=true;
    //     for(int x=0;x<n;x++)
    //     {
    //         if(visited[x]==false)
    //         {
    //             init=x;
    //             con=false;
    //             break;
    //         }
    //     }
    
    // }

    // int ans=0;

    // for(int x:topo)
    // {
    //     if(adj[x].size()==0)
    //     {
    //         dp[x]=0;
    //     }
    //     else
    //     {
    //         for(int y:adj[x])
    //         {
    //             dp[x]=max(dp[x],dp[y]+1);
    //         }
            
    //     }
    //     if(dp[x]>ans)
    //     {
    //         ans=dp[x];
    //     }
    //     // cout<<x<<" ";
    // }
    // // cout<<endl;
    // // for(int x: dp)
    // // {
    // //     cout<<x<<" ";    
    // // }
    // cout<<ans<<endl;
    int ans2=0;
    vector<int> dp2(n,-1);
    for (int x=0;x<n;x++)
    {
        ans2=max(ans2,dfs(adj,x,dp2));
    }

    cout<<ans2<<endl;

}

Measured memory_bytes: 9216
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N;
  cin >> N;
  vec<ll> A(N);
  REP(i, N) cin >> A[i];

  for (ll j = 0;; j++) {
    REP(i, N) {
      if (A[i] % 2 == 1) {
        cout << j << endl;
        return 0;
      }
      A[i] >>= 1;
    }
    if (all_of(ALL(A), [](ll Ai) { return Ai == 0; })) {
      cout << j << endl;
    }
  }
  return 0;
}


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


using namespace std;

int main()
{
	int X, A, B;
	cin >> X >> A >> B;

	if (B - A <= 0) {
		cout << "delicious" << endl;
	}
	else if (B - A <= X) {
		cout << "safe" << endl;
	}
	else 
		cout << "dangerous" << endl;


    return 0;
}

Measured memory_bytes: 256
//It is made by Awson on 2018.1.21
    #include <set>
    #include <map>
    #include <cmath>
    #include <ctime>
    #include <queue>
    #include <stack>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <cstdlib>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    #define LL long long
    #define Abs(a) ((a) < 0 ? (-(a)) : (a))
    #define Max(a, b) ((a) > (b) ? (a) : (b))
    #define Min(a, b) ((a) < (b) ? (a) : (b))
    #define Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
    #define writeln(x) (write(x), putchar('\n'))
    #define lowbit(x) ((x)&(-(x)))
    #define y1 yy
    using namespace std;
    const int N = 500000;
    void read(int &x) {
        char ch; bool flag = 0;
        for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar());
        for (x = 0; isdigit(ch); x = (x<<1)+(x<<3)+ch-48, ch = getchar());
        x *= 1-2*flag;
    }
    void write(int x) {
        if (x > 9) write(x/10);
        putchar(x%10+48);
    }
     
    int n, t1, x1, y1, t2, x2, y2;
     
    void work() {
        read(n);
        while (n--) {
    	read(t2), read(x2), read(y2);
    	if (t2-t1 < Abs(x2-x1)+Abs(y2-y1)) {printf("No\n"); return; }
    	if ((t2-t1-Abs(x2-x1)+Abs(y2-y1))%2) {printf("No\n"); return; }
    	t1 = t2, x1 = x2, y1 = y2;
        }
        printf("Yes\n");
    }
    int main() {
        work();
        return 0;
    }

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math

MOD = 1000000007  # type: int

def ncr(n, r, p): 
    # initialize numerator 
    # and denominator 
    num = den = 1 
    for i in range(r): 
        num = (num * (n - i)) % p 
        den = (den * (i + 1)) % p 
    return (num * pow(den, p - 2, p)) % p 

#
# X : X座標
# Y : Y座標
#
def solve(X: int, Y: int):
    # 3 の倍数のとき、(+1,+2) の移動の回数を n
    # n + 2m = X
    # n
    # (+2,+1) の移動の回数を m 
    # 2n + m = Y
    # m

    n = -1
    for m in range(X + 1):

        # print("{} {}".format(m, m / (X + 1) * 100))

        # print('---')
        # print(m)
        # print(X - m)
        # print(Y - (2 * m))

        if (X - m) / 2 == (Y - (2 * m)):
            n = int((X - m) / 2)
            # print("{} {}".format(m, n))
            break

    # print("{} {}".format(m, n))

    if(n == -1):
        print(0)
    else:
        # print(math.factorial(m + n))
        print(ncr((m + n), n, MOD))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*
Author : N_o_o_B
Created : April 26 2020 17:30:16 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;


    int s,w;
    cin >> s >> w;

    cout << (w < s ? "safe":"unsafe") << endl;


    time_taken();
    return 0;
}

Measured memory_bytes: 3800
use std::io::Read;

const MOD: usize = 1_000_000_007;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();

    let blue = k;
    let red = n - k;

    let mut result = String::new();

    let mc = ModComb::init(5000);
    for i in 1..=k {
        if red + 1 < i {
            result.push_str("0\n");
            continue;
        }
        let b = mc.calc(blue - 1, i - 1);
        let r = mc.calc(red + 1, red + 1 - i);
        result.push_str(&format!("{}\n", (b * r) % MOD));
    }

    result.trim().to_string()
}

struct ModComb {
    fac: Vec<usize>,
    finv: Vec<usize>,
}

impl ModComb {
    fn init(max: usize) -> ModComb {
        let mut fac = vec![1; max];
        let mut finv = vec![1; max];
        let mut inv = vec![1; max];
        for i in 2..max {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
        ModComb {
            fac,
            finv,
        }
    }

    fn calc(&self, n: usize, k: usize) -> usize {
        if n < k {
            return 0;
        }
        return self.fac[n] * (self.finv[k] * self.finv[n - k] % MOD) % MOD;
    }
}


Measured memory_bytes: 2288
# -*- coding: utf-8 -*-
import heapq as hq

n = int(input())
a = list(map(lambda x: 0 - int(x), input().split()))
a.sort()

rst = 0
circle = []
hq.heappush(circle, a[0])
for i in a[1:]:
    k = hq.heappop(circle)
    rst += k
    if k < i:
        hq.heappush(circle, i)
        hq.heappush(circle, i)
    else:
        # k == i
        hq.heappush(circle, i)
        hq.heappush(circle, k)

print(-rst)


Measured memory_bytes: 31544
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  
  int ans=1;
  int x=H.at(0);
  
  for(int j=1;j<N;j++){
    x=max(x,H.at(j));
    if(x==H.at(j)){
      ans++;
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  s[k - 1] = tolower(s[k - 1]);
  cout << s << endl;
  return 0;
}

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

int a[100005]={0};

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;++i)cin >> a[i];

    int ans = 0;
    bool inc = false, dec = false;
    for(int i=1;i<n;++i){
        if(!inc && !dec){
            if(a[i] < a[i-1])dec = true;
            else if(a[i] > a[i-1])inc = true;
        }else if(inc){
            if(a[i] < a[i-1]){
                ans++;
                inc = false;
            }
        }else if(dec){
            if(a[i] > a[i-1]){
                ans++;
                dec = false;
            }
        }
    }
    ans++;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
N   = int(input())
A   = [int(temp) for temp in input().split()]
cou = 0

for mak in range(1,N) :
    for j in range(mak,N)[ : : -1] :
        if A[j] < A[j - 1] :
            tem      = int(A[j])
            A[j]     = int(A[j - 1])
            A[j - 1] = int(tem)
            cou = cou + 1
A   = [str(temp) for temp in A]
print(' '.join(A))
print(cou)

Measured memory_bytes: 7752
/*input
3
1 0 0 
*/
#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;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=200005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn],ans[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>arr[i];
	FILL(ans);
	for(int i=n/2+1;i<=n;i++){
		ans[i]=arr[i];
	}
	for(int i=n/2;i>=1;i--){
		int sum=0;
		for(int j=i*2;j<=n;j+=i){
			sum+=ans[j];
		}
		if(arr[i]==sum%2) ans[i]=0;
		else ans[i]=1;
	}
	vector<int> v;
	for(int i=1;i<=n;i++) if(ans[i]==1) v.pb(i);
	cout<<v.size()<<'\n';
	for(auto x:v) cout<<x<<'\n';
}

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

int main() {
    int a[101][101] = {};
    int r, c;
    cin >> r >> c;
    
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            a[i][c] += a[i][j];
            a[r][j] += a[i][j];
            a[r][c] += a[i][j];
        }
    }

    for (int i = 0; i < r + 1; i++) {
        for (int j = 0; j < c + 1; j++) {
            cout << a[i][j];
            if (j < c)  cout << " ";
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3160
import os

def main():
	x = int(input())
	a,b = 0,0
	for i in range(119, -118, -1):
		for j in range(118, -119, -1):
			if i**5 - j**5 == x:
				a = i
				b = j
				break
	print(a,b)				


if __name__ == "__main__":
	main()


Measured memory_bytes: 9056
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n = int(input())
    a = [0] * n
    b = [0] * n
    c = [0] * n
    for i in range(n):
        a[i],b[i],c[i] = readInt()
    for i in range(101):
        for j in range(101):
            for k in range(max(c),max(c)+105):
                res = False
                for l in range(n):
                    if max(k-abs(a[l]-i)-abs(b[l]-j),0)!=c[l]:
                        res = True
                        break
                if res:
                    continue
                else:
                    print(i,j,k)
                    return
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 3064
def chocolate_bar(H: int, W: int)->int:
    # 縦 3 分割
    h1 = H // 3
    h2 = H // 3 + (H % 3)//2
    h3 = H - h1 - h2

    min_diff = (h3 - h1) * W

    # 横 3 分割
    w1 = W // 3
    w2 = W // 3 + (W % 3)//2
    w3 = W - w1 - w2

    min_diff = min(min_diff, (w3 - w1) * H)

    # 縦に分割した後に一方を横分割　
    #  --------
    # |        |
    # |--------|
    # |    |   |
    #  --------
    h1 = round(H/3)
    h2 = H - h1
    w1 = W // 2
    w2 = W - w1

    S = [h1*W, h2*w1, h2*w2]

    min_diff = min(min_diff, max(S)-min(S))

    # 横に分割した後に一方を縦分割
    #  --------
    # |    |   |
    # |    |---|
    # |    |   |
    #  --------
    h1 = H // 2
    h2 = H - h1
    w1 = round(W/3)
    w2 = W - w1

    S = [H*w1, h1*w2, h2*w2]

    min_diff = min(min_diff, max(S)-min(S))

    return min_diff


if __name__ == "__main__":
    H, W = map(int, input().split())
    ans = chocolate_bar(H, W)
    print(ans)


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int A, B;
  scanf("%d %d", &A, &B);
  char buf[64] = { '\0' };
  scanf("%s", buf);
  bool ok = true;
  for (int i = 0; ok and i < A + B + 1; ++i) {
    if (i == A) {
      if (buf[i] != '-') { ok = false; }
    }
    else if (not isdigit(buf[i])) { ok = false; }
  }
  printf("%s\n", ok ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256