akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
	private static final int MAX_NUM = 100;
	private static int[] numInput = new int[MAX_NUM];
	private static ArrayList<Integer> result = new ArrayList<Integer>(1);
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try{
			while(true){
				checkInput(sc.nextInt());
			}
		}catch(NoSuchElementException e){
			//ツ禿シツ療債づ個終ツ猟ケ
		}
		
		addNumMostInput();
		
		for(int i = 0; i < result.size(); i++){
			System.out.println(result.get(i));
		}
	}
	
	//ツ鳴シツ前ツつィツつゥツつオツつ「ツ？
	private static void checkInput(int input){
		numInput[input - 1]++;
	}
	
	private static void addNumMostInput(){
		int maxTimesInput = getMaxTimesInput();
		for(int i = 0; i < MAX_NUM; i++){
			if(numInput[i] == maxTimesInput){
				result.add(i + 1);
			}
		}
	}
	
	private static int getMaxTimesInput(){
		int count = 0;
		for(int i = 0; i < MAX_NUM; i++){
			if(count < numInput[i]){
				count = numInput[i];
			}
		}
		return count;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main(){
  ll r;
  cin >> r;
  double x = 3.1415926535;
  cout <<setprecision(10)<< 2*r * x << endl;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std; 
using lint =                            long long int;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD 1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
    int N;
    cin>>N;
   string S;
   cin>>S;
   string T;
   cin>>T;
   string ret;
   REP(i,N){
       ret += S[i];
       ret += T[i];
   }
   cout<<ret<<endl;

}

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


Measured memory_bytes: 256
//abc160_e.cpp
//Sat Mar 28 21:26:27 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<ll,ll> P;

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

	vector<P> apple;
	for (int i=0;i<a;i++){
		ll p;
		cin >> p;
		apple.push_back(P(p,0));
	}

	for (int i=0;i<b;i++){
		ll q;
		cin >> q;
		apple.push_back(P(q,1));
	}

	for (int i=0;i<c;i++){
		int r;
		cin >> r;
		apple.push_back(P(r,2));
	}

	sort(apple.begin(),apple.end(),greater<P>());

	ll ans = 0;
	ll ate[3];
	fill(ate,ate+3,0);
	ll totalate = 0;
	for (int i=0;i<apple.size();i++){
		if ((apple[i].second==0 && ate[0]<x) ||
			(apple[i].second==1 && ate[1]<y) ||
			(apple[i].second==2)){
			ans += apple[i].first;
			ate[apple[i].second]++;
			totalate++;
		}
		if (totalate == x+y){
			cout << ans << endl;
			return 0;
		}
//		cout << apple[i].first << " " << apple[i].second << " " << totalate << " " << ans << endl;
	}

}

Measured memory_bytes: 10604
#include<bits/stdc++.h>
using namespace std;
int main(){
  int cnt=0,mx=0;
  string S;
  cin>>S;
  for(int i=0;i<S.length();i++){
    if(S[i]=='R'){
      cnt++;
    }else{
      mx=max(mx,cnt);
      cnt=0;
    }
  }
  mx=max(mx,cnt);
  cout<<mx<<'\n';
  return 0;
}

Measured memory_bytes: 3620
n = int(input())
data = input().split(" ")
sum = 0
for i in data:
    sum += int(i)
r1 = int(round(sum / n, 0))
r2 = int(round(sum / n + 0.5, 0))
r3 = int(round(sum / n - 0.5, 0))

res = 0
keep = 0

def search(intvalue, data):
    sum = 0
    for i in data:
        k = abs(intvalue - int(i))
        if k == 0:
            continue
        sum += k ** 2
    return sum
res = [0 for i in range(3)]
res[0] = search(r1, data)
res[1]= search(r2, data)
res[2] = search(r3, data)
print(min(res))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 1e5+5, M=1e5+5, oo=0x3f3f3f3f, mod = 1e9+7;

int n, m, u, v, in[N], mxpath[N], mx;
vector<int>g[N];
int solve(){
    queue<int>q;
    for(int i=1; i<=n; i++){
        if(in[i] == 0){
            q.push(i);
        }
    }
    while(q.size()){
        int node = q.front();
        int y = mxpath[node];
        q.pop();
        for(auto i: g[node]){
            mxpath[i] = max(mxpath[i], y + 1);
            in[i]--;
            if(!in[i])
                q.push(i);
        }
    }
    for(int i=1; i<=n; i++)
        mx = max(mx, mxpath[i]);
    return mx;
}

int main()
{
    _69e27
    cin >> n >> m;
    for(int i=0; i<m; i++){
        cin >> u >> v;
        g[u].push_back(v);
        in[v]++;
    }
    cout << solve();
    return 0;
}


