akhauriyash/Code-Regression huggingface dataset:
use std::vec::Vec;
use std::cmp::*;
use std::collections::BinaryHeap;
use std::cmp::Ordering;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let (h, w, d) = {
    let v: Vec<usize> = read_vec();
    (v[0], v[1], v[2])
  };

  let mut dist = vec![(0, 0); h * w + 1];
  for i in 0..h {
    let v: Vec<usize> = read_vec();
    for (j, e) in v.into_iter().enumerate() {
      dist[e] = (i as i64 + 1, j as i64 + 1);
    }
  }

  let mut lr: Vec<(i64, i64)> = Vec::new();
  let q: usize = read();
  for _ in 0..q {
    let t: Vec<i64> = read_vec();
    lr.push((t[0], t[1]));
  }

  let mut costs = vec![vec![0; (h * w + d - 1) / d]; d];
  for (i, &posit) in dist.iter().enumerate() {
    if i + d < h * w + 1 {
      let (x, y) = decode(i, d);
      costs[x][y] = cost_calc(posit, dist[i + d]);
    }
  }
  let mut sums_costs = vec![vec![0; (h * w + d - 1) / d + 1]; d];

  for (i, line) in costs.iter().enumerate() {
    for (j, &val) in line.iter().enumerate() {
      sums_costs[i][j+1] = sums_costs[i][j] + costs[i][j];
    }
  }
  for (l, r) in lr {
    let (i, j) = decode(l as usize, d);
    let (a, b) = decode(r as usize, d);
    println!("{}", sums_costs[a][b] - sums_costs[i][j]);
  }
}

fn cost_calc(x: (i64, i64), y: (i64, i64)) -> i64 {
  (x.0 - y.0).abs() + (x.1 - y.1).abs()
}

fn decode(x: usize, d: usize) -> (usize, usize) { (x % d, x / d) }

fn encode(i: usize, j: usize, d: usize) -> usize  { d * i + j }


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

struct Node {
    int key;
    Node *prev, *next;
};

