akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int A = cin.nextInt();
        int B = cin.nextInt();
        int H = cin.nextInt();
        Console.WriteLine((A+B) * H / 2);
    }




}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
  int n;
  while(cin>>n,n){
    char sc[20];
    sprintf(sc,"%o",n);
    string s1=string(sc);
    for(int i=0;i<s1.size();++i){
      char c=s1[i];
      if(c>='4')++c;
      if(c>='6')++c;
      cout<<c;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1232
import numpy as np


a = []
for i in range(5):
    a.append(int(input()))

b = []
for item in a:
    b.append(item%10)

c = []
for i in range(5):
    c.append(a[i] - b[i])

ans = sum(c)
b.sort()

flg = True
for i in range(5):
    if b[i] != 0:
        if flg:
            ans = ans + b[i]
            flg = False
        else:
            ans = ans + 10
print(ans)


Measured memory_bytes: 20856
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

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

	vector<int>W(n + 1, 0), E(n + 1, 0);
	for (int i = 0; i < n; i++) {
		W[i + 1] = W[i] + (s[i] == 'W');
		E[i + 1] = E[i] + (s[i] == 'E');
	}
	int ans = 1e9;
	for (int i = 0; i < n; i++) {
		ans = min(ans, W[i] + E[n] - E[i+1]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3076
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

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

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

bool is_ok(const ll& t) {
  ll c = 0;
  for (c = 0;c*c < t;++c) ;
  if (c*c == t) return true;
  return false;
}
bool is_num(const vector<ll>& v1, const vector<ll>& v2, const int& D) {
  ll k {}; 
  rep(i, D) {
    k += (v1[i] - v2[i])*(v1[i] - v2[i]);
  }
  return is_ok(k);
}

int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<ll>> X(N, vector<ll>(D));
  rep(i, N) rep(j, D) cin >> X[i][j];
  int answer {};
  rep(i, N) {
    srep(j,i+1,N) {
      if (is_num(X[i], X[j], D)) ++answer;
    }
  }
  cout << answer << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

int main() {
    while (1) {
        int N;
        cin >> N;
        if(N==0)
            break;
        int mi = INF, ma = 0, ans = 0;
        rep(i, N) {
            int in;
            cin >> in;
            ans += in;
            mi = min(mi, in);
            ma = max(ma, in);
        }
        cout << (ans - mi - ma) / (N - 2) << "\n";
    }

    return 0;
}


Measured memory_bytes: 3108
#include "stdio.h"
#include "string.h"
#include "math.h"
int conversion(char a[][1000],int i,int j,int n,int m)
{
	int c=0;
	if(i-1>=0)					//上
		if(a[i-1][j]=='#')
			c++;
	if(i+1<=n)			//下
		if(a[i+1][j]=='#')
			c++;
	if(j-1>=0)					//左
		if(a[i][j-1]=='#')
			c++;
	if(j+1<=m)				   //右
		if(a[i][j+1]=='#')
			c++;
	if(i-1>=0&&j-1>=0)		  //左上
		if(a[i-1][j-1]=='#')
			c++;
	if(i+1<=n&&j-1>=0)		  //左下
		if(a[i+1][j-1]=='#')
			c++;
	if(i-1>=0&&j+1<=m)		  //右上
		if(a[i-1][j+1]=='#')
			c++;
	if(i+1<=n&&j+1<=m)
		if(a[i+1][j+1]=='#')
			c++;
	return c+48;
}
int main()
{

	int n,m;
	while(~scanf("%d%d",&n,&m))
	{
	    char a[1000][1000];
	    int i,j;
	    getchar();
        for(i=0;i<n;i++)
            gets(a[i]);
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
                if(a[i][j]=='.')
                    a[i][j]=conversion(a,i,j,n,m);
        }
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
                printf("%c",a[i][j]);
            printf("\n");
        }
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n  = Integer.parseInt(br.readLine());
		Node[] nodes = setInfo(n,br);
		pirntInfo(n,nodes);

	}

	private static void pirntInfo(int n,Node[] nodes){
		for(int i = 0 ; i < n ; i++){
			System.out.printf("node %d: parent = %d, "
					+ "sibling = %d, degree = %d, depth = %d, height = %d, %s\r\n"
					,i,nodes[i].parent,nodes[i].sibling,nodes[i].degree,nodes[i].depth,nodes[i].height,getType(i,nodes));
		}
	}

	private static String getType(int i,Node[] nodes){
		if(nodes[i].parent == -1){
			return "root";
		}else if(nodes[i].degree == 0){
			return "leaf";
		}else{
			return "internal node";
		}
	}

	private static Node[] setInfo(int n,BufferedReader br) throws Exception{

		Node[] nodes = new Node[n];
		for(int i = 0 ; i < n ; i++ ) nodes[i] = new Node();
		setParentAndSibling(n,br,nodes);
		int rootIndex = getRootIndex(nodes);
		setDepth(rootIndex,nodes,0);
		setHight(rootIndex,nodes);
		return nodes;
	}

	private static int setHight(int index,Node[] nodes){
		int left = 0;
		int right = 0;
		if(nodes[index].left != -1){
			left = setHight(nodes[index].left,nodes) + 1;
		}

		if(nodes[index].right != -1){
			right = setHight(nodes[index].right,nodes) + 1;
		}

		return nodes[index].height = Math.max(left,right);
	}


	private static int getRootIndex(Node[] nodes){
		int i = 0;
		while(nodes[i].parent != -1){
			i++;
		}
		return i;
	}

	private static void setDepth(int index,Node[] nodes,int depth){
		nodes[index].depth = depth;
		if(nodes[index].left != -1){
			setDepth(nodes[index].left,nodes,depth+1);
		}

		if(nodes[index].right != -1){
			setDepth(nodes[index].right,nodes,depth+1);
		}
	}

	private static void setParentAndSibling(int n,BufferedReader br,Node[] nodes) throws Exception{
		String[] infos;
		int id;
		int left;
		int right;

		for(int i = 0 ; i < n ; i++ ){
			infos = br.readLine().split(" ");
			id = StoI(infos[0]);
			left = StoI(infos[1]);
			right = StoI(infos[2]);


			if(left != -1){
				//???????????±????¨????
				nodes[id].degree++;
				nodes[id].left = left;
				//???????????±????¨????
				nodes[left].parent = id;
				nodes[left].sibling = right;
			}

			if(right != -1){
				//???????????±????¨????
				nodes[id].degree++;
				nodes[id].right = right;
				//???????????±????¨????
				nodes[right].parent = id;
				nodes[right].sibling = left;
			}
		}

	}

	private static int StoI(String s){
		return Integer.parseInt(s);
	}

}

class Node{
	int node;
	int parent;
	int sibling;
	int degree;
	int depth;
	int height;
	int right;
	int left;
	String type;

	Node(){
		parent = -1;
		sibling = -1;
		right = -1;
		left = -1;
		degree = 0;
	}
}

Measured memory_bytes: 24956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    string s,t;
    cin>>s>>t;
    int ans=0;
    rep(i,3){
        if(s[i]==t[i])ans++;
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define vectorp vector<pair<int,int>>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
	int n,x;
	cin >> n >> x;
	int a[n];
	for(int i = 0 ; i < n ; i++ ){
		cin >> a[i];
	}
	int c = 1;
	for(int i = 1 ; i < n ; i++ ){
		a[i]+=a[i-1];
		if(a[i]<=x){
			c++;
		}
		else{
			break;
		}
	}
	cout<<c+1;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    vector<bool> flag(n, true);
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }

    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (h[a] >= h[b])
        {
            flag[b] = false;
        }

        if (h[a] <= h[b])
        {
            flag[a] = false;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (flag[i])
        {
            ans++;
        }
    }

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

Measured memory_bytes: 3788
#include <stdio.h>

int check_all(int mid, int k, int n, int w[]) {
  int j = 0;
  for (int i = 0; i < k; i++) {
    int s = 0;
    while(s + w[j] <= mid) {
      s += w[j];
      j += 1;
      if (j == n) {
        return n;
      }
    }
  }
  return j;
}

int allocation(int n, int k, int w[]) {
  int right = 100000 * 10000;
  int left = 0;

  while(right - left > 1) {
    int mid = (right + left) / 2;
    int v = check_all(mid, k, n, w);
    if (v >= n) {
      right = mid;
    } else {
      left = mid;
    }
  }
  return right;
}

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int w[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &w[i]);
  }

  printf("%d\n", allocation(n, k, w));
  
  return 0;
}