Measured memory_bytes: 6528
#include<stdio.h>

int main(void){

	int n,m,i,j,num,tmp;
	int *B,**A;

	scanf("%d %d",&n,&m);
		B = (int *)malloc(sizeof(int)*m);
		A = (int **)malloc(sizeof(int *)*n);

	for(i=0;i<n;i++){
		A[i] = (int *)malloc(sizeof(int )*m);
	}

	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&A[i][j]);
		}
	}

	for(i=0;i<m;i++){
		scanf("%d",&B[i]);
	}

	for(i=0;i<n;i++){
		tmp = 0;
			for(j = 0;j<m;j++){
				tmp = tmp + A[i][j] * B[j];
	}
			printf("%d\n",tmp);
		}
	for(i=0;i<n;i++){
		free(A[i]);
	}
	free(A);

	return 0;
}

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

int main() {
    int num;
    cin >> num;
    vector<vector<int>> array(num, vector<int>(num, 0));
    for(int i=0; i<num; i++) {
        int index;
        int degree;
        cin >> index >> degree;
        for(int j=0; j<degree; j++) {
            int edge;
            cin >> edge;
            array.at(index-1).at(edge-1) = 1;
        }
    }

    for(int i=0; i<num; i++) {
        for(int j=0; j<num; j++) {
            if(j != 0) cout << " ";
            cout << array.at(i).at(j);
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3176
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	t := getNextString(scanner)
	if len(s)+1 != len(t) {
		fmt.Fprintln(writer, "No")
		return
	}
	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			fmt.Fprintln(writer, "No")
			return
		}
	}
	fmt.Fprintln(writer, "Yes")
}


Measured memory_bytes: 1804
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

template <typename T> struct BIT {
    int n;
    vector<T> bit;
    BIT(int n_) : n(n_ + 1), bit(n, 0) {
    }

    void add(int i, T x) {
        if (i == 0) {
            cout << "BIT add ERROR" << endl;
            exit(1);
        }
        for (int idx = i; idx < n; idx += (idx & -idx)) {
            bit[idx] += x;
        }
    }

    T sum(int i) {
        T s(0);

        for (int idx = i; idx > 0; idx -= (idx & -idx)) {
            s += bit[idx];
        }
        return s;
    }
};

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

    vec<int> mp(N+1);
    vec<int> ball(N+1);

    rep(i, N) {
        int c;
        cin >> c;
        int now = i + 1;
        if (mp[c] == 0) {
            mp[c] = now;
        } else {
            ball[mp[c]] = now;
            mp[c] = now;
        }
    }

    vec<vec<pair<int,int>>> query(N+1);
    vec<int> l(Q), r(Q);
    rep(i, Q) {
        cin >> l[i] >> r[i];
        query[l[i]].push_back({r[i],i});
    }

    BIT<ll> bit(N);
    vec<int> ans(Q);
    for (int i = N; i > 0; --i) {
        if (ball[i] != 0) bit.add(ball[i], 1);
        for (auto [R,index] : query[i]) {
            ans[index] = bit.sum(R);
        }
    }

    rep(i, Q) {
        cout << r[i] - l[i] + 1 - ans[i] << endl;
    }
}


Measured memory_bytes: 39044
import math as mt
n,k=map(int,input().split())
a=list(map(int,input().split()))
bot=0
top=max(a)


while 1:
  cen=(top+bot)//2
  x=0
  if cen==0:
    print(1)
    break
  for i in a:
    x+=mt.ceil(i/cen)-1
  #print(x,top,cen,bot)
  if x>k:
    bot=cen+1
  else:
    top=cen
  
  if top<=bot:
    print(top)
    break
  if bot==cen:
    print(cen+1)
    break

Measured memory_bytes: 93684
h,w = map(int,input().split())
buf = '/'*(w+2)
lst = []
lst.append(buf)
for i in range(h):
    t = input()
    lt = '/'+t+'/'
    lst.append(lt)
lst.append(buf)

for i in range(1,h+1):
    text = ''
    for j in range(1,w+1):
        if (lst[i][j]=='.'):
            n = 0
            flame = list((lst[i-1],lst[i],lst[i+1]))
            for x in range(3):
                for y in range(j-1,j+2):
                    if (flame[x][y]=='#'):
                        n += 1
            text += str(n)
        else:
            text += '#'
    print(text)

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

int main(){
    int r,c;
    int sheet[101][101]={0};

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

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

    for(int a=0;a<r+1;a++){
        for(int b=0;b<c+1;b++){
            cout << sheet[a][b];
            if(b==c){
                cout << endl;
            }else{
                cout << " ";
            }

        }
    }

    return 0;
}


Measured memory_bytes: 3096
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

