akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 100010;
int a[MAXN], visited[MAXN];

int n, k, res;

vector< vector<int> > adj;

int dfs(int u) {
    visited[u] = 1; int depth = 0;

    for (auto v : adj[u]) {
        if (!visited[v]) {
            int d = dfs(v) + 1;
            depth = max(d, depth);
        }
    }

    if (depth == k-1 && a[u] != 1) {
        res++;
        return -1;
    }
    else {
        return depth;
    }
}

int main() {
    GI(n); GI(k); adj.resize(n+1);

    FOR1(i, n) {
        GI(a[i]);
        if (i == 1) continue;

        adj[i].PB(a[i]);
        adj[a[i]].PB(i);
    }

    res = 0;

    if (k == 1) {
        FOR1(i, n) {
            if (a[i] != 1) res++;
        }
        printf("%d\n", res);
        return 0;
    }

    if (a[1] != 1) {
        a[1] = 1; res++;
    }

    dfs(1);
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>
#include <vector>
#include <algorithm>

struct segTree{
	int value[800010];
	void setValue(int ind, int val, int l=1, int r=200000, int v=1)
	{
		if(l==r) value[v] = val;
		else
		{
			int h = (l+r)/2;
			if(ind<=h) setValue(ind,val,l,h,2*v);
			else setValue(ind,val,h+1,r,2*v+1);
			value[v] = value[2*v]<value[2*v+1]?value[2*v]:value[2*v+1];
		}
	}
	int getMin(int L, int R, int l=1, int r=200000, int v=1)
	{
		if(L<=l&&r<=R) return value[v];
		else if(r<L) return 200001;
		else if(R<l) return 200001;
		else
		{
			int h = (l+r)/2;
			int s1 = getMin(L,R,l,h,2*v);
			int s2 = getMin(L,R,h+1,r,2*v+1);
			return s1<s2?s1:s2;
		}
	}
}T1,T2;

struct str{
	int first;
	int second;
	int index;
	int max;
	int min;
}x[200010];
bool cmp1(str a, str b)
{
	return a.first<b.first;
}
bool cmp2(str a, str b)
{
	return a.index<b.index;
}

std::vector<int> V;
int next[200010],size[200010],maxHeight[200010];
int main()
{
	int a;
	scanf("%d",&a);
	for(int i=1;i<=a;i++)
	{
		int b,c;
		scanf("%d%d",&b,&c);
		x[i]={b,c,i};
	}
	std::sort(x+1,x+a+1,cmp1);
	for(int i=1;i<=a;i++)
	{
		size[i] = 1;
		next[i] = i;
		maxHeight[x[i].index] = x[i].second;
	}
	
	for(int i=a;i>=1;i--)
	{
		if(V.empty() || maxHeight[V.back()]<x[i].second) V.push_back(x[i].index);
		else
		{
			while(!V.empty())
			{
				int k = V.back();
				if(maxHeight[k]>x[i].second)
				{
					int s = x[i].index;
					while(s!=next[s]) s = next[s];
					if(size[s]<size[k])
					{
						size[k] += size[s];
						next[s] = k;
						maxHeight[k] = maxHeight[k]>maxHeight[s]?maxHeight[k]:maxHeight[s];
					}
					else
					{
						size[s] += size[k];
						next[k] = s;
						maxHeight[s] = maxHeight[k]>maxHeight[s]?maxHeight[k]:maxHeight[s];
					}
					V.pop_back();
				}
				else break;
			}
			int s = x[i].index;
			while(s!=next[s]) s = next[s];
			V.push_back(s);
		}
	}
	
	for(int i=1;i<=a;i++)
	{
		int s = i;
		while(s!=next[s]) s = next[s];
		printf("%d\n",size[s]);
	}
}

Measured memory_bytes: 9556
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll N;
    cin >> N;
    ll out = 0;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            for(int k=1;k<=N;k++) out += __gcd(__gcd(i,j),k);
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3648
# ABC137D - Summer Vacation
import sys
from heapq import heappop, heappush

readline = sys.stdin.buffer.readline
heappop_max = lambda heap: -heappop(heap)
heappush_max = lambda heap, x: heappush(heap, -x)


def main():
    N, M = map(int, readline().split())
    available_jobs = [[] for _ in range(M + 1)]
    for _ in range(N):
        waiting_days, reward = map(int, readline().split())
        if waiting_days <= M:
            available_jobs[waiting_days].append(reward)
    heap = []
    max_rewards = 0
    for jobs in available_jobs[1:]:
        for job in jobs:
            heappush_max(heap, job)
        if heap:
            max_rewards += heappop_max(heap)
    print(max_rewards)


if __name__ == "__main__":
    main()


Measured memory_bytes: 19284
tmp1 = list(map(int, input().split(" ")))
num = [0 for i in range(10**5)]
for i in range(tmp1[0]):
    tmp = list(map(int, input().split(" ")))
    num[tmp[0]-1] += tmp[1]
tmp = 0
i = 0
while tmp < tmp1[1]:
    tmp = tmp + num[i]
    if tmp >= tmp1[1]:
        print(i+1)
    i = i + 1

Measured memory_bytes: 5924
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>
 
using namespace std;
 
 
bool solve(){
    int a,b,x;
    char ch, ch2;
    int ans = 0, ans2 = 0;
    while(cin>>a){
        cin>> ch>> b>> ch2>> x;
        if(a*a + b*b == x*x) ans++;
        if(a == b) ans2++;
    }
    cout<< ans<< endl;
    cout<< ans2<< endl;
    return true;
}
 
int main(){
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
     
    return 0;
}

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

#define endl "\n"
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(),(x).end()
#define rect return 0
#define pause cout << endl; system("pause")
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(x) (int)(x).size()
#define Pi acos(-1.0)
#define bitcount __builtin_popcountll

#define TupleGet(name, index) std::get<(index)>(name)
#define FOR(a, b, c) for(int (a) = (b); (a) < (c); ++(a))
#define FORs(a, b, c) for(int (a) = (b); (a) <= (c); ++(a))
#define revFOR(a, b, c) for(int (a) = (b); (a) > (c); --(a))
#define revFORs(a, b, c) for(int (a) = (b); (a) >= (c); --(a))
#define foreach(it, a) for(auto it = (a).begin(); it != (a).end(); it++)

using namespace std;

// *** TYPEDEF'S, CONSTANTS AND FUNCTIONS *** //
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tii;
typedef vector<vector<int> > vvi;

/* |T| |I| |P| |S|
@ string abc = "abcdefghijklmnopqrstuvwxyz";
@ 'char' - 'a' ::: порядковый номер латинской буквы
@ 'digit' - '0' or 'digit' - 48 ::: (char) ---> (int)
@ 'A' = dec 65 'Z' = dec 90
  'a' = dec 97 'z' = dec 122
  '0' = dec 48 '9' = dec 57
@ Если страдает скорость ввода:
1) ios::sync_with_stdio(0);
   cin.tie(0);
2) юзать сканф
@ для стринга перевод i-того символа в другой регистр: a[i] = char (a[i] +- 32)  :::  32 == 'a' - 'A'
@ int n (m знаков) :::  n[1] = n / 10^(m-1) ; n[m] = n % 10 ; n[m-1] = (n % 100)/10 ; n[m-2] = (n % 1000)/100...
@ cout << fixed << setprecision(n) ::: n знаков после запятой, без "fixed" - всего n знаков
@ abs(x-y) < EPS ::: равентсво вещественных чисел x и y по точности EPS
@ x + EPS < y  или  x - EPS < y ::: сравнение больше-меньше для вещественных чисел по точности EPS
@ если цифру можешь записать из головы - так и пиши в программе, иначе - пиши ФОРМУЛУ
@ «экспонента» - целое число, показывающее, на сколько надо сдвинуть десятичную запятую в числе ::: 123e2 = 12300 , 123e-4 = 0.0123
@ если задача плохо решается при нумерации с единицы, иногда оказывается намного проще перейти к нумерации с нуля.
  Особенно задачах, где явно надо делить на равные части.
@ while(cin >>)  |||  while (getline(cin, )) ::: считывание, пока даются данные
@ ctrl+Z ::: конец файла в консоли
@ Глобальные массивы, чтобы не было ошибок; размер брать с запасом
@ Количество цифр N числа X в b-ичной записи, N = floor[ log[b](X) ] + 1
@ ios::sync_with_stdio(0); //ввод
@ cin.tie(0); cout.tie(0); //могут быть проблемы в интерактивных задачах (частый ввод-вывод)
*/

void solve() {
    string s;cin>>s;string a = "abc";sort(all(s));
if(a==s) cout << "Yes";
else cout << "No";
}
int main() {
    solve();
    return 0;
}

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

public class Class1
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int K = int.Parse(input[1]);

        Console.WriteLine(N - K + 1);
    }
}