Measured memory_bytes: 2120
n = int(input())
h = list(map(int, input().split()))
sea = []
mountain = h[0]
for i in range(n):
    if i == 0:
        sea.append(h[0])
    else:
        if h[i] >= mountain and h[i] >= h[0]:
            mountain = h[i]
            sea.append(h[i])
        
print(len(sea))

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m;
  cin >> n >> m;
  vector<int> ans(n + 1), cnt(n + 1, 1);
  ans[1] = 1;
  while (m--) {
    int x, y;
    cin >> x >> y;
    --cnt[x]; ++cnt[y];
    ans[y] |= ans[x];
    if (cnt[x] == 0)
      ans[x] = 0;
  }
  cout << count(ans.begin(), ans.end(), 1);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
//给一个图的邻接表，输出其邻接矩阵

using namespace std;

static const int N=100;

int main(){
    int M[N][N];

    int n,u,k,v;

    cin>>n;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            M[i][j]=0;
        }
    }

    for(int i=0;i<n;i++){
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }

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

}


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

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

const long long MOD = 1000000007;

int main(){
  int k;
  int n=1;
  cin >> k;
  int s=7%k,m=7%k;
  if(k%2==0 || k%5==0) n=-1;
  else{
    while(s!=0){
      m*=10;
      m%=k;
      s+=m;
      s%=k;
      n++;
    }
  }
  cout << n << endl;
      
}