Node *nil;

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;

    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node *listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void printList() {
    Node *cur = nil->next;
    printf("%d", cur->key);
    cur = cur->next;
    while (cur != nil) {
        printf(" %d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

int main(void) {
    int key, n, i;
    char line[20];
    scanf("%d", &n);
    init();
    for (i = 0; i < n; i++) {
        scanf("%s %d", line, &key);
        if (line[0] == 'i') {
            insert(key);
        } else if (line[0] == 'd') {
            if (strlen(line) > 6) {
                if (line[6] == 'F') {
                    deleteFirst();
                } else {
                    deleteLast();
                }
            } else {
                deleteKey(key);
            }
        }
    }

    printList();

    return 0;
}

Measured memory_bytes: 32208
# -*- coding: utf-8 -*-
from operator import add


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class SegmentTree:
    def __init__(self, array):
        _len = len(array)
        self.__size = 1 << (_len - 1).bit_length()
        self.__tree = [0] * self.__size + \
            array + [0] * (self.__size - _len)
        self.__ie = 0

        for i in range(self.__size - 1, 0, -1):
            self.__tree[i] = self.__tree[i * 2] + self.__tree[i * 2 + 1]

    def update(self, i, v):
        i += self.__size
        self.__tree[i] = v
        while i:
            i //= 2
            self.__tree[i] = self.__tree[i * 2] + self.__tree[i * 2 + 1]

    def query(self, l, r):
        """[l, r)
        """
        l += self.__size
        r += self.__size
        ret = 0
        while l < r:
            if l & 1:
                ret += self.__tree[l]
                l += 1
            if r & 1:
                r -= 1
                ret += self.__tree[r]
            l //= 2
            r //= 2
        return ret

    def __getitem__(self, key):
        return self.__tree[key + self.__size]


@mt
def slv(N, Q, C, LR):
    LR.sort(key=lambda x: x[2])
    ans = [-1] * Q

    st = SegmentTree([0]*(N+1))
    la = [-1] * (N+1)
    p = 0
    for i, l, r in LR:
        l -= 1
        r -= 1
        for j in range(p, r+1):
            c = C[j]
            if la[c] != -1:
                st.update(la[c], st[la[c]]-1)
            la[c] = j
            st.update(j, st[j]+1)
        p = r+1
        ans[i] = st.query(l, r+1)
    return ans


def main():
    N, Q = read_int_n()
    C = read_int_n()
    LR = [[_, *read_int_n()] for _ in range(Q)]
    print(*slv(N, Q, C, LR), sep='\n')


if __name__ == '__main__':
    main()


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

long long cut(long long a, long long x){
  long long l=1,r=a;
  while(l<r){
    long long y = (l+r)/2;
    if((a+y-1)/y <= x) r = y;
    else l = y+1;
  }
  return l-1;
}

int main(){
  long long N,K,maxA=0;
  cin >> N >> K;
  vector<long long> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
    maxA = max(maxA,A[i]);
  }
  
  long long l=1,r=maxA;
  while(l<r){
    long long x = (l+r)/2;
    long long left = K;
    for(int i=0;i<N;i++){
      left -= cut(A[i],x);
      if(left<0) break;
    }
    if(left>=0) r = x;
    else l = x+1;
  }
  
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 4772
/*
                                Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
 
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
 
#include <bits/stdc++.h>
 
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
 
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x) % M;
        x=(x*x)% M;
        n=n/2;
    }
    return result % M;
}
signed main()
{   jaldi
	int a,b,k,x,y;
	cin>>a>>b>>k;
	if(k==0)
	cout<<a<<" "<<b;
	else
	{	if(a/k!=0)
		cout<<a-k<<" "<<b;
		else
		{	k=k-a;
			b=b-k;
			if(b<0)
			cout<<0<<" "<<0;
			else
			cout<<0<<" "<<b;
		}
	}
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()

#define ll long long
#define ld long double

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    map<char, int> ma;
    cin >> n >> ma['A'] >> ma['B'] >> ma['C'];
    vector<string> q(n);
    for (int i = 0; i < n; ++i) cin >> q[i];
    vector<map<char, int>> pr(n + 1);
    pr[0] = ma;
    string ans = "";
    for (int i = 0; i < n; ++i) {
        string s = q[i];
        if (ma[s[0]] == 0 && ma[s[1]] == 0) {
            if (i == 0) {
                cout << "No\n";
                return 0;
            }
            if (q[i - 1][1] == s[0] || q[i - 1][1] == s[1]) swap(q[i - 1][1], q[i - 1][0]);
            if (pr[i - 1][q[i - 1][1]] == 0) {
                cout << "No\n";
                return 0;
            }
            ans.back() = q[i - 1][0];
            pr[i][q[i - 1][1]] -= 2;
            pr[i][q[i - 1][0]] += 2;
            ma = pr[i];
            char ch = 'A';
            while (ch == q[i - 1][0] || ch == q[i - 1][1]) ++ch;
            ans.pb(ch);
            ++ma[ch];
            --ma[q[i - 1][0]];
        } else {
            if (ma[s[0]] == 0) {
                ans.pb(s[0]);
                ++ma[s[0]];
                --ma[s[1]];
            } else {
                ans.pb(s[1]);
                ++ma[s[1]];
                --ma[s[0]];
            }
        }
        pr[i + 1] = ma;
    }
    cout << "Yes\n";
    for (auto x : ans) cout << x << '\n';
    return 0;
}


Measured memory_bytes: 25112
// B - Grid Compression
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	int H,W; cin>>H>>W;
	vector<string> A(H);
	rep(i, H) cin>>A[i];

	vector<bool> row(H, false), col(W, false);
	rep(h, H) rep(w, W)
		if(A[h][w] == '#') row[h] = col[w] = true;

	rep(h, H)
		if(row[h]){
			rep(w, W) if(col[w]) cout<<A[h][w];
			puts("");
		}
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

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

    return 0;
}


Measured memory_bytes: 3652
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9+5;
const ll INF=1e18+5;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if(s.size()==1) {
    cout << 'D' << endl;
    return 0;
  }
  if(s[s.size()-1]=='?') {
    s[s.size()-1]='D';
  }
  for(int i=0; i<s.size(); i++) {
    if(i==0&&s[0]=='?') {
      if(s[i+1]=='P') {
        s[0]='D';
      }
      else {
        s[0]='P';
      }
      continue;
    }
    if(s[i]=='?'&&s[i-1]=='P') {
      s[i]='D';
    }
    else if(s[i]=='?'&&s[i-1]=='D') {
      if(s[i+1]=='D') {
        s[i]='P';
      }
      else if(s[i+1]=='P') {
        s[i]='D';
      }
      else {
        s[i]='P';
      }
    }
  }
  cout << s << endl;
}

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

int main() {
	int n;
	string s;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s == "Y") {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
	return 0;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    if (a < k && a <= b) {
        cout << -1 << endl;
    } else if (a >= k) {
        cout << 1 << endl;
    } else {
        cout << ((k - b - 1) / (a - b)) * 2 + 1 << endl;
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

struct zero_seq
{
    ll left, len, right;
};
int main()
{
    ll n = in(), k = in();
    string s; cin >> s;

    ll lefcnt = 0;
    vector<zero_seq>zv;
    REP(i, n) {
        if (s[i] == '1') {
            ++lefcnt;
        } else {
            zv.push_back(zero_seq{ lefcnt, 0, 0 });
            lefcnt = 0;
            if (zv.size() > 1)(*(zv.end() - 2)).right = zv.back().left;
            while (true) {
                ++zv.back().len;
                if (i == n - 1 || s[i + 1] == '1')break;
                ++i;
            }
        }
    }
    if (zv.size() <= k) {
        cout << n << endl;
    } else {
        zv.back().right = lefcnt;
        ll tmp = 0;
        REP(i, k) tmp += zv[i].left + zv[i].len * 2 + zv[i].right;
        tmp += zv[0].left + zv[k - 1].right;
        tmp /= 2;

        ll ans = tmp;
        for (ll i = k; i < zv.size(); ++i) {
            tmp -= zv[i - k].left + zv[i - k].len;
            tmp += zv[i].len + zv[i].right;
            ans = max(ans, tmp);
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 2104
n,*a=`dd`.split.map &:to_i
v=[0]
a.each{|e|v<<v[-1]+e}
r=[0,Float::INFINITY]
(2..n-2).each{|maxc|
	r0=r1=[0,Float::INFINITY]
	v0=-~v[maxc]/2
	maxb=(1...maxc).bsearch{|maxb|v0<=v[maxb]}||maxc
	[maxb,maxb-1].each{|maxb|
		r0=[r0,[v[maxb],v[maxc]-v[maxb]].minmax].min_by{|x,y|y-x}
	}
	v1=-~(v[n]-v[maxc])/2
	maxd=(1...n).bsearch{|maxd|v1<=v[maxd]-v[maxc]}||n
	[maxd,maxd-1].each{|maxd|
		r1=[r1,[v[maxd]-v[maxc],v[n]-v[maxd]].minmax].min_by{|x,y|y-x}
	}
	r=[r,(r0+r1).minmax].min_by{|x,y|y-x}
}
p r[1]-r[0]

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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            //ここから
            int[] str = IO.ReadLineToIntArray();
            int n = str[0];
            int l = str[1];
            int sum=0;

            int ans;
            for(int i = 1; i < n+1; i++)
            {
                sum += l + i - 1;
            }

            if (l >= 1)
            {
                ans = sum - l;
            }
            else
            {
                if (l + n - 1 >= 0)
                {
                    ans = sum;
                }
                else
                {
                    ans = sum - (l + n - 1);
                }
            }
            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }

    class Func
    {
        long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }
        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray() { return Console.ReadLine().Split(' ').ToArray(); }
        static public int[] ReadLineToIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>


#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (10e9 + 7)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}


void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}


lli gcd(lli a, lli b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result 
	x = x % p;  // Update x if it is more than or equal to p 
	while (y > 0) {
		// If y is odd, multiply x with result 
		if (y & 1)res = (res*x) % p;
		// y must be even now 
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n; cin >> n; vector<lli>arr(n+1);
	for (int i = 1; i <= n; i++)cin >> arr[i];
	vector<lli>dp(n + 1);
	dp[1] = 0; dp[2] = abs(arr[1] - arr[2]);
	for (int i = 3; i <= n; i++) {
		dp[i] = min(abs(arr[i] - arr[i - 1]) + dp[i - 1], dp[i - 2] + abs(arr[i] - arr[i - 2]));
	}
	cout << dp[n];
	//system("PAUSE");
}

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

using namespace std;

const int N = 1e6;
const int MOD = 1e9 + 7;

long long on[70], off[70];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    long long x;
    scanf("%lld", &x);
    for (int j = 0; j < 61; j++) {
      if ((x & ((1LL << j)))) {
        on[j]++;
      } else {
        off[j]++;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < 61; i++) {
    long long cnt = (on[i] * off[i]) % MOD;
    long long pew = (1LL << i) % MOD;
    long long tmp = (cnt * pew) % MOD;
    ans += tmp;
    ans %= MOD;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
      Scanner in = new Scanner(System.in);

      int x = in.nextInt();
      int y = in.nextInt();
      int z = in.nextInt();

      in.close();

      int ans = (x - z) / (y + z);

      System.out.println(ans);
    }
}


Measured memory_bytes: 21972
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n";
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;

int main(){
	migmig;
	int a,b,c;
	cin>>a>>b>>c;
	int o=a+b;
	int t=b+c;
	int tt=c+a;
	cout<<min(o,min(t,tt));
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll fast(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)
        res*=a;
        a=a*a;
        b>>=1;
    }
    return res;
}
int main()
{
        ll n;
        cin>>n;
        ll h=log2(n)+1;
        ll sum=1;
        for(ll i=1;i<h;i++){
            sum+=fast(2LL,i);
        }
        cout<<sum<<endl;
        //cout<<fast(2,5)<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <list>
#include <string>
#include <map>
#include <numeric>
#include <queue>
#include <stack>

using namespace std;
using ll = long long;

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

int main() {

	int n, k, Max = 0;;
	int a[100000] = { 0 };

	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		Max = max(Max, a[i]);
		if (i > 0) {
			a[i] = gcd(a[i - 1], a[i]);
		}
	}

	if (Max >= k && k%a[n - 1] == 0)
		cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long res=0,a[100005],b[100005],i,n,x;
int main()
{
    cin>>n;
    n++;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<n;i++)
    {
        cin>>b[i];
        x=min(a[i],b[i]);
        res+=x;
        a[i]-=x;
        b[i]-=x;
        x=min(a[i+1],b[i]);
        res+=x;
        a[i+1]-=x;
        b[i]-=x;
    }
    cout<<res;
    return 0;
}


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

using namespace std;

const int INF = 1000000000;

int main()
{
    ios_base::sync_with_stdio(0);
    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i] >> b[i];
    vector<int> dp(h + 1, INF);
    for (int i = 1; i <= h; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (i - a[j] > 0)
                dp[i] = min(dp[i], dp[i - a[j]] + b[j]);
            else
                dp[i] = min(dp[i], b[j]);
        }
    }
    cout << dp[h];
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
const int maxn=100010;
const ll mod=1e9+7;
bool b[maxn];
ll dp[maxn];
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%d",&x);
		b[x]=1;
	}
	dp[0]=1;
	if(b[1])
	{
		dp[1]=0;
	}
	else
	{
		dp[1]=1;
	}
	for(i=2;i<=n;i++)
	{
		dp[i]=dp[i-1]+dp[i-2];
		dp[i]=dp[i]%mod;
		if(b[i])
		{
			dp[i]=0;
		}
	}
	printf("%d",dp[n]);
	return 0;
}


Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<unordered_map>
#define int long long
const int maxn=2e5+5;
typedef long long ll; 
using namespace std;
int vis[maxn];
int a[maxn];
signed main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>a[i];
    	vis[a[i]]++;
    } 
    ll ans=0;
    for(int i=1;i<=n;i++){
    	if(vis[i]>0){
         ans+=(vis[i]*(vis[i]-1)/2);
       }
    }
    for(int i=1;i<=n;i++){
    	if(vis[a[i]]>0){
    		cout<<ans-(vis[a[i]]-1)<<endl;
    	}
    	else{
    		cout<<ans<<endl;
    	}
    }
	return 0;
}

Measured memory_bytes: 4736
from collections import Counter

n = int(input())
A = [int(i) for i in input().split()]

S = [0] * (n + 1)
for i in range(1, n + 1):
    S[i] = S[i - 1] + A[i - 1]
    
S = Counter(S)
ans = 0
for v in S.values():
    ans += v * (v - 1) // 2
        
print(ans)

Measured memory_bytes: 41504
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

typedef long long ll;

struct tmp {
    int b;
    long c;
    bool operator<(const tmp &another) const
    {
        return c < another.c;
    };
};

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

    int N, M;
    cin >> N >> M;

    vector<long> A(N);
    vector<tmp> S(M);

    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    int tmp1;
    long tmp2;
    for (int j = 0; j < M; j++) {
        cin >> tmp1 >> tmp2;
        tmp t = {
                tmp1, tmp2
        };
        S[j] = t;
    }
    sort(A.begin(), A.end());
    sort(S.begin(), S.end());
    int j = 0;
    for (int i = M-1; i >= 0; i--) {
        int tmp = S[i].b;
        long tmp2 = S[i].c;
        while (tmp2 > A[j] && tmp > 0) {
            A[j] = tmp2;
            j++;
            tmp--;
        }
    }
    cout << accumulate(A.begin(), A.end(), 0l) << endl;

    return 0;
}

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

struct bar{int h, p, q; bool operator>(const bar &b)const{return h>b.h;}};

int main(){
    int n, m, a;
    while(cin >> n >> m >> a, n+m+a){
        vector<bar> v;
        for(int i=0; i < m; i++){
            bar b;
            cin >> b.h >> b.p >> b.q;
            v.push_back(b);
        }
        sort(v.begin(), v.end(), greater<bar>());

        for(int i=0; i < v.size(); i++){
            if(v[i].p == a) a = v[i].q;
            else if(v[i].q == a) a = v[i].p;
        }
        cout << a << endl;
    }
}

Measured memory_bytes: 1244
package main

import (
	"fmt"
)

func main() {
	var mid, fin, makeup int
	var grade rune
	for i := 0; ; i++ {
		fmt.Scanln(&mid, &fin, &makeup)

		if (mid + fin + makeup) == -3 {
			break
		} else if (mid == -1) || (fin == -1) {
			grade = 'F'
		} else if (mid + fin) >= 80 {
			grade = 'A'
		} else if (mid + fin) >= 65 {
			grade = 'B'
		} else if (mid + fin) >= 50 {
			grade = 'C'
		} else if (mid + fin) >= 30 {
			if makeup >= 50 {
				grade = 'C'
			} else {
				grade = 'D'
			}
		} else if (mid + fin) < 30 {
			grade = 'F'
		}
		fmt.Printf("%c\n", grade)

	}
}



Measured memory_bytes: 1136
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

vector<int> E(vector<int> a){
    return {a[3], a[1], a[0], a[5], a[4], a[2]};
}
vector<int> W(vector<int> a){
    return E(E(E(a)));
}
vector<int> S(vector<int> a){
    return {a[4], a[0], a[2], a[3], a[5], a[1]};
}
vector<int> N(vector<int> a){
    return S(S(S(a)));
}
random_device rnd;
bool check(vector<int> cu, vector<int> cu2) {
    int counter = 0;
    while (1) {
        int k = rnd() % 2;
        if (k % 2) {
            cu = E(cu);
        } else {
            cu = S(cu);
        }
        if (cu == cu2) {
            return true;
        }
        counter++;
        if (counter == 1000) {
            return false;
        }
    }
}
int main(){
    int n;
    cin >> n;
    vector<vector<int>> ain(n, vector<int>(6));
    for (int i = 0; i < n; i++){
        for (int j = 0; j < 6; j++){
            cin >> ain [i] [j];
        }
    }
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            if (check(ain [i], ain[j])){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


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

int main(){
  int W,a,b,D;
  cin>>W>>a>>b;
  if(a-b>=0) D=a-b;
  else if(a-b<0) D=b-a;

  if(D-W>0) cout<<D-W<<endl;
  else cout<<'0'<<endl;
  
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
s={}
for i in a:
  if i in s:
    s[i]+=1
  else:
    s[i]=1
i=0
current=40
l=0
ans=0
while current!=0 and i<n:
  l=i
  while a[i]>=pow(2,current-1):
    i+=1
    if i==n:
      break
  r=i
  for j in range(l,r):
    if s[a[j]]==0:
      continue
    if pow(2,current)-a[j] in s:
      if a[j]==pow(2,current-1):
        if s[a[j]]>=2:
          ans+=1
          s[a[j]]-=2
      else:
        if s[pow(2,current)-a[j]]>0:
          s[pow(2,current)-a[j]]-=1
          s[a[j]]-=1
          ans+=1
  current-=1
print(ans)

Measured memory_bytes: 126332
n = int(raw_input())
a = map(int, raw_input().split())
b = map(int, raw_input().split())
d = sum(b) - sum(a)
if d < 0:
    print "No"
elif all([i==j for i,j in zip(a,b)]):
    print "Yes"
else:
    ct = 0
    for i,j in zip(a,b):
        if i < j:
            ct += (j-i+1) / 2
    if ct <= d:
        print "Yes"
    else:
        print "No"


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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

// #define INF 1e9

int main(){
  string S;
  cin >> S;
  if(S[0] == S[1] && S[1] == S[2] && S[0] == S[2]){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  ll ans=0;
  ll cnt=0;
  rep(i,n){
    ll a,b; cin>>a>>b;
    if(a==b){
      cnt++;
    }else{
      chmax(ans,cnt);
      cnt=0;
    }
  }
  chmax(ans,cnt);
  if(ans>=3) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        x: usize,
        a: [usize; m],
    }

    let mut cnt = 0;
    for i in 0..m {
        if a[i] > x {
            break;
        }
        cnt = i + 1;
    }

    let ans = min(cnt, m - cnt);

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


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define mxn 200005
using namespace std;

typedef long long ll;

int N, arr[mxn];
ll sol;
map<int, int>M;

int main(){
    //freopen("a.in","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N;

    for (int i = 0; i < N; i++)
        cin >> arr[i];
    int sum, res;
    for (int i = N-1; i >= 0; i--){
        sum = i + arr[i];
        res = i - arr[i];
        sol += M[sum];
        M[res]++;
    }
    cout << sol << "\n";
    return 0;
}


Measured memory_bytes: 21392
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int64_t FastPow(int64_t n, int64_t m){
    if(m==0) return 1;
    if(m==1) return n;

    int64_t v=FastPow(n,m/2);
    v*=v;
    v%=MOD;
    if(m%2){
        v*=n;
        v%=MOD;
    }
    return v;
}

int64_t RevS(int64_t n){
    return FastPow(n,MOD-2);
}

int64_t Factorical(int64_t n, int64_t m){
    int64_t v=1;
    _rep(i,n,n-m+1){
        v*=i;
        v%=MOD;
    }
    return v;
}

int main(){
    int X,Y; cin>>X>>Y;

    int64_t a,b;
    if(2*X-Y>=0 && (2*X-Y)%3==0) a=(2*X-Y)/3;
    else a=-1;
    if(2*Y-X>=0 && (2*Y-X)%3==0) b=(2*Y-X)/3;
    else b=-1;

    if(a<0 || b<0){
        cout<<0<<endl;
        return 0;
    }

    int64_t ans=(Factorical(a+b,a+b-max(a,b))*RevS(Factorical(min(a,b),min(a,b))))%MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        boolean judge = false;
        for (int i = n; 0 <= i; i -= 4) {
            if (i % 7 == 0 || i == 0) {
                judge = true;
            }
        }
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
const int maxn = 100000+5;

int A[maxn+1];
int mynew[maxn+1];


int main(){
    //freopen("input.txt", "r", stdin);
    int N;
    cin >> N;
    for(int i = 1; i <= N; ++i)
        cin>>A[i];
    for(int i = 1; i <= N; ++i)
        mynew[ A[i] ] = i;
    for(int i = 1; i <= N; ++i)
        cout<<mynew[i]<<" ";
    return 0;
}



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

int main() {
	int N, tmp, flag = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		if (tmp % 2 == 0) {
			if (tmp % 3 != 0 && tmp % 5 != 0) {
				flag = 1;
			}
		}
	}
	if (flag == 1) cout << "DENIED" << endl;
	else {
		cout << "APPROVED" << endl;
	}
}

Measured memory_bytes: 256
import sys
from bisect import bisect_left

input = sys.stdin.readline
n, q = map(int, input().split())
stx = [tuple(map(int, input().split())) for _ in range(n)]
d = [int(input()) for _ in range(q)]

stx.sort(key=lambda x: x[2])

ans = [-1] * q
jump = [-1] * q
for s, t, x in stx:
    d_start = bisect_left(d, s - x)
    d_stop = bisect_left(d, t - x, lo=d_start)
    while d_start < d_stop:
        if jump[d_start] == -1:
            ans[d_start] = x
            jump[d_start] = d_stop
            d_start += 1
        else:
            d_start = jump[d_start]

for an in ans:
    print(an)


Measured memory_bytes: 53892
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#define inf 2000000001
#define lowbit(o) o&(-o)
using namespace std;
int i,j,k,l,s,n,m,a[305][305];
long long ans;
int main() {
	scanf("%d",&n);
	for (i=1;i<=n;i++) for (j=1;j<=n;j++) scanf("%d",&a[i][j]);
	for (i=1;i<=n;i++) for (j=i+1;j<=n;j++) {
		int gt=inf;
		for (k=1;k<=n;k++) if (k!=i&&k!=j) gt=min(gt,a[i][k]+a[k][j]);
		if (gt<a[i][j]) return puts("-1"),0;
		if (gt>a[i][j]) ans+=a[i][j];
	}
	printf("%lld\n",ans);
	
}


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

using namespace std;

const int N = 200000;

int aa[N];
bool visited[N];

int main() {
	int n; cin >> n;
	long long k; cin >> k;
	for (int i = 0; i < n; i++)
		cin >> aa[i], aa[i]--;
	int i = 0;
	while (!visited[i])
		visited[i] = true, i = aa[i];
	int i_ = 0;
	while (i_ != i && k)
		k--, i_ = aa[i_];
	if (!k) {
		cout << i_ + 1 << '\n';
		return 0;
	}
	int l = 1;
	i_ = aa[i];
	while (i_ != i)
		l++, i_ = aa[i_];
	k %= l;
	i_ = i;
	while (k--)
		i_ = aa[i_];
	cout << i_ + 1 << '\n';
	return 0;
}


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

int n,a[200000],b[200000];
int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",a+i),b[i]=a[i];

	sort(b,b+n);
	for(int i=0;i<n;i++) {
		if(a[i]<=b[n/2-1]) printf("%d\n",b[n/2]);
		else printf("%d\n",b[n/2-1]);
	}

	return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()

const ll inf = 1e18;
const int N = 100100;

ll n, m, k, a[N], dp[N][305], ans;

int main() {
	cin >> n >> m >> k;
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
		dp[i][1] = a[i];
	}
	for (ll i = 2; i <= k; i++) {
		deque<ll> d;
		ll j;
		for (j = max(1LL, i - m); j < i; j++) {
			while (!d.empty() && dp[j][i - 1] >= dp[d.back()][i - 1])
				d.pop_back();
			d.push_back(j);
		}
		for ( ; j <= n; j++) {
			ll mx = dp[d.front()][i - 1];
			dp[j][i] = max(dp[j][i], mx + i * a[j]);
			while (!d.empty() && d.front() <= j - m)
				d.pop_front();
			while (!d.empty() && dp[j][i - 1] >= dp[d.back()][i - 1])
				d.pop_back();
			d.push_back(j);
		}
	}
	for (ll i = 1; i <= n; i++)
		ans = max(ans, dp[i][k]);
	cout << ans;
}


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

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

  if      (N>=64) cout << 64 << endl;
  else if (N>=32) cout << 32 << endl;
  else if (N>=16) cout << 16 << endl;
  else if (N>= 8) cout <<  8 << endl;
  else if (N>= 4) cout <<  4 << endl;
  else if (N>= 2) cout <<  2 << endl;
  else if (N>= 1) cout <<  1 << endl;
}


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

typedef long long ll;
int n;
ll ans, tmp;

int main(){
    scanf("%d", &n);
    for (ll i=1; i<=n; ++i){
        ans += i * (n/i) * (n/i + 1) / 2;
    }
    cout<<ans;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define forn(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define for1(i, n) for (long long i = 1; i <= (long long)(n); ++i)
#define fore(i, l, r) for (long long i = (long long)(l); i <= (long long)(r); ++i)
#define fordn(i, n) for (long long i = (long long)(n) - 1; i >= 0; --i)
#define ford1(i, n) for (long long i = (long long)(n); i >= 1; --i)
#define all(x) (x).begin(), (x).end()
#define PI 3.141592653589793
using namespace std;
using ll = long long;
using ld = long double;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    bool ans = false;
    if(a == b + c) ans = true;
    else if(b == a + c) ans = true;
    else if(c == a + b) ans = true;
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
from sys import stdin
from string import ascii_lowercase


def main():
    s = stdin.readline().rstrip()
    K = int(stdin.readline().rstrip())
    result = []
    for c in ascii_lowercase:
        for text in sorted([s[i:] for i, x in enumerate(s) if x == c]):
            for i in range(len(text)):
                if not text[:i + 1] in result:
                    result.append(text[:i + 1])
                    if len(result) == K:
                        print(result[-1])
                        return


if __name__ == '__main__':
    main()


Measured memory_bytes: 16248
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> vec(n);
    rep(i, n) cin >> vec[i];
    sort(all(vec));

    k = min(n, k);
    for(int i=0; i<k; i++) vec.pop_back();

    ll sum = 0;
    for(int i=0; i<vec.size(); i++){
        sum += vec[i];
    }
    out(sum);
    return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 998244353;

string s;
lli n;
unordered_set<string> mem;
lli dp[e5][3][3][3];


 bool judge(){
	 for(lli i = 0;i < n;i++){
		 if(s[i] != s[0]) return false;
	 }
	 return true;
 }

 bool judge2(){
	 for(lli i = 1;i < n;i++){
		 if(s[i] == s[i-1]) return true;
	 }
	 return false;
 }

 lli dfs(string s){
	 if(mem.count(s)) return 0;
	 mem.insert(s);
	 lli ret = 1;
	 for(lli i = 1;i < n;i++){
		 if(s[i-1] != s[i]){
			 string s_ = s;
			 for(char c = 'a';c <= 'c';c++){
				 if(c != s[i-1] && c != s[i]){
					 s_[i-1] = c;
					 s_[i] = c;
					 ret += dfs(s_);
					 ret %= mod;
					 break;
				 }
			 }
		 }
	 }
	 return ret;
 }

int main(){
	cin >> s;
	n = s.size();
	if(judge()){
		cout << 1 << endl;
		return 0;
	}
	if(n == 3){
		cout << dfs(s) << endl;
		return 0;
	}
	dp[0][0][0][0] = dp[0][1][1][0] = dp[0][2][2][0] = 1;
	for(lli i = 0;i < n;i++){
		for(lli j = 0;j < 3;j++){ // mod
			for(lli k = 0;k < 3;k++){ // prev
				for(lli l = 0;l < 2;l++){ // bool
					for(lli m = 0;m < 3;m++){
						dp[i+1][(j+m)%3][m][l||(k==m)] += dp[i][j][k][l];
						dp[i+1][(j+m)%3][m][l||(k==m)] %= mod;
					}
				}
			}
		}
	}
	lli ans = 0;
	for(lli i = 0;i < n;i++){
		ans = (ans+(s[i]-'a'))%3;
	}
	for(lli i = 0;i < 3;i++){
		cerr << dp[n-1][i][0][1]+dp[n-1][i][1][1]+dp[n-1][i][2][1] << endl;
	}
	if(judge2()) cout << (dp[n-1][ans][0][1]+dp[n-1][ans][1][1]+dp[n-1][ans][2][1])%mod << endl;
	else cout << (dp[n-1][ans][0][1]+dp[n-1][ans][1][1]+dp[n-1][ans][2][1]+1)%mod << endl;
}


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

int main(){
    int n;
    long long a;
     long long minvalue = 1000000;
      long long maxvalue= -1000000;
       long long sum= 0;
       
       cin >> n;
       
       for (int i =0; i < n; i++ ){
           cin >> a;
           if( a < minvalue ) minvalue = a;
           if( a > maxvalue ) maxvalue = a;
           sum += a;
       }
       
       cout << minvalue << " " <<maxvalue << " " << sum << endl;
       
       return 0;
}


Measured memory_bytes: 3120
#include <stdio.h>

int main() {

	int a[110] = {};
	int n, i, count = 0, max = 0;

	while(scanf("%d", &n)!=EOF){
    a[n]++;
    if (max <= a[n]) max = a[n];
    count++;
  }
  for (i = 0; i < count; i++) {
    if (a[i] == max) {
      printf("%d\n", i);
    }
  }
  return 0;
}


Measured memory_bytes: 592
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, k = na()

def modpow(n, p, m):
    if p == 0:
        return 1
    if p % 2 == 0:
        t = modpow(n, p // 2, m)
        return t * t % m
    return n * modpow(n, p - 1, m) % m

d = [0] * (k + 1)

ans = 0
for i in range(k, 0, -1):
    d[i] = modpow(k // i, n, mod)
    j = 2
    while j * i <= k:
        d[i] -= d[j * i]
        j += 1
    ans += d[i] * i % mod

print(ans % mod)

Measured memory_bytes: 11268
/*******************************
Author:Morning_Glory
LANG:C++
Created Time:2019年07月23日 星期二 10时12分43秒
*******************************/
#include <cstdio>
#include <fstream>
#include <algorithm>
using namespace std;
const int maxn = 200005;
//{{{cin
struct IO{
	template<typename T>
	IO & operator>>(T&res){
		res=0;
		bool flag=false;
		char ch;
		while((ch=getchar())>'9'||ch<'0')	 flag|=ch=='-';
		while(ch>='0'&&ch<='9') res=(res<<1)+(res<<3)+(ch^'0'),ch=getchar();
		if (flag)	 res=~res+1;
		return *this;
	}
}cin;
//}}}
int n,m,l,r;
int a[maxn],b[maxn],c[maxn];
bool flag=true;
bool check (int x)
{
	int tl=m,tr=m,ans=c[m];
	c[0]=c[1],c[n+1]=c[n];
	for (;tl>=1&&c[tl]!=c[tl-1]&&c[tr]!=c[tr+1];--tl,++tr)	ans^=1;
	return ans;
}
int main()
{
	cin>>m;
	n=2*m-1;
	for (int i=1;i<=n;++i)	cin>>a[i],b[i]=a[i];
	sort(b+1,b+n+1);
	l=1,r=n;
	while (l<r){
		int mid=(l+r)/2+1;
		for (int i=1;i<=n;++i)	c[i]=a[i]>=b[mid];
		if (check(mid))	l=mid;
		else	r=mid-1;
	}
	printf("%d\n",b[l]);
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    ll zero[65] = {}, one[65] = {}; //桁ごとの数を数える
    ll ans = 0;
    rep (i, 0, n) {
        ll a;
        cin >> a;
        bitset<60> a_bit (a);
        rep (j, 0, 60) {
            if (a_bit[j]) one[j]++;
            else {
                zero[j]++;
            }
        }
    }
    ll sum = 1;
    const ll mod = 1e9 + 7;
    rep (i, 0, 60) {
        ans = (ans + (one[i] * zero[i]) % mod * sum % mod) % mod;
        sum = sum * 2 % mod;
        // cout << i << " " << one[i] << "\n";
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
N = int(input())
d = dict()
for i in range(N):
  let = input()
  if let in d:
    d[let] += 1
  else:
    d[let] = 0
max = 0
res = []
for i in d:
  if d[i]  > max:
    max = d[i]
    res =[i]
  elif d[i] == max:
    res.append(i)
for i in sorted(res):
  print(i)

Measured memory_bytes: 145004
H,W = map(int,input().split())
s = [input() for i in range(H)]

ans = 'Yes'

for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            a = 0
            for dy,dx in [(1,0), (-1,0), (0,1), (0,-1)]:
                if 0 <= i+dy < H and 0 <= j+dx < W and s[i+dy][j+dx] == '#':
                    a = 1
            if a:
                continue
            ans = 'No'
print(ans)

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

#define ll long long
#define INF 1e9

vector <ll> item;
vector <ll> dis;

ll dp(int w, int k) {
    // if (w < 0) return INF;
    if (w == 0) return 0;
    if (dis[w] != INF) return dis[w];

    for (int i = 1; i <= k; i++) {
        if (w >= i) dis[w] = min(dis[w], dp(w-i, k) + abs(item[w]-item[w-i]));
    }

    return dis[w];
}

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

    item.assign(n, 0);
    for (int i = 0; i < n; i++) scanf("%lld", &item[i]);

    dis.assign(n, INF);
    printf("%lld\n", dp(n-1, k));
}


Measured memory_bytes: 8064