Measured memory_bytes: 11092
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next()-1;
  var ans = "";
  while(n>0){
    ans = String.fromCharCode(n%26+97) + ans;
    n = Math.floor(n/26)-1;
  }
  return n===0?"a"+ans:ans;
}

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

int a[55];
int n,sum;

int main(void)
{
	cin>>n;
	for (int i=1; i<=n; i++)
		cin>>a[i];
	for (int i=1; i<=n; i++)
		for (int j=i; j<=n; j++)
			if (i!=j)
				sum+=a[i]*a[j];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int i=1;
do{
int x=i;
if(x%3==0)cout<<" "<<i;
else {
while(x){if(x%10==3){cout<<" "<<i;break;}x/=10;}
}}while(++i<=n);
cout<<endl;
}

Measured memory_bytes: 1164
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


def solve():
    S = Scanner.string()
    N = len(S)
    K = Scanner.int()
    dp = [[[0 for _ in range(2)] for _ in range(K + 1)] for _ in range(N + 1)]
    dp[0][0][0] = 1
    for i in range(N):
        for j in range(4):
            for k in range(2):
                nd = int(S[i])
                for d in range(10):
                    ni, nj, nk = i + 1, j, k
                    if d != 0:
                        nj += 1
                    if nj > K:
                        continue
                    if k == 0:
                        if d > nd:
                            continue
                        if d < nd:
                            nk += 1
                    dp[ni][nj][nk] += dp[i][j][k]
    print(dp[N][K][0] + dp[N][K][1])


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


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