Measured memory_bytes: 3632
//#include "stdafx.h"
#include<bits/stdc++.h> 
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

int a[3],k,ans;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	set<char>st;

	cin>>a[0]>>a[1]>>a[2]>>k;
	sort(a,a+3);
	ans=a[2];
	while(k--){
		ans*=2;
	}
	cout<<ans+a[0]+a[1]<<"\n";

	return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  set<string> st;
  int n; cin >> n;
  for(int i = 0; i < n; ++i){
    string s; cin >> s;
    st.emplace(s);
  }
  cout << st.size() << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  for(int i=1;i<=N;i++){
    if((int)(i*1.08)==N){
      cout << i << endl;
      return 0;
    }
  }
  
  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int r,g;
   cin >> r >> g;

   cout << 2*g -r << endl;


   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;
int main(void)
{
    int num = 0;
    int dig = 0;
    int sum = 0;
    cin >> num;
    int N = num;
    while (num)
    {
        dig = num % 10;
        sum = sum + dig;
        num = num / 10;
    }
    if (sum == 1)
        sum = 10;
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
void main(){
	int a, b;
	readf("%d %d", &a, &b);
	writeln( a-b*2<0? 0: a-b*2 );
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2788
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
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 functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

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


def main():
    N = INT()
    A = [INT() for _ in range(N)]

    point = 0
    cnt = 1
    for i in range(N):
        point = A[point] - 1
        if point == 1:
            print(cnt)
            sys.exit()
        cnt += 1

    print(-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 13804
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    T, H, S = map(int, readline().split())
    if T == -1:
        return False
    rest = 7200 - (T*3600 + H*60 + S)
    write("%02d:%02d:%02d\n" % (rest//3600, (rest//60)%60, rest%60))
    rest *= 3
    write("%02d:%02d:%02d\n" % (rest//3600, (rest//60)%60, rest%60))
    return True
while solve():
    ...



Measured memory_bytes: 5604
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a >= 13) {
			System.out.println(b);
		} else if (6 <= a) {
			System.out.println(b / 2);
		} else {
			System.out.println(0);
		}
	}

}


Measured memory_bytes: 21588
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n int
	var a string
  	buf := make([]byte, 1000000)
  	sc.Buffer(buf, 1000000000)
  
	if sc.Scan() {
		n, _ = strconv.Atoi(sc.Text())
	}
	if sc.Scan() {
		a = sc.Text()
	}
	count_subordinate := make([]int, n)
	for _, i := range strings.Split(a, " ") {
		index, _  := strconv.Atoi(i)
		count_subordinate[index - 1]++
	}
	for _,j := range count_subordinate {  // 1 1 1 1 1 1 0
		fmt.Println(j)
	}
}

Measured memory_bytes: 10952
class Main{
    public static void main(String[] a){
    	Main app = new Main();
    	app.calculation();
    }
    
    public void calculation(){
    	int i,j;
    
    	for(i=1;i<=9;i++){
    		for(j=1;j<=9;j++){
    			System.out.println(i +"x"+ j +"="+ i*j);
    		}
    	}
    }
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; 

static const long long INF = 1e18;

using lll = __int128_t;

ll popcount(lll x) {
    ll c = 0;
    rep(i, 128) 
        c += !!(x & ((lll)1 << i));
    return c;
}

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, qnum; 
    while (cin >> n >> qnum && n && qnum) {
        vector<ll> a(qnum); 
        rep(i, qnum) rep(j, n) { 
            char c; cin >> c; 
            if (c - '0') 
                a[i] |= 1ll << j; 
        }

        map<lll, ll> memo; // 1 if impossible
        function<ll(lll, ll)> f = [&](lll x, ll counter) -> ll {
            if (popcount(x) == qnum - 1) 
                return 0;
            if (popcount(x) == qnum) 
                return INF;
            if (memo.count(x)) 
                return memo[x];

            ll ret = INF;
            rep(j, n) {
                lll yes, no; yes = no = x; 
                rep(i, qnum) 
                    (a[i] & ((ll)1 << j) ? yes : no) |= (lll)1 << i;

                ll tmp = -1;
                ll yes_ret = INF, no_ret = INF; 
                if (yes != x)
                    yes_ret = f(yes, counter+1);
                if (no != x)
                    no_ret = f(no, counter+1);
                if (yes_ret != INF)
                    chmax(tmp, yes_ret);
                if (no_ret != INF)
                    chmax(tmp, no_ret);
                if (tmp != -1)
                    chmin(ret, tmp + 1);
            }
            return memo[x] = ret;
        };
        cout << f(0, 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 4668
<?php
// Your code here!
$input = explode(" ",trim(fgets(STDIN)));
// var_dump($input);
$n = $input[0];
$cnt = $input[1];

for($i=0; $i<=$n-1; $i++){
    $total[] = trim(fgets(STDIN));
}
sort($total);

$string = implode($total);
echo $string;

?>





Measured memory_bytes: 3576
T=int(input())
a,b=map(int,input().split())
ll=list(map(int,input().split()))
mins=0
for i in range(len(ll)):
    ans=a-0.006*ll[i]
    if abs(ans-b)<abs((a-0.006*ll[mins])-b):
        mins=i

print(mins+1)


Measured memory_bytes: 38384
N = int(raw_input())
points = map(int, raw_input().split())

points.insert(0,0)
points.insert(len(points),0)

#print points

# 0->A->B->C->D->0 ng
# 0->-->B->C->D->0
# 0->A->-->C->D->0
# 0->A->B->-->D->0
# 0->A->B->C->-->0

# remove i,
# sub i-1=>i and i=>i+1
# add i-1=>i+1

dif_points = []

for i in range(N+1):
    dif_points.append(abs(points[i] - points[i+1]))

#print dif_points

sum_fee = sum(dif_points)

#print sum_fee

for i in range(N):
    print (sum_fee - dif_points[i]  - dif_points[i+1] + abs(points[i] - points[i+2]))


Measured memory_bytes: 13540
//
//  main.c
//  aoj_03
//
//  Created by k16031kk on 2018/05/17.
//  Copyright © 2018年 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a, b;
    scanf("%d %d",&a, &b);
    int area=a*b;
    int track=a*2+b*2;
    printf("%d %d\n",area, track);
    return 0;
}



Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B; 
    cin >> N >> A >> B;
    int X[N];
    rep(i ,N) cin >> X[i];

    int tired = 0;

    rep(i ,N-1) {
        int subA = (X[i+1] - X[i]) * A;
        tired += min(subA, B); 
    }

    cout << tired << endl;
    return 0;
}


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

#define ll long long int
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define hell (ll)(1e9+7)

using namespace std;

void solve()
{
    ll n;
    cin>>n;
    vector <ll> a(n),dp(n);
    rep(i,0,n)
        cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    rep(i,2,n)
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    cout<<dp.back()<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
	public static void main(String [] args) {
		Scanner x=new Scanner(System.in);
		int a=x.nextInt();
		int b=x.nextInt();
		int c[]=new int [a];
		int c1[]=new int [a];
		for(int i=0;i<a;i++) {
			c1[i]=x.nextInt();
			c[i]=x.nextInt();
		}
		int min=9999;
		for(int i=0;i<a;i++) {
			if(c[i]<=b&&min>c1[i])
			{
				min=c1[i];
				
			}
		}
		if(min==9999) {
			System.out.println("TLE");
		}
		else {
			System.out.println(min);
		}
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;



//入力
#define MAX_Y 1000
#define MAX_X 1000
#define MAX_K 100000

int M;  //南北の長さ
int N;  //東西の長さ
int K;  //調査対象の領域の個数

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

  cin >> M >> N >> K;

  char map[M][N];

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



  // cumulative sum
  int csJ[M+1][N+1];
  int csO[M+1][N+1];
  int csI[M+1][N+1];
  memset(csJ, 0, sizeof(csJ));
  memset(csO, 0, sizeof(csO));
  memset(csI, 0, sizeof(csI));
  for(int i = 0; i < M; i++) {
    for(int j = 0; j < N; j++) {
      csJ[ i+1 ][ j+1 ] = csJ[ i ][ j+1 ] + csJ[ i+1 ][ j ] - csJ[ i ][ j ] + ( map[i][j] == 'J');
      csO[ i+1 ][ j+1 ] = csO[ i ][ j+1 ] + csO[ i+1 ][ j ] - csO[ i ][ j ] + ( map[i][j] == 'O');
      csI[ i+1 ][ j+1 ] = csI[ i ][ j+1 ] + csI[ i+1 ][ j ] - csI[ i ][ j ] + ( map[i][j] == 'I');
    }
  }


  int a, b, c, d;
  int sumJ = 0, sumO = 0, sumI = 0;
  for(int i = 0; i < K; i++) {
    cin >> a >> b >> c >> d;
    sumJ = csJ[c][d] - csJ[a-1][d] - csJ[c][b-1] + csJ[a-1][b-1];
    sumO = csO[c][d] - csO[a-1][d] - csO[c][b-1] + csO[a-1][b-1];
    sumI = csI[c][d] - csI[a-1][d] - csI[c][b-1] + csI[a-1][b-1];
    cout << sumJ << " " << sumO << " " << sumI << endl;
  }

 return 0;

}

Measured memory_bytes: 15544
N=int(input())
S=[[],[]]
S[0]=list(input())
S[1]=list(input())
p=1000000007
#print(S)

L= [1] if S[0][0]==S[1][0] else []
for i in range(1,N):
  if S[0][i]==S[0][i-1] and S[1][i]==S[1][i-1]:
    L.append(2)
  elif S[0][i]==S[1][i]:
    L.append(1)
#print(L)

for i,num in enumerate(L):
  if i==0:
    if num==1:
      cnt = 3
    else:
      cnt = 6
  else:
    if L[i]==1 and L[i-1]==1:
      cnt = (cnt*2)%p
    elif L[i]==1 and L[i-1]==2:
      cnt = (cnt*1)%p
    elif L[i]==2 and L[i-1]==1:
      cnt = (cnt*2)%p
    else: #2,2
      cnt = (cnt*3)%p
  #print(cnt)
print(cnt)

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

int P, Q;

vector<array<int, 4> > parse(int L){
	vector<array<int, 4>  > ret;
	ret.push_back(array<int, 4>{0, 0, 0, 0});
	for(int i = 0; i < L; i++){
		string s;
		cin >> s;
	
		array<int, 4> add{0,0,0,0};
		int idx = 0;
		while(idx < s.size() && s[idx] == '.'){
			idx++;
			add[3]++;
		}
		for(; idx < s.size(); idx++){
			switch(s[idx]){
				case '(': add[0]++; break;
				case ')': add[0]--; break;
				case '{': add[1]++; break;
				case '}': add[1]--; break;
				case '[': add[2]++; break;
				case ']': add[2]--; break;
			}
		}
		for(int j = 0; j < 3; j++) add[j] += ret[i][j];
		ret.push_back(add);
	}
	return ret;
}

int main(){
	while(cin >> P >> Q, P and Q){
		auto pstr = parse(P);
		auto qstr = parse(Q);
		vector<array<int , 3> > param;
		for(int r = 1; r <= 20; r++){
			for(int c = 1; c <= 20; c++){
				for(int s = 1; s <= 20; s++){
					bool flg = true;
					for(int i = 0; i < P; i++){
						if(pstr[i][0] * r + pstr[i][1] * c + pstr[i][2] * s != pstr[i + 1][3]){
							//printf("(%d %d %d %d(%d %d %d))", pstr[i][0] ,pstr[i][1], pstr[i][2], pstr[i][3], r, c, s);
							flg = false;
						}
					}
					//cout << endl;
					if(flg){
						param.push_back({r, c, s});
					}
				}
			}
		}
		for(int i = 0; i < Q; i++){
			int indent = 100000;
			for(auto val : param){
				int ii = qstr[i][0] * val[0] + qstr[i][1] * val[1] + qstr[i][2] * val[2];
				if(indent == 100000) indent = ii;
				else if(indent != ii) indent = -1;
			}
			if(i) cout << " ";
			cout << indent;
		}
		cout << endl;
	}
}
	

Measured memory_bytes: 3220
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(){
    LL N;
    cin>>N;
    LL res=0;
    FOR(A,1,N){
        res+=(N-1)/A;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3628
from itertools import combinations
def main():
    gojo_lst = [i**5 for i in range(-200,200)]
    gojo_dict = {}
    for i in range(-200,200):
        gojo_dict[i**5] = i
    kumiawase = combinations(gojo_lst,2)
    x = int(input())
    for a,b in kumiawase:
        #print(a,b)
        if a - b == x:
            print(gojo_dict[a],gojo_dict[b])
            break
        elif b - a == x:
            print(gojo_dict[b],gojo_dict[a])
            break



if __name__ == '__main__':
    main()


Measured memory_bytes: 9228
function main(input) {
  input = input.trim().split("\n");
  const [n, m] = input[0].split(" ").map(a => Number(a));
  const as = input[1].split(" ").map(a => Number(a));
  const bcs = input.slice(2).map(a => a.split(" ").map(b => Number(b)));
  as.sort((a, b) => a-b);
  bcs.sort((a, b) => b[1]-a[1]);
  const ds = [];
  for (let i = 0; i < m; i++) {
    if (n <= ds.length) break;
    const [b, c] = bcs[i];
    ds.push(...Array(b).fill(c));
  }
  let result = 0;
  for (let i = 0; i < n; i++) {
    const a = as[i];
    const d = ds[i];
    result += d ? Math.max(a, d) : a;
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int r, d, x;
    cin >> r >> d >> x;
    rep(i, 10) {
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ARB ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define bp  __builtin_popcount
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-14;
const ll mod=(ll)1e9+7;
int n;
ll k;
int arr[maxn];
int main()
{
    cin>>n>>k;
    for(int i=0; i<n; i++)
        cin>>arr[i];
    int x=0,y=0;
    for (int i = 0; i < n; i++)
        for (int j = i+1; j < n; j++)
        {
             if(arr[i]>arr[j])
                x++;
            if(arr[i]!=arr[j])
                y++;
        }
    cout<<(k*x+k*(k-1)/2%mod*y)%mod;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,unsigned long long>P;

int trie[200009][27],n,c,dp[100009];
string s;
typedef unsigned long long ull;
struct RollingHash{
  typedef unsigned long long ull;
  string S;
  ull B;
  int len;
  vector<ull> hash,p;
  RollingHash(){}
  RollingHash(string S_,ull B_=1000000007LL):
    S(S_),B(B_),len(S.length()),hash(len+1),p(len+1){
    hash[0]=0;p[0]=1;
    for(int i=0;i<len;i++){
      hash[i+1]=hash[i]*B+S[i];
      p[i+1]=p[i]*B;
    }
  }
  //S[l,r)
  ull find(int l,int r){
    return hash[r]-hash[l]*p[r-l];
  }
};

signed main(){
  vector<P>v;
  r(i,200009)r(j,27)trie[i][j]=-1;
  cin>>n;
  string t[n];
  r(i,n){
    cin>>s;
    if(s.size()<=500){
        int idx=0;
        r(j,s.size()){
            int p=s[j]-'a';
            if(trie[idx][p]==-1) trie[idx][p]=++c;
            idx=trie[idx][p];
        }
        trie[idx][26]=1;
    }
    else{
        RollingHash R(s);
        v.push_back(P(s.size(),R.find(0,s.size())));
    }
  }
  cin>>s;
  RollingHash R(s);
  dp[0]=1;
  r(i,s.size()){
    int idx=0,sum=0,j=i;
    while(trie[idx][s[j]-'a']!=-1 && j!=s.size()){
      idx=trie[idx][s[j]-'a'];
      if(trie[idx][26]==1)dp[j+1]+=dp[i];
      j++;
      dp[j]%=1000000007;
    }
    r(j,v.size()){
        int len=v[j].first;
        if(len+i>s.size())continue;
        if(R.find(i,i+len)==v[j].second){
            dp[i+len]+=dp[i];
            dp[i+len]%=1000000007;
        }
    }
  }
  cout<<dp[s.size()]<<endl;
}


Measured memory_bytes: 26396
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;

    int N, M;
    io.read(N, M);
    vector<int> a(M);
    vector<int> b(M);
    for(int i = 0; i < M; i++){
        io.read(a[i], b[i]);
        a[i]--;
        b[i]--;
    }
    vector<vector<int>> v(N);
    for(int i = 0; i < M; i++){
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }
    for(int i = 0; i < N; i++){
        cout << v[i].size() << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int N, C, s, t, c, a[33][100009], x[100009];
int main() {
  cin >> N >> C;
  for (int i = 0; i < N; i++) {
    cin >> s >> t >> c; c--;
    for (int j = s; j < t; j++) a[c][j] = 1;
  }
  for (int i = 0; i < C; i++) {
    for (int j = 0; j <= 100000; j++) {
      if (a[i][j + 1]) a[i][j] = 1;
      x[j] += a[i][j];
    }
  }
  cout << *max_element(x, x + 100001) << endl;
  return 0;
}


Measured memory_bytes: 12544
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input! {a:i32,b:i32};

    println!("{}", if a%2!=0 && b%2!=0 {"Odd"} else {"Even"});

}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    string s;
    cin >> s;
    string ans = "";

    rep(i, s.size()){
        ans.append("x");
    }

    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define il inline
#define rg register
using namespace std;
int s, t, n, m;
il void chkmax(int &a, int b) {a = a > b ? a : b;}
il void chkmin(int &a, int b) {a = a < b ? a : b;}
il int read() {
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) {
		if(c == '-') f = -f;
		c = getchar();
	}
	while(isdigit(c)) {
		x = (x << 1) + (x << 3) + c - '0';
		c = getchar();
	}
	return x * f;
}
il void write(int x) {
	char c[33] = {0}, tot = 0;
	if(x == 0) {puts("0"); return;}
	while(x) {c[++ tot] = x % 10 + '0'; x /= 10;}
	while(tot) {putchar(c[tot --]);}
	return ;
}
string a, b;
int main() {
	cin >> a >> b;
	int k = a.size();
	for(int i = 0;i < k;i ++) {
		if(a[i] ^ b[i]) n ++;
	}
	cout << n;
	return 0;
}


Measured memory_bytes: 3836
n, m = gets.split.map(&:to_i)
roads_count = Array.new(n, 0)
for i in 0...m do
  a, b = gets.split.map(&:to_i)
  roads_count[a - 1] += 1
  roads_count[b - 1] += 1
end
for j in 0...n do
  puts roads_count[j]
end


Measured memory_bytes: 1788
import java.util.Scanner;

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

	while (scan.hasNext()) {
	    int n = scan.nextInt();

	    if (0 == n)
		break;
	    
	    int num = scan.nextInt();
	    int sum = num; 
	    int max = num;
	    int min = num;
	    for (int i=1; i<n; i++) {
		num = scan.nextInt();
		sum += num;

		if (num > max)
		    max = num;
		if (num < min)
		    min = num;
	    }
	    sum -= max;
	    sum -= min;
	    
	    System.out.println(sum/(n-2));
	}
    }


}

Measured memory_bytes: 19120
#include <stdio.h>

void merge_sort(int x[], int n)
{
	static int y[100001] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, j, W, H, p[100001], q[100001];
	scanf("%d %d", &W, &H);
	for (i = 0; i < W; i++) scanf("%d", &(p[i]));
	for (j = 0; j < H; j++) scanf("%d", &(q[j]));
	merge_sort(p, W);
	merge_sort(q, H);
	
	int count[2] = {};
	long long ans = 0;
	for (i = 0, j = 0; i < W || j < H; ) {
		if (i == W) ans += q[j++];
		else if (j == H) ans += p[i++];
		else if (p[i] < q[j]) {
			ans += (long long)p[i++] * (H - count[1] + 1);
			count[0]++;
		} else {
			ans += (long long)q[j++] * (W - count[0] + 1);
			count[1]++;
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2876
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/


int main(){
    int n, x; cin >> n >> x;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    int sum = 0;
    int count = 1;
    rep(i, n){
        sum += l[i];
        if(sum <= x) count++;
        else break;
    } 
    cout << count << endl;
}

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

using namespace std;
int main() {
	int n, m, q;
	cin >> n >> m >> q;
	vector<vector<int> > tbl(n, vector<int>(n, 0));
	for(int i = 0; i < m; i++) {
		int l, r;
		cin >> l >> r;
		for(int j = r - 1; j < n; j++) {
			tbl[l-1][j]++;
		}
	}
	for(int i = 0; i < q; i++) {
		int pi, qi;
		cin >> pi >> qi;
		pi--;
		qi--;
		int sum = 0;
		for(int j = pi; j <= qi; j++) {
			sum += tbl[j][qi];
		}
		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	string str;cin >> str;
	if(str.back() == '0')cout << "pon" << endl;
	if(str.back() == '1')cout << "pon" << endl;
	if(str.back() == '2')cout << "hon" << endl;
	if(str.back() == '3')cout << "bon" << endl;
	if(str.back() == '4')cout << "hon" << endl;
	if(str.back() == '5')cout << "hon" << endl;
	if(str.back() == '6')cout << "pon" << endl;
	if(str.back() == '7')cout << "hon" << endl;
	if(str.back() == '8')cout << "pon" << endl;
	if(str.back() == '9')cout << "hon" << endl;

	return 0;
}


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

int main(){
	int H, W, i, j;
	
	while(1){
		cin >> H >> W;
		if (H == 0 && W == 0){
			break;
		}
		for (i = 0; i < H; i++){
			for(j = 0; j < W; j++){
				if((i + j) % 2 == 0){
					cout << '#';
				}else{
					cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main(){
  int i,m=0;
  int d[100]={};
  while(cin >> i) d[i-1]++;
  for(i=0;i<100;i++) m=max(m,d[i]);
  for(i=0;i<100;i++) if(d[i]==m) cout << (i+1) << endl; 
}

Measured memory_bytes: 1160
mx = 1000000
haming = {1=>1}
mem = [1]

while mem != []
	nextmem = []
	mem.each {|h|
		[2,3,5].map {|x|x*h}.each{|h2|
			if h2 <= mx and !haming[h2]
				nextmem.push h2
				haming[h2] = 1
			end
		}
	}
	mem = nextmem
end
haming = haming.keys
while gets.split.map(&:to_i)!=[0]
	m,n = $_.split.map(&:to_i)
	puts haming.count {|x|
		(m..n).member? x
	}
end

Measured memory_bytes: 6108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,w; cin >> h >> w;
    vector<vector<int>> c(10,vector<int> (10));
    for(int i = 0; i < 10; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            cin >> c[i][j];
        }
    }
    for(int i = 0;i < 10; i++)
    {
        for(int j = 0;j < 10; j++)
        {
            for(int k = 0; k < 10; k++)
            {
                c[i][j] = min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
    for(int i = 0;i < 10; i++)
    {
        for(int j = 0;j < 10; j++)
        {
            for(int k = 0; k < 10; k++)
            {
                c[i][j] = min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
    for(int i = 0;i < 10; i++)
    {
        for(int j = 0;j < 10; j++)
        {
            for(int k = 0; k < 10; k++)
            {
                c[i][j] = min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
    int ans = 0;
    vector<vector<int>> A(h,vector<int> (w));
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            cin >> A[i][j];
            if(A[i][j] != -1)
            {
                ans += c[A[i][j]][1];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_D
#??????????????????

def cal(truck_num, cargos):
    p = 0
    
    for i in range(len(cargos) - truck_num + 1):
        if not i == 0 and p < sum(cargos[:i + 1]):
            continue
        if truck_num > 1:
            r = max(sum(cargos[:i + 1]), cal(truck_num - 1, cargos[i + 1:]))
            if i == 0:
                p = r
            elif p > r:
                p = r
        else:
            return sum(cargos)
    return p

def check(truck_num, carogs, target_load):
    
    cur_truck = 1
    cur_weight = 0
    for weight in cargos:
        cur_weight += weight
        if cur_weight > target_load:
            cur_weight = weight
            cur_truck += 1
            if cur_truck > truck_num:
                return False
    return True

def solve(truck_num, cargs):

    max_load = sum(cargos)
    min_load = max(cargos)
    #print(min_load, max_load)
    while min_load < max_load:
        target_load = int((min_load + max_load)/2)
        if check(truck_num, cargos, target_load):
            max_load = target_load
        else:
            min_load = target_load + 1
        #print(min_load, max_load)
        
    return max_load

if __name__ == "__main__":
    line = input()
    truck_num = int(line.split(" ")[1])
    line_num = int(line.split(" ")[0])
    cargos = [int(input()) for i in range(line_num)]
    print(solve(truck_num,cargos))

Measured memory_bytes: 11624
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{
    public static void main(String[] args) throws IOException
    {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s;
		while((s=br.readLine())!=null){
			System.out.println(fact(Integer.parseInt(s)));
		}
    }
    
    private static long fact(int n)
    {
    	if(n==0) return 0;
    	if(n==1) return 1;
    	return fact( n, 1, 0);
    }
    
    private static long fact(int n,long temp, long pre)
    {
        if(n==2) return temp * 2;
        else     return fact(n-1,temp*n, temp);
    }
}

Measured memory_bytes: 9344