#include <iomanip>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

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

    cin >> N;
    cin >> K;

    double ans = 0;

    double base = 1;
    for( ll ni = N ; ni >0 ; ni-- ){
        while(ni*base < K){
            base*=2;
        }
        ans += ( 1 / base);
    }

    ans = ans / N;


    cout << fixed << setprecision(15) << ans << endl;


}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i=0;i<n;++i){
    cin >> p[i];
  }
  long long ans=0;
  sort(p.begin(),p.end());
  for(int i=0;i<k;++i) ans+=p[i];

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


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

// loop and test case
#define ft    int t; scanf("%d", &t); for(int c=1; c<=t; c++)
#define whilecase while (tc--)
#define eof while (cin >> n)
#define forloop for (pos=1; pos<=tc; pos++)
#define arrayloop for (i=0; i<n; i++)

//memset function
#define setz(a) memset(a, 0, sizeof(a))
#define setneg(a) memset(a, -1, sizeof(a))

#define sf scanf
#define pf printf

// integer input
#define isc(a) scanf("%d", &a)
#define isc2(a,b) scanf("%d%d", &a,&b)
#define isc3(a,b,c) scanf("%d%d%d", &a,&b,&c)



// double input
#define dsc(a) scanf("%lf", &a)
#define dpf2(a) printf("%.2f", a)
#define dpf3(a) printf("%.3f", a)

//Case printing
#define casepf(a) printf("Case %d: ", a)
#define casestr(a, b) printf("Case %d: %s\n", a,b)
#define nl printf("\n") //new line

#define fl(a) floor(a)
#define cl(a) ceil(a)


#define pb(a) push_back(a)
typedef pair<int, int> pii;
#define mp(a,b) make_pair(a,b)