int main(){
    int N; cin >> N;
    map<string, int> m;
    for (int i = 0; i < N; i++)
    {
        string s; cin >> s;
        m[s]++;
    }

    vector<string> t;
    int cnt = 0;
    for(auto i: m){
        if(i.second>cnt){
            cnt = i.second;
            t.clear();
            t.push_back(i.first);
        } else if(i.second==cnt){
            t.push_back(i.first);
        }
    }    
    for(string s: t){
        cout << s << endl;
    }
}


Measured memory_bytes: 26868
MOD = 10**9 + 7
N, K = map(int,input().split())
A = list(map(int,input().split()))
num1,num2 = 0,0
for i in range(N-1):
  for j in range(i+1,N):
    if A[i]>A[j]: num1 += 1

for i in range(1,N):
  for j in range(i):
    if A[i]>A[j]: num2 += 1

val1 = num1*(K*(K+1)//2)%MOD
val2 = num2*(K*(K-1)//2)%MOD
print((val1+val2)%MOD)

Measured memory_bytes: 41836
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n, a, b;
cin >> n >> a >> b;
int ans = 0;
reps(i,n+1,1){
    string s = to_string(i);
    int num= 0;
    // rep(j,s.size()){
    for(auto c :s){
        num += c - '0';
    }
    if(num>=a && num<=b)
        ans+=i;
}
cout << ans << endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)


//?????§2??¨??????????????° verified AOJ GRL_7_A
#define MAX_V 100000
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u,int v){
    G[u].pb(v);
    G[v].pb(u);
}

// ?¢???§??????DFS??§??¢???
bool dfs(int v){
    used[v]=true;
    rep(i,G[v].size()){
        int u=G[v][i],w=match[u];           //u:v??????????§???????????????? , w:u??¨??????????????°??????????????????
        if(w<0 || (!used[w] && dfs(w))){    //u????????????????????????dfs??§???w????????£???????????? ??????w?????\????????¢??????????????£???(=?¢???§?????????) ??´???
            match[v]=u;
            match[u]=v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(int V){
    int res=0;
    rep(i,MAX_V)match[i]=-1;
    rep(v,V){
        if(match[v]<0){
            rep(i,MAX_V)used[i]=0;
            if( dfs(v) ) res++;       //?¢???§????????????????????°res+=1
        }
    }
    return res;
}

int main(){
    int x,y,e;
    cin>>x>>y>>e;
    rep(i,e){
        int a,b;
        cin>>a>>b;
        add_edge(a,x+b);
    }
    
    cout<<bipartite_matching(x+y)<<endl;
}

Measured memory_bytes: 6064
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int h,w ;
	cin >> h >> w ;
	vvc g(h+2,vc(w+2,'.')) ;
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) cin >> g.at(i).at(j) ;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(g.at(i).at(j)=='#'){
				if(g.at(i-1).at(j)!='#'&&g.at(i+1).at(j)!='#'&&g.at(i).at(j+1)!='#'&&g.at(i).at(j-1)!='#'){
					cout << "No" << endl ;
					return 0 ;
				}
			}
		}
	}
	cout << "Yes" << endl ;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <time.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{
    struct Small_Segment_Tree{
        vector<int> a;
        int l, r;

        private:
        int __summ(int L, int R, int l, int r, int v)
        {
            if (L <= l && r <= R)
                return a[v];
            if (R <= l || r <= L)
                return 0;
            int m = (l + r) / 2;
            return __summ(L, R, l, m, 2 * v + 1) + __summ(L, R, m, r, 2 * v + 2);
        }

        void __set(int P, int l, int r, int v, int V)
        {
            if (l + 1 == r)
            {
                a[v] = V;
                return;
            }
            int m = (l + r) / 2;
            if (P < m)
            {
                __set(P, l, m, 2 * v + 1, V);
                a[v] = a[2 * v + 1] + a[2 * v + 2];
            }
            else
            {
                __set(P, m, r, 2 * v + 2, V);
                a[v] = a[2 * v + 1] + a[2 * v + 2];
            }
        }

        public:
        int Summ(int L, int R)
        {
            if (R < L)
                return 0;
            return __summ(L, R + 1, l, r, 0);
        }

        void Set(int P, int V)
        {
            __set(P, l, r, 0, V);
        }

        Small_Segment_Tree(int _n)
        {
            a.resize(4 * _n);
            l = 0, r = _n;
        }
    };
};

using std::__gcd;
using namespace MySpace;

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
const ll MOD = 1e9 + 7;


ll a, b, c, d;

ll solve(ll x)
{
    ll ans = x - x / c - x / d;
    if (c * d > MOD * MOD)
        return ans;
    ll g = c * d / __gcd(c, d);
    ans += x / g;
    return ans;
}

signed main()
{
    srand(time(NULL));
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> a >> b >> c >> d;
    cout << solve(b) - solve(a - 1);
}


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

namespace AtCoder
{
	public class Program
	{
		// ABC108-B
		static void Main(string[] args)
		{
			string[] vs = Console.ReadLine().Split();
			int x1 = int.Parse(vs[0]);
			int y1 = int.Parse(vs[1]);
			int x2 = int.Parse(vs[2]);
			int y2 = int.Parse(vs[3]);
			int x3, x4, y3, y4;
			int dx = x2 - x1;
			int dy = y2 - y1;
			x3 = x2 - dy;
			y3 = y2 + dx;
			x4 = x3 - dx;
			y4 = y3 - dy;
			Console.WriteLine(string.Format("{0} {1} {2} {3}", x3, y3, x4, y4));
		}
	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

int N, C;
vector<vs32> col;
vector<vs32> D;

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

    cin >> N >> C;
    col.resize(3, vs32(C, 0));
    D.resize(C, vs32(C, 0));

    rep (i, C) rep (j, C) cin >> D[i][j];

    int c;
    for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j)
    {
        cin >> c;
        --c;
        ++col[(i + j) % 3][c];
    }

    u64 ans = 1e12;
    u64 temp;
    rep (i, C)
    {
        rep (j, C)
        {
            if (j == i) continue;
            rep (k, C)
            {
                if (k == i || k == j) continue;
                temp = 0;
                rep (x, C)
                {
                    temp += D[x][i] * col[0][x];
                    temp += D[x][j] * col[1][x];
                    temp += D[x][k] * col[2][x];
                }
                ans = MIN(ans, temp);
            }
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    private static StringTokenizer st;

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        int N = readInt();
        if (N % 1000 == 0) pw.println(0);
        else pw.println(1000 - N % 1000);
        pw.close();
    }
}


Measured memory_bytes: 32756
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int A, B, C, D;
    std::cin >> A >> B >> C >> D;