typedef long long ll;
typedef unsigned long long ull;
char a[200][200];
int main(){
int n,m;
isc2(n,m);
for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
        cin>>a[i][j];
    }
}
for(int i=0;i<=n+1;i++){
    for(int j=0;j<=m+1;j++){
        if(i==0 || i==n+1){
            cout<<"#";
        }
        if((i!=0 && i!=n+1) && (j!=0 && j!=m+1)){
           cout<<a[i][j];
        }
        if((i!=0 && i!=n+1) && (j==0 || j==m+1)){
           cout<<"#";
        }
    }
    nl;
}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (ll i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
 
ll n, x, m;
 
int order[100000];
ll sum[100000];
 
int main() {
    cin >> n >> x >> m;
    ll s = 0;
    int loop_b = -1, loop_e = -1;
    reps(i, n) {
        if (order[x] != 0) {
            loop_b = order[x];
            loop_e = i;
            break;
        }
        s += x;
        order[x] = i;
        sum[i] = s;
        x = (x * x) % m;
    }
    ll ans = s;
    if (loop_b != -1) {
        ll a = (n - loop_e + 1) % (loop_e - loop_b);
        ans += (sum[loop_e - 1] - sum[loop_b - 1]) * ((n - loop_e + 1) / (loop_e - loop_b)) +
               (sum[loop_b + a - 1] - sum[loop_b - 1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4348
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()
	A = inputList()

	A.sort()
	A = A[::-1]
	ans = 0
	maxs = 0
	cnt = 0
	fst = True

	ansans = []
	pgt = queue.Queue()
	for i,val in enumerate(A):
		if i == 0:
			pgt.put(val)
		else:
			tmp = pgt.get()
			ansans.append(tmp)

			pgt.put(val)

			if tmp == val:
				pgt.put(val)
				cnt += 1
			else:
				pgt.put(val)
				if cnt == N:
					pgt.put(val)

	#print(ansans)
	print(sum(ansans))


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


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

const int N = 100005;

int n, m, u, v, cnt = 0;
bool vis[N];
vector<int> ve, adj[N];

bool DFS(int u, int b, int p = 0) {
    vis[u] = true;
    for (int &v : adj[u]) {
        if (v == p || v == b) {
            continue;
        }
        if (vis[v] || DFS(v, b, u)) {
            return true;
        }
    }
    return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    if (m < n + 2) {
        return cout << "No", 0;
    }
    for (int i = 1; i <= m; i++) {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (int i = 1; i <= n; i++) {
        if (adj[i].size() & 1) {
            return cout << "No", 0;
        }
    }
    for (int i = 1; i <= n; i++) {
        if (adj[i].size() >= 6) {
            return cout << "Yes", 0;
        } else if (adj[i].size() == 4) {
            ve.push_back(i);
        }
    }
    if (ve.size() >= 3) {
        return cout << "Yes\n", 0;
    }
    cout << (DFS(ve.front(), ve.back()) ? "Yes" : "No");
}


Measured memory_bytes: 7040
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np
from collections import defaultdict

N = int(readline())
S = np.frombuffer(read().rstrip(),'S1')

MOD = 10**9 + 7

Sright = (S==b'>')
Sleft = (S==b'<')
Sadd = (S==b'+')
Ssub = (S==b'-')

def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

def calc_hash_data(MOD,base):
    inv = pow(base,MOD-2,MOD)
    x = np.ones(N+1,dtype=np.int64)
    x[1:][Sright] = base
    x[1:][Sleft] = inv
    power = cumprod(x,MOD)
    x = np.pad(power[1:] * Sadd - power[1:] * Ssub,(1,0),mode='constant')
    np.cumsum(x,out=x); x %= MOD
    return power,x

b1 = 123450
b2 = 314159
pow1,H1 = calc_hash_data(MOD,b1)
pow2,H2 = calc_hash_data(MOD,b2)

X1 = (H1+H1[-1]*pow1)%MOD
X2 = (H2+H2[-1]*pow2)%MOD
X = (X1<<32)^X2

H = (H1<<32)^H2

# x[i] == H[j] となる i<j の個数を答える

X = X.tolist(); H = H.tolist()
counter = defaultdict(int)
for h in H:
    counter[h] += 1

answer = 0
for x,h in zip(X,H):
    counter[h] -= 1
    answer += counter[x]

print(answer)

Measured memory_bytes: 94280
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int N = 10;
const int M = 10;
const int INF = 0x3f3f3f3f;
int d[N][N],n;
int main()
{
    int m,a,b,c;
    while(cin>>m&&m){
        for(int i=0;i<N;i++)
            fill(d[i],d[i]+N,INF);
        n=0;
        while(m--){
            scanf("%d%d%d",&a,&b,&c);
            d[a][b]=d[b][a]=c;
            n=max(max(n,a+1),b+1);
        }
        for(int k=0;k<n;k++){
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
                }
            }
        }
        int sum,msum=INF;
        int id=0;
        for(int i=0;i<n;i++){
            sum=0;
            for(int j=0;j<n;j++){
                if(i==j)continue;
                sum+=d[i][j];
            }
            if(sum<msum){
                msum=sum;
                id=i;
            }
        }
        printf("%d %d\n",id,msum);
    }

    return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <utility>
#include <set>
#include <vector>
#include <queue>
using namespace std;
#define loop(i,n) for(int i=0;i<n;i++)

int main(){
    
    string s;
    string t="CODEFESTIVAL2016";
    int c=0;
    cin>>s;
    loop(i,16){
        if(s[i]!=t[i])c++;
    }
    cout<<c<<endl;

  return 0;
}


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

int main() {
  int N,D;
  cin >> N >> D;
 
  vector<vector<int>> data(N, vector<int>(D));
 
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> data.at(i).at(j);
    }
  }
  
  int d = 0;
  int count = 0;
   for (int i = 0; i < N-1; i++) {
     for (int k = i+1; k < N; k++) {
       for (int j = 0; j < D; j++) {
         d += (data.at(k).at(j) - data.at(i).at(j))*(data.at(k).at(j) - data.at(i).at(j));
       }
       for (int l = 0; l < 128; l++) {
         if (l*l == d){
           count++;
           break;
         }
       }
     d = 0;
     }
   }
  cout << count << endl;
}
  

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

using namespace std;

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

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += a[i] - 1;
  }

  cout << ans << endl;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    string S;
    cin >> S;

    vector<vector<int>> pre(N);
    vector<int> cnt(10, 0);
    for(int i=0; i<N; i++)
    {
        pre[i] = cnt;
        cnt[(S[i] - '0')]++;
    }

    vector<vector<int>> post(N);
    cnt.assign(10, 0);
    for(int i=N-1; i>=0; i--)
    {
        post[i] = cnt;
        cnt[(S[i] - '0')]++;
    }

    vector<vector<vector<int>>> mp(10, vector<vector<int>>(10, vector<int>(10, 0)));
    int ans = 0;
    for(int i=0; i<N; i++)
    {
        for(int j=0; j<10; j++)
        {
            if(pre[i][j] == 0) continue;
            for(int k=0; k<10; k++)
            {
                if(post[i][k] == 0) continue;
                if(mp[j][(S[i] - '0')][k] == 0)
                {
                    mp[j][(S[i] - '0')][k]++;
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7392
import java.util.Scanner;

/**
 * https://abc043.contest.atcoder.jp/tasks/abc043_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		
		int ans = 0;
		for(int i=1; i<=N; i++){
			ans += i;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 21844
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
      int W = scan.nextInt();

      int H = scan.nextInt();

      int x = scan.nextInt();

      int y = scan.nextInt();

      int r = scan.nextInt();

    if(r<=x&&x<=W-r&&r<=y&&y<=H-r){
            System.out.println("Yes");}

    else{System.out.println("No");}
  }
}


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

#define ll long long 

ll cnt(vector<int>& xs, int x) {
    int n = xs.size();
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (xs[i]-1)/x;
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(0); 

    int n; cin >> n;
    int k; cin >> k;
    vector<int> xs(n);
    for (int i = 0; i < n; i++) 
        cin >> xs[i];

    int left = 1;
    int right = *max_element(xs.begin(), xs.end());
    int ans = right;
    while (left <= right) {
        int mid = left + (right - left)/2;
        if (cnt(xs, mid) <= k) {
            ans = mid;
            right = mid-1;
        } else {
            left = mid+1;
        }
    }

    cout << ans << endl;



    return 0; 
}



Measured memory_bytes: 4032
#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, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
   string s;cin>>s;
   int n = s.size();
   reverse(all(s));
   ll cnt=0, res=0;
   rep(i,n){
       if(s[i]=='W')++cnt;
       else res+=cnt;
   }
   cout<<res<<endl;
}

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

int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
   
      long long n,i,j,k,sum=0,count=0,ans=0,x=0,y=0,l,r,m;
      string s,t;
      cin>>s>>t;
      n=s.length();
      k=t.length();
      ans=1000000000;
      for(i=0;i<=(n-k);i++)
      {
          count=0;
          for(j=i;j<(i+k);j++)
          {
              if(s[j]!=t[j-i])
              count++;
          }
          ans=min(ans,count);
      }
      cout<<ans;
      
  
	return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
            int num = Integer.parseInt(scanner.nextLine());
            String str = scanner.nextLine();
            if (str.length() <= num) {
                System.out.println(str);
            } else {
                System.out.println(str.substring(0, num) + "...");
            }
    }

}

Measured memory_bytes: 27016
#include <iostream>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

int R0, W0, C, R;

int main(void) {
  while(cin >> R0 >> W0 >> C >> R, R0 || W0 || C || R) {
    int ans = 0;
    while(1) {
      if(R0 + R * ans >= C * W0) break;
      ans++;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3080
using System;
class Program
{
	static void Main()
	{
	int n = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
	string input = Console.ReadLine();//Splitで区切り文字を指定して複数個受け取る。
    int minCount = 0;

        int count = 0;

        for(int i = 1; i < input.Length; i++)
        {
          if(input[i] == 'E')count++;
        }
        
        minCount = count;//１つ目の場合
         
      for(int i = 1; i < input.Length; i++)
      {
        
          if(input[i-1] == 'W' && input[i] == 'W')count++;

          if(input[i-1] == 'E' && input[i] == 'E')count--;
        
          if(count<minCount) minCount = count;
      
      }  

	Console.WriteLine(minCount);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 13140
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<ll, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

vector<int> pos[128];

int main(){
    fastIO;
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0 ; i < 128; i ++ )
        pos[i].push_back(0);
    for(int i = 0 ; i < n ; i ++ ){
        pos[s[i]].push_back(i+1);
    }
    for(int i = 0 ; i < 128; i ++ )
        pos[i].push_back(n+1);
    int res = (int)1e9;
    int mx;
    for(int i = 0 ; i < 128; i ++ ){
        mx = 0;
        for(int j = 1; j < pos[i].size(); j ++ ){
            mx = max(mx, pos[i][j]-pos[i][j-1]-1);
        }
        res = min(res, mx);
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a1,a2,a3,a4,a5,a6,a7,a8,a9;
    int c1,c2,c3,c4,c5,c6;
    cin>>a1>>a2>>a3>>a4>>a5>>a6>>a7>>a8>>a9;
c1=a1-a4;c2=a2-a5;c3=a3-a6;c4=a4-a7;c5=a5-a8;c6=a6-a9; if((c1==c2)&&(c2==c3)&&(c4==c5)&&(c5==c6)) cout<<"Yes";
else cout<<"No";
}

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

int gcd(int x,int y){
    if(y==0) return x;
    return gcd(y, x%y);
}

int main(){
    int n;scanf("%d",&n);
    vector<int> a(n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    vector<int> l(n),r(n);
    for(int i=0;i<n-1;i++){
        l[i+1]=gcd(l[i],a[i]);
    }
    for(int i=n-1;i>0;i--){
        r[i-1]=gcd(r[i],a[i]);
    }
    int ans=1;
    for(int i=0;i<n;i++){
        int tmp=gcd(l[i],r[i]);
        ans=max(tmp,ans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1408
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for p in range(a+1):
    for q in range(b+1):
        for r in range(c+1):
            if p*500+q*100+r*50 == x:
                count += 1
print(count)

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

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

const int N = (int) 1e5 + 10;
int n, a[N], b[N];

int main() {
    #ifdef LOCAL
        freopen("Data.inp", "r", stdin);
        freopen("Data.out", "w", stdout);
    #endif

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

    LL ans = 0, sum = 0;
    for (int i = n; i >= 1; --i) {
        int l = (b[i] - (a[i] + sum) % b[i]) % b[i];
        sum += l;
        ans += l;
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
n,k,s = map(int,input().split())
ans = []

if n-k < s:
    for i in range(k):
        ans.append(s)
    for i  in range(n-k):
        ans.append(1)
    print(*ans, sep = " ")
else:
    if s > 2:
        for i in range(k):
            ans.append(s)
        po = (s//2) + 1
        for i  in range(n-k):
            ans.append(po)
        print(*ans, sep = " ")
    else :
        for i in range(k):
            ans.append(s)
        for i  in range(n-k):
            ans.append(s+1)
        print(*ans, sep = " ")



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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    ll rj = 0;
    rj += min(a, k);
    k -= a;
    if(k > 0)
        k -= b;
    if(k > 0){
        rj -= k;
    }
    cout << rj;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

signed main(){

	lli n;
	cin>>n;

	vector<lli> a(n);
	map<lli,lli> cnts;
	set<lli> s;

	lli cnt=0;
	REP(i,0,n){
		cin>>a[i];
		s.insert(a[i]);
		cnts[a[i]]++;
	}

	sort(a.begin(),a.end());

	for(auto e:cnts){
		cnt += e.second-1;
	}
	lli tmp = s.size();
	if(s.size()%2==0)tmp--;

	cout<<tmp<<endl;

	return 0;
}

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

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

    int res = 0;
    for (int i = 1; !res && i <= 1<<12; i++) {
        int c = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) {
                c++;
            }
        }
        if (c == N) res = i;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++) a[i] = sc.nextInt();
			for(int i = 0; i < n; i++) {
				if(i != 0) System.out.print(" ");
				System.out.print(a[n - i - 1]);
			}
			System.out.println();
	}
}



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

int main(){
  int N=0, l=0, r=0, sum=0;
  cin >> N;
  
  for(int i=0; i<N; i++){
    cin >> l >> r;
    sum += (r - l + 1);
  }
  cout << sum << endl;
  return 0;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll H, W;
  cin >> H >> W;
  vector<string> a(H);
  map<char, ll> ma;
  for(int i = 0; i < H; i++){
    cin >> a.at(i);
    for(int j = 0; j < W; j++){
      char c = a.at(i).at(j);
      if(!ma.count(c)) ma[c] = 1LL;
      else ma.at(c)++;
    }
  }
  ll four = 0, two = 0, odd = 0;
  for(auto i = ma.begin(); i != ma.end(); i++){
    ll num = i -> second;
    if(num % 4 == 0) four++;
    else if(num % 2 == 0) two++;
    else odd++;
  }
  bool flag = false;
  if(H%2==0){
    if(W%2==0){
      if(two == 0 && odd == 0) flag = true;
    }
    else{
      if(odd == 0 && two <= H/2) flag = true;
    }
  }
  else{
    if(W%2==0){
      if(odd == 0 && two <= W/2) flag = true;
    }
    else{
      if(odd <= 1 && two <= W/2 + H/2) flag = true;
    }
  }
  cout << (flag? "Yes": "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; string S; 
	char ans[78]; 
	for(int i = 0; i < 26; i++){
		ans[i] = (char) ('A' + i); 
	}
	for(int i = 0; i < 26; i++){
		ans[i+26] = (char) ('A' + i); 
	}
	for(int i = 0; i < 26; i++){
		ans[i+52] = (char) ('A' + i); 
	}
	cin >> N >> S; 
	for(int i = 0; i < S.size(); i++){
		cout << ans[S.at(i) - 'A' + N]; 
	}
	cout << endl; 
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void doIt() {
		long n = sc.nextLong();
		long sum = 0;
		for(long i = 1; i * i < n; i++) {
			if(n % i == 0) {
				long m = n / i - 1;
				if(n / m == n % m) {
					sum += m;
				}
			}			
		}
		System.out.println(sum);
		
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 23380
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# l = LIST()
# a, b, c = MAP()
n = INT()
print(3 * n ** 2)




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

using ll = long long;
#define f first
#define s second

#ifndef LOCAL
	#define cerr if(0) cerr
#endif

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	
	int n;
	cin >> n;

	vector<ll> a(n);
	for (ll& x : a)
		cin >> x;
	sort(a.begin(), a.end(), greater<ll>());

	ll ans = a[0];

	priority_queue<ll> pq;
	pq.push(a[1]); pq.push(a[1]);

	for (int i = 2; i < n; ++i) {
		ans += pq.top();
		pq.pop();

		pq.push(a[i]);
		pq.push(a[i]);
	}
	cout << ans << "\n";
}


Measured memory_bytes: 6884
#include<bits/stdc++.h> 
#define ll                 long long                            
#define ra                 return a;                                          
#define pb                 push_back                                                     
#define sti                stack<ll>
#define spi                stack<pair<ll,ll>>
#define S                  second
#define msi                map<string,ll >
#define msi                map<string,ll >
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z)        { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define mis                map<ll , string>
#define rep(i,a,b)         for(ll  i=a;i<b;i++)
#define mpi                map<pair<ll ,ll >,ll >                                                
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define F                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define vs                 vector<string>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define bs                 binary_search
#define mp                 make_pair
#define qi                 queue<ll>
#define qs                 queue<string>
#define qpi                queue<pair<ll,ll>>
#define qps                queue<pair<ll,string>> 
#define endl               '\n' 
#define itr(a,it)          for(typeof(a.begin()) it=a.begin();it!=a.end();it++)// This will produce const_iterator for const object and normal iterator for non-const object
#define ss                 set<string>
using namespace std;
#define N  100005
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
//    cin>>t;
    while(t--)
{
    ll n;
    cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    ll ans=0;
    rep(i,0,n)
    {
    	if(a[i]!=b[i])
    	{
    		if(a[i]!=c[i])
    		{
    			if(b[i]!=c[i])ans+=2;
    			else ans++;
    		}
    		else ans++;
    	}
    	else 
    	{
    		if(a[i]!=c[i])ans++;
    	}
    }
    cout<<ans;
}	
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

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

  vector<int> o(N);
  iota(ALL(o), 0);

  sort(ALL(o), [&](int const & l, int const & r){
      if(A[l] != A[r]) return A[l] > A[r];
      return l > r;
      });
  
  vector<int> ans(N+1, 0);

  o.emplace_back(N);
  A.emplace_back(0);

  int p = INF;
  REP(i, N){
    chmin(p, o[i]);
    ans[p] += (i+1)*(A[o[i]]-A[o[i+1]]);
  }

  REP(i, N){
    cout << ans[i] << "\n";
  }

  return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <unordered_map>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;

int main(){
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    int cr = INT32_MAX;
    for(int pos = 0; pos <= 100; pos++){
        int x = 0;
        for(int i = 0; i < n; i++){
            int tmp = (arr[i] - pos);
            x += tmp*tmp;
        }
        cr = min(cr, x);
    }
    cout << cr << '\n';
}


Measured memory_bytes: 256
/***
 ** " All that we are is the result of what we have thought. "
 **     -- Buddha
***/

/**
  *  Author: dhruv_gheewala
  *  Problem: __________
  *  Date:   13.04.2020
  *  Time:   06:59:17
**/

#if __has_include("debug.h")
    #include "debug.h"
#else
    #include<bits/stdc++.h>
    using namespace std;

    #define p(str) 7
    #define o(str) 42
    #define fundri 108
    #define d(...) 1729
#endif

#define int long long
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const bool testcases = 0;
#define ff first
#define ss second
#define endl '\n'
#define all(s) s.begin(),s.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define test int T = 1;if(testcases)cin >> T;for(int tc = 1 ; tc <= T ; tc++)
#define make_unique(vec) sort(all(vec));vec.erase(unique(all(vec)),vec.end())
#define sort_by(cont,expr) sort(all(cont),[&](const auto &lhs,const auto &rhs){return expr;})

ll seed;mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX){return uniform_int_distribution<int>(l,r)(rng);}

template<typename T>bool isPrime(T n){for(T i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}
template<typename T>inline bool in_range(T a,T l,T r){return (a>=l&&a<=r);}

template<typename T,typename U>inline istream& operator >>(istream& in,pair<T,U> &a)
{in>>a.ff>>a.ss;return in;}
template<typename T>inline istream& operator >>(istream& in,vector<T> &a)
{for(auto &x : a)in>>x;return in;}
template<typename TAIL>inline void inp(TAIL& T){cin>>T;}
template<typename HEAD,typename... TAIL>inline void inp(HEAD &H,TAIL&... T){cin>>H;inp(T...);}

int32_t main(int32_t argc, char **argv)
{
    std::chrono::time_point<std::chrono::high_resolution_clock> start_time, end_time;
    start_time = std::chrono::high_resolution_clock::now();

    #ifdef DHRUV_GHEEWALA
        freopen("INPUT.txt","r",stdin);
        freopen("OUTPUT.txt","w",stdout);
        freopen("DEBUG.txt","a",stderr);
    #endif
    
    fast;
    int n, ans = 0;
    cin >> n;
    for(int i = 1 ; i <= n ; i++)
        if(i % 3 != 0 && i % 5 != 0)
            ans += i;

    cout << ans << endl;

    end_time = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
    o("\n\n");
    if(elapsed_time<10000)
        o("Elapsed Time: "<<elapsed_time<<" ms\n");
    else
        o("Elapsed Time: "<<elapsed_time/1000<<" s\n");

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(All(a),greater<int>());
    int res=0;
    for(int i=0;i<n;i++){
        if(k){
            k--;
        }else{
            res+=a[i];
        }
    }
    cout<<res<<endl;

}

Measured memory_bytes: 1792
// https://beta.atcoder.jp/contests/abc076
// status:
// tag:

#define SUBMIT
//#define DEBUG

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <queue>
#include <numeric>
#include <limits>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_N = 100;
int N;
double t[MAX_N];
double v[MAX_N];

struct constraint { double t_left, t_right, v; };
constraint constraints[MAX_N];

double compute_max_v(const constraint& c, double t) {
    if (t <= c.t_left) return c.v + c.t_left - t;
    else if (c.t_right <= t) return c.v + t - c.t_right;
    else return c.v;
}

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    auto program_input = std::string(R"(10
64 55 27 35 76 119 7 18 49 100
29 19 31 39 27 48 41 87 55 70
)");
    stringstream stream(program_input);
#endif
    stream >> N;
    for (int i = 0; i < N; ++i) stream >> t[i];
    for (int i = 0; i < N; ++i) stream >> v[i];

    for (int i = 0; i < N; ++i) {
        if (i == 0) constraints[i].t_left = 0.0;
        else constraints[i].t_left = t[i - 1] + constraints[i - 1].t_left;

        if (i == 0) constraints[i].t_right = t[i];
        else constraints[i].t_right = constraints[i].t_left + t[i];

        constraints[i].v = v[i];
    }

    // 制約を2つ追加
    constraints[N].t_left = 0.0;
    constraints[N].t_right = 0.0;
    constraints[N].v = 0.0;
    constraints[N + 1].t_left = constraints[N - 1].t_right;
    constraints[N + 1].t_right = constraints[N - 1].t_right;
    constraints[N + 1].v = 0.0;

    double ans = 0.0;
    for (double curr_t = 0.5; curr_t <= constraints[N - 1].t_right; curr_t += 0.5) {
        double min_max_v_left = numeric_limits<double>::max();
        double min_max_v_right = numeric_limits<double>::max();
        for (int i = 0; i < N + 2; ++i) {
            min_max_v_left = min(min_max_v_left, compute_max_v(constraints[i], curr_t - 0.5));
            min_max_v_right = min(min_max_v_right, compute_max_v(constraints[i], curr_t));
        }

        ans += (min_max_v_left + min_max_v_right) * 0.5 / 2.0;
    }

    cout << fixed << setprecision(18) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <string.h>
#include <iostream>
#include <queue>
#include <complex>
#include <functional>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

typedef complex<double> P;
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define EQV(a,b) ( EQ( a.real(), b.real() ) && EQ( a.imag(), b.imag() ) )

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,n) for(int i=a;i<=n;i++)

//---------------------------------------------------------------------
vector<string> f(10);

int DX[] = { 1,0,-1,0 };
int DY[] = { 0,1,0,-1 };
int w, h;

void rec(int x, int y, char c) {
	rep(i, 4) {
		int nx = x + DX[i]; int ny = y + DY[i];
		if (nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
		
		if (f[ny][nx] == '.') {
			f[ny][nx] = (c == 'B' ? 'b' : 'w');
			rec(nx, ny, c);
		}
		else if ((f[ny][nx] == 'b' && c == 'W') || (f[ny][nx] == 'w' && c == 'B')) {;
			f[ny][nx] = 'o';
			rec(nx, ny, c);
		}
	}
}

int main() {
	while (cin >> w >> h, (w || h)) {
		f.clear();
		rep(y, h) {
			string s;
			cin >> s;
			f.push_back(s);
		}
		rep(y, h) {
			rep(x, w) {
				if (f[y][x] == 'W' || f[y][x] == 'B') rec(x, y,  f[y][x]);
			}
		}
		int blacks = 0, whites = 0;
		rep(y, h) {
			rep(x, w) {
				if (f[y][x] == 'b') blacks++;
				else if (f[y][x] == 'w') whites++;
			}
		}
		cout << blacks << " " << whites << endl;
	}
	return 0;
}

Measured memory_bytes: 3272