    int ans = 0;
    if (B <= C || A >= D) {
        ans = 0;
    } else {
        if (A <= C && D <= B) {
            ans = D - C;
        } else if (C <= A && B <= D) {
            ans = B - A;
        } else if (A <= C && B <= D) {
            ans = B - C;
        } else if (C <= A && D <= B) {
            ans = D - A;
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LiangJiaJun main
using namespace std;
double ans=0;
int n,k;
int LiangJiaJun(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        double now=1.0/n;
        if(i>=k){
            ans+=now;
        }
        else{
            int g=i;
            while(g<k){
                g<<=1;
                now/=2.0;
            }
            ans+=now;
        }
    }
    printf("%.10f\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b;
	int sum;

	scanf("%d %d", &a, &b);

	sum = a + b;

	if (sum % 2 != 0) printf("%d", sum / 2 + 1);
	else printf("%d", sum / 2);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int n, t;
    scanf("%d%d", &n, &t);
    vector<pair<int, int>> vec(n);
    rep(i, n) {
        int a, b;
        scanf("%d%d", &a, &b);
        vec.at(i) = make_pair(a, b);
    }
    sort(vec.begin(), vec.end());
    rep(i, n) {
        if(vec[i].second <= t) {
            int ans = vec[i].first;
            printf("%d\n", ans);
            return 0;
        }
    }
    printf("TLE\n");
    return 0;
}

Measured memory_bytes: 3732
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){

    int n;
    cin >> n;

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

    int ans = 0;
    int previous = -1;
    for(int i = 0; i < n; i++){
        ans += b[a[i]];
        // cout << previous << endl;
        if(previous + 1 == a[i]){
            ans += c[previous];
        }
        previous = a[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>
#include <vector>
#include <iomanip>
#define lsb(x) ((x) & -(x))
using namespace std;

const int NMAX = 200010;
typedef long long i64;
int n;
i64 aib[NMAX];

i64 query(int x)
{
    i64 ans = 0;
    while (x)
        ans = max(ans, aib[x]), x -= lsb(x);
    return ans;
}
void update(i64 val, int poz)
{
    while (poz <= n)
        aib[poz] = max(aib[poz], val), poz += lsb(poz);
}

int h[NMAX], val[NMAX];

int main()
{
    scanf("%d", &n);

    for (int i = 1; i <= n; i++)
        scanf("%d", h + i);

    for (int i = 1; i <= n; i++)
        scanf("%d", val + i);

    for (int i = 1; i <= n; i++) {
        i64 prev = query(h[i]);
        prev += val[i];

        update(prev, h[i]);
    }

    cout << query(n) << '\n';

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}




int d[10];
int n,k;

bool check(int num){
  while(num){
    int m = num%10;
    rep(i,k) if(m == d[i]) return false;
    num/=10;
  }
  return true;
}


int main(){
  cin >> n >> k;
  rep(i,k) cin >> d[i];

  for(int i = n; i < 100000; i++){
    int num = i;
    if(check(num)){
       cout << num << endl;
       return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 256
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

for i, lis in enumerate(itertools.permutations([i for i in range(1, N + 1)])):
  lis = list(lis)
  if lis == P:
    a = i
  if lis == Q:
    b = i

print(abs(a - b))


Measured memory_bytes: 73864
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	map<string, int> mp;
	rep(i, n)
	{
		string s; cin >> s;
		++mp[s];
	}
	int mx = 0;
	for (auto p : mp)
	{
		mx = max(mx, p.second);
	}
	vector<string> res;
	for (auto p : mp)
	{
		if (p.second == mx)res.push_back(p.first);
	}
	sort(all(res));
	for (string x : res)cout << x << endl;
}

Measured memory_bytes: 26868
#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; 
 
typedef long long int ll;
typedef long int li;

const ll mod = 1000000007;
const ll inf = 1000000000000000000;

typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vli> vvli;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef map<ll, ll> mll;
typedef map<ll, string> mls;
typedef map<string, ll> msl;
typedef pair<ll, ll> pll;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#pragma GCC optimize ("-O3")
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(), v.end()
#define mini(a) *min_element(all(a))
#define maxi(a) *max_element(all(a))
#define tol(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define tou(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define FOR(i, j, k, in) for(li i=j; i<k; i+=in)
#define RFOR(i, j, k, de) for(li i=j; i>=k; i-=de)
#define rep(i,j,k) FOR(i, j, k, 1)
#define rrep(i,j,k) RFOR(i, j, k, 1)
#define repc(v) for(auto it=v.begin(); it!=v.end(); it++)
#define rrepc(v) for(auto it=v.rbegin(); it!=v.rend(); it--)
#define T ll t; cin>>t; while(t--)

ll gen(){
    ll temp;
    cin>>temp;
    return temp;
}

ll power(ll a, ll b, ll m){    
    ll res=1;
    while(b>0){
        if(b&1){
            res=(res*a)%m;
            b--;
        }
        a=(a*a)%m;
        b=b>>1;
    }
    return res;
}

ll gcd(ll a, ll b){if(a==0)return b; else return gcd(b%a, a);}
ll lcm(ll a, ll b){return (a*b)/gcd(a,b);}

#define inpt(v) generate(all(v),gen)
#define sum(v) accumulate(all(v),0LL)
#define vpll vector<pll>
#define umap unordered_map
#define uset unordered_set
#define print(v) rep(i,0,n) cout<<v[i]<<" ";

int32_t main(){
  FAST

    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 

    ll n;
    cin>>n;
    vll v(n);
    inpt(v);

    if(n <= 2)
    cout<<0;

    else{
        ll c=0;
        rep(i,0,n-2){
          rep(j,i+1,n-1){
            rep(k,j+1,n){
              if(v[i] + v[j] > v[k] and v[j] + v[k] > v[i] and v[i] + v[k] > v[j] and v[i] != v[j] and v[j] != v[k] and v[k] != v[i])
              c++; 
            }
          }
        }
        cout<<c;
    }

  
  return 0;
}










Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for (int i = m; i < n; i++)
using str = string;
using vi = vector<int>;

int d[2019];
int d2[2019];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);

  vi a(200010);
  str s;
  cin >> s;
  int n = s.length();
  int ans = 0;
  rep(i, n) a[i] = s[i] - '0';
  d2[a[0]]++;
  REP(i, 1, n) {
    d[a[i]]++;
    rep(j, 2019) { d[(10 * j + a[i]) % 2019] += d2[j]; }
    ans += d[0];
    rep(j, 2019) {
      d2[j] = d[j];
      d[j] = 0;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int main()
{
    string s1, s2;
    cin >> s1;
    cin >> s2;
    reverse(s2.begin(), s2.end());
    string ans = "NO";

    if (s1 == s2) ans = "YES";

    cout << ans << endl;

    return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  sort(v.rbegin(), v.rend());
  
  int64_t ans = 0;
  for(int i=k; i<n; i++) ans += v[i];
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;
const int maxn=2e5+10;
ll a[maxn],b[maxn];
int main()
{
//	ios::sync_with_stdio(false);
//	cin.tie(0);cout.tie(0);
	int n,m;
	ll k;
	scanf("%d%d%lld",&n,&m,&k);
	a[0]=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		a[i]=a[i-1]+a[i];
	}
	b[0]=0;
	for(int i=1;i<=m;i++){
		scanf("%d",&b[i]);
		b[i]=b[i-1]+b[i];
	}
	int ans=0;
	for(int i=0,j=m;i<=n;i++){
		if(a[i]>k)break;
		while(b[j]>k-a[i]){
			j--;
		}
		ans=max(ans,i+j);
	}
	printf("%d\n",ans);
 	return 0;
}



Measured memory_bytes: 6900
A, B, Q = [int(_) for _ in input().split()]
S = [int(input()) for i in range(A)]
T = [int(input()) for i in range(B)]
Q = [int(input()) for i in range(Q)]

#print(S, T, Q)

def calc_m(xs):
    return [(a + b) / 2 for a, b in zip(xs, xs[1:])]

sm = calc_m(S)
tm = calc_m(T)

#print(sm)
#print(tm)

import bisect

def calc_nearest_0(xs, y, ym):
    result = []
    i = 0
    for x in xs:
        while i < len(ym) and x >= ym[i]:
            i += 1
        result.append(y[i])
    return result

def calc_nearest(xs, y, ym):
    result = []
    for x in xs:
        i = bisect.bisect(ym, x)
        result.append(y[i])
    return result

sn = calc_nearest(S, T, tm)
tn = calc_nearest(T, S, sm)

#print(sn)
#print(tn)

def solve(q, S, T, sn, tn):
    nsp = bisect.bisect(S, q)
    ntp = bisect.bisect(T, q)

    rs = []

    if 0 <= nsp < len(S):
        rs.append(abs(S[nsp] - q) + abs(S[nsp] - sn[nsp]))
    nsp -= 1
    if 0 <= nsp < len(S):
        rs.append(abs(S[nsp] - q) + abs(S[nsp] - sn[nsp]))

    if 0 <= ntp < len(T):
        rs.append(abs(T[ntp] - q) + abs(T[ntp] - tn[ntp]))
    ntp -= 1
    if 0 <= ntp < len(T):
        rs.append(abs(T[ntp] - q) + abs(T[ntp] - tn[ntp]))

    # print("Q", q, S, T, sn, tn, r1, r2)
    return min(rs)

for q in Q:
    print(solve(q, S, T, sn, tn))


Measured memory_bytes: 24876
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#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 MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int A, B, Q; cin >> A >> B >> Q;
    vector<ll> s(A + 2), t(B + 2), ANS(Q);
    s[0] = t[0] = -LLINF>>2;
    s[A + 1] = t[B + 1] = LLINF>>22;
    REP(i, A) cin >> s[i + 1];
    REP(i, B) cin >> t[i + 1];
    REP(i, Q) {
        ll x; cin >> x;
        ll sa, sb, tc, td;
        int itr = lower_bound(ALL(s), x) - s.begin();
        sa = s[itr - 1];
        sb = s[itr];
        itr = lower_bound(ALL(t), x) - t.begin();
        tc = t[itr - 1];
        td = t[itr];
        ll dx[] = {sa,sa,sb,sb,tc,tc,td,td}, dy[] = {tc,td,tc,td,sa,sb,sa,sb};
        ll ans = LLINF>>2;
        REP(j, 8) {
            ans = min(ans, abs(x - dx[j]) + abs(dx[j] - dy[j]));
        }
        ANS[i] = ans;
    }
    REP(i, Q) cout << ANS[i] << endl;
    getchar(); getchar();
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

const int MOD = 1e9 + 7;

int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, m;
    cin >> n >> m;
    vector<bool> broken(n + 1, 0);
    for(int i = 1; i <= m; i ++) {
        int x;
        cin >> x;
        broken[x] = 1;
    }

    vector<int> dp(n + 1, 0);
    dp[0] = 1;
    for(int i = 1; i <= n; i ++) {
        if(!broken[i - 1])
            dp[i] = dp[i - 1];
        if(i > 1 && !broken[i - 2])
            dp[i] += dp[i - 2];
        dp[i] %= MOD;
    }
    cout << dp[n];

    return 0;
}


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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 2e3 + 10;

int n, K;
int sum[N][N];

int S(int x1, int y1, int x2, int y2){
	if(x1 > x2 || y1 > y2) return 0;
	--x1, --y1;
	return sum[x2][y2] - sum[x2][y1] - sum[x1][y2] + sum[x1][y1];
}

int main(){

	scanf("%d%d", &n, &K);
	int k = K;
	For(i, 1, n){
		int x, y;
		char S[5];
		scanf("%d%d%s", &x, &y, S);
		
		x %= 2 * k, y %= 2 * k;
		if(S[0] == 'B') x = (x + k) % (2 * k);
		if(x >= k) x -= k, y = (y + k) % (2 * k);

		if(!x) x = k, y = (y + k) % (2 * k);
		if(!y) y = 2 * k;

		sum[x][y]++;
	}

	For(i, 1, K) For(j, 1, 2 * K) sum[i][j] += sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1];

	int ans = 0;
	For(i, 1, K + 1) For(j, 1, K + 1){
		int val = S(1, 1, i - 1, j - 1) + S(i, j, K, j + K - 1) + S(1, j + K, i - 1, 2 * K);
		ans = max(ans, max(val, n - val));
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    int n, m; cin >> n >> m;
    vector<int> ans(n,0);
    rep(i,m){
        int a, b; cin >> a >> b;
        ans[a-1]++;
        ans[b-1]++;
    }
    bool check = true;
    rep(i,n) if(ans[i] % 2 == 1) check = false;
    cout << (check ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3752
fun main(args : Array<String>) {
    val S = readLine()!!

    val map = S.toCharArray().groupBy { it }.entries

    var count1 = 0
    map.forEach {
        count1++
        if (it.value.size != 2) {
            println("No")
            return
        }
    }

    if (count1 == 2) {
        println("Yes")
    } else {
        println("No")
    }
}

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

using namespace std;

void hawawa()
{
  string str;
  int num[3] = {};
  cin >> str;
  for (auto&& i : str) {
    num[i - 'a']++;
  }
  sort(begin(num), end(num));
  if (num[2] - num[0] < 2) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'

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

    ll n,k;
    cin >> n >> k;

    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    if(k >= n) {
        cout << 0 << endl;
        return 0;
    }

    ll cnt = 0;
    for(int i = k; i < n; i++){
        cnt += a[i];
    }
    cout << cnt << endl;
}



Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
#ifdef local
#define dbg(a) cout << #a": " << a << endl;
#else
#define dbg(a)
#endif // loacl


using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const ll inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-6;
const int mod=998244353;
const int maxn=1e6+10;
const int N=1e5+10;
const int M=N<<1;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll MOD)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=(ans*a)%MOD;
        b>>=1;
        a=(a*a)%MOD;
    }
    return ans;
}

int n,a[55];
int main()
{
#ifdef local
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // local
    IOS;
    cin>>n;rep1(i,n) cin>>a[i];
    sort(a+1,a+1+n);
    double ans=0,tmp=a[1]*1.0,tag;
    for(int i=2;i<=n;++i)
    {
        tag=1.0*(tmp+a[i])/2;dbg(tag)
        tmp=tag;
        ans+=tag;
    }
    printf("%.6f",tmp);
    return 0;
}


Measured memory_bytes: 256
s = input()
aa = int(s[0:2])
bb = int(s[2:4])

if aa >= 1 and aa <= 12:
    if bb >= 1 and bb <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif bb >= 1 and bb <= 12:
    print("YYMM")
else:
    print("NA")


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

using namespace std;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  vector <int64_t> x;

  int r, D, x0;
  cin >> r >> D >> x0;

  x.emplace_back (x0);

  for (auto i = 1; i <= 10; ++ i)
  {
    x.push_back (x.back () * r - D);
  }

  for (size_t i = 1; i <= 10; ++ i)
  {
    cout << x [i] << endl;
  }
}



Measured memory_bytes: 256
S = input()
N = len(S)
MOD = 10**9 + 7
dp = [[0]*(N+1) for _ in range(13)]
#dp[j][i]: 上からiケタ目までみたときの13で割った余りがjである個数
dp[0][0] = 1

for i in range(0, N):
    if S[i] == "?":
        for j in range(0, 10):
            for k in range(0, 13):
                dp[(k*10+j)%13][i+1] += dp[k][i]
    else:
        j = int(S[i])
        for k in range(0, 13):
            dp[(k*10+j)%13][i+1] += dp[k][i]
    
    for k in range(0, 13):
        dp[k][i+1] %= MOD

print(dp[5][N]%MOD)

Measured memory_bytes: 84188
#include<bits/stdc++.h>
using namespace std;
bool check_row(int r,vector<string> &v)
{
  for(auto i:v[r])
    if(i=='#')
      return false;

  return true;
}
bool check_column(int c,vector<string> &v)
{
  for(auto i:v)
    if(i[c]=='#')
      return false;
  return true;
}
bool found(vector<string> &v)
{
  for(int i=0;i<v.size();i++)
    if(check_row(i,v))
      return true;

  for(int i=0;i<v[0].size();i++)
    if(check_column(i,v))
       return true;

  return false;
}
string util(vector<string> &v)
{
  for(int i=0;i<v.size();i++)
    if(check_row(i,v))
      return "r"+to_string(i);

  for(int i=0;i<v[0].size();i++)
    if(check_column(i,v))
       return "c"+to_string(i);
}
void delete_rc(vector<string> &v)
{
  string td=util(v);
  if(td[0]=='r')
  {
    int r=stoi(td.substr(1,td.length()-1));
    v.erase(v.begin()+r);
  }
  else
  {
    int c=stoi(td.substr(1,td.length()-1));
    for(int i=0;i<v.size();i++)
    {
      string h=v[i];
      string l="";
      for(int j=0;j<h.length();j++)
        if(j!=c)
          l+=h[j];
      v[i]=l;
    }
      
  }
}

int main()
{
  int n,m;
  cin>>n>>m;
  vector<string> v(n);
  for(auto &i:v) cin>>i;
  while(found(v))
  {
    delete_rc(v);
  }
  for(auto i:v){
    for(auto j:i)
      if(j=='3')
        continue;
      else
        cout<<j;
    cout<<"\n";
  }
  return 0;
}


Measured memory_bytes: 256
import sys
import math
import heapq
from collections import deque
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N,u,v=LI()

TR=[[] for i in range(N+1)]
for _ in range(N-1):
    i,j=LI()
    TR[i].append(j)
    TR[j].append(i)

DIST1=[-1]*(N+1)
DIST2=[-1]*(N+1)
FIFO = deque()

FIFO.append((v,0))
while FIFO:
    edge, dist = FIFO.popleft()
    DIST1[edge] = dist
    for i in TR[edge]:
        if DIST1[i] == -1:
            FIFO.append((i, dist+1))

FIFO.append((u, 0))

farest = 0
while FIFO:
    edge, dist = FIFO.popleft()
    DIST2[edge] = dist
    farest = max(farest, DIST1[edge])
    for i in TR[edge]:
        if DIST2[i] == -1 and dist+1 < DIST1[i]:
            FIFO.append((i, dist+1))

# print(DIST1)
# print(DIST2)
print(max(0, farest-1))


Measured memory_bytes: 28844