akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    rep(i, S.length()) { ans += S[i] != T[i]; }
    cout << ans << endl;
}

Measured memory_bytes: 3856
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    character(11):: s,t

    read*, s
    read*, t

    if (t(1:len_trim(s)) == s(1:len_trim(s))) then
        print'(a)', 'Yes'
    else
        print'(a)', 'No'
    end if
    
end program main

Measured memory_bytes: 2924
import collections

N = int(input())
D = list(map(int, input().split()))

c = collections.Counter(D)
c = sorted(c.items(), key=lambda x:x[0])

rates, counter = list(zip(*c))

acc = 0
found = False
for i in range(len(counter)):
    acc += counter[i]
    if acc == N/2:
        found = True
        break
    if acc > N/2:
        found = False
        break

if found == False:
    print(0)
else:
    print(rates[i+1]-rates[i])

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

using namespace std;

int main(){
	string s;
	cin >> s;
	int n;
	cin >> n;
	
	int ncal = s[0] -'0';
	for(int i = 2;i < s.size();i+=2){
		if(s[i-1] == '+'){
			ncal += s[i] - '0';
		}else{
			ncal *= s[i] - '0';
		}
	}
	
	int rcal = 0;
	int tmulti = 1;
	for(int i = 0;i < s.size()-1;i+=2){
		if(s[i+1] == '+'){
			rcal += tmulti * (s[i] - '0');
			tmulti = 1;
		}else{
			tmulti *= s[i] - '0';
		}
	}
	rcal += tmulti * (s[s.size()-1] - '0');
	
	if(n == rcal && n != ncal){
		cout << "M" << endl;
	}else if(n != rcal && n == ncal){
		cout << "L" << endl;
	}else if(n == rcal && n == ncal){
		cout << "U" << endl;
	}else{
		cout << "I" << endl;
	}
	return 0;
}


Measured memory_bytes: 3240
package main

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


func solveFromFile() int{
    var nu int
    scanner := bufio.NewScanner(os.Stdin)
    file, err := os.Open(os.Args[1])
    if err != nil {
      log.Fatalf("failed opening file: %s", err)
    }
    scanner = bufio.NewScanner(file)
    scanner.Scan()

	  n, err2 := strconv.Atoi(scanner.Text())
    nu = n
    if err2 != nil {
      log.Fatalf("failed opening file: %s", err2)
      
    }

    defer file.Close()

    return solution(nu)
}

//========== Implement Algorithm =======================
func solution(num int) int{
  temp:= strconv.Itoa(num)
  tempInt,_ := strconv.Atoi(string(temp[len(temp)-1]))

  return tempInt
}

func main() {

//================== Variables used ====================
  var num, ret int
//======================================================

  if len(os.Args) >=2{
//============== Get return value from File ============
    ret = solveFromFile()


  }else{
//============== Get return value from STDIN ===========
    size,_ := fmt.Fscan(os.Stdin, &num)
    size++

    //fmt.Scan(&num)
    ret = solution(num)
  }

//================== OUTPUT ============================
  if ret == 3{
    fmt.Println("bon")
  }else if ret == 0||ret == 1||ret == 6||ret == 8 {
    fmt.Println("pon")
  }else {
    fmt.Println("hon")
  }
  
}


Measured memory_bytes: 1888
#include <stdio.h>
#include<string.h>
#include<stdlib.h>



int main(void){
    int k,l;
    char s[120];
    scanf("%d",&k);
    for(int i=0;i<120;++i){
    scanf("%s",&s[i]);
    }
    l=strlen(s);
    
    if(k>=l){for(int i=0;i<l;++i){ printf("%c",s[i]);}return 0;}
    if(k<l){for(int i=0;i<k;++i){ printf("%c",s[i]);}printf("...");return 0;}
}


Measured memory_bytes: 1724
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <limits>
#include <iomanip>

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

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

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------

int main() {
    string s;
    cin >> s;
    if (s == "SUN") {
        cout << "7" << endl;
        return 0;
    }
    if (s == "MON") {
        cout << "6" << endl;
        return 0;
    }
    if (s == "TUE") {
        cout << "5" << endl;
        return 0;
    }
    if (s == "WED") {
        cout << "4" << endl;
        return 0;
    }
    if (s == "THU") {
        cout << "3" << endl;
        return 0;
    }
    if (s == "FRI") {
        cout << "2" << endl;
        return 0;
    }
    if (s == "SAT") {
        cout << "1" << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-

def main():
	s = raw_input()
	s2 = raw_input()
	x, y = [int(x) for x in s2.split()]
	# print s, x, y

	xt, yt = [], []
	d, step = 0, 0
	for c in s:
		if c == 'T':
			if d == 0:
				xt.append(step)
			else:
				yt.append(step)
			step = 0
			d = 1 - d
		else:
			step += 1
	if step > 0:
		if d == 0:
			xt.append(step)
		else:
			yt.append(step)

	x -= xt[0]
	xt = xt[1:]
	xd, yd = set([0]), set([0])
	for t in xt:
		xd2 = set()
		for i in xd:
			xd2.add(i + t)
			xd2.add(i - t)
		xd = xd2
	for t in yt:
		yd2 = set()
		for i in yd:
			yd2.add(i + t)
			yd2.add(i - t)
		yd = yd2

	if x in xd and y in yd:
		print 'Yes'
	else:
		print 'No'


if __name__ == '__main__':
	main()

Measured memory_bytes: 3500
from collections import*
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def find(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.find(self.root[x])
      return self.root[x]
  def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if(x == y):return 
    elif(self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1
  def same(self, x, y):
    return self.find(x) == self.find(y)
  def count(self, x):
    return -self.root[self.find(x)]
n,m=map(int,input().split())
uf=UnionFind(n)
for _ in range(m):
  a,b,z=map(int,input().split())
  uf.unite(a,b)
a=dict(Counter([uf.find(i) for i in range(1,n+1)]))
ans=n
for i in a:
  ans-=a[i]-1
print(ans)

Measured memory_bytes: 110596
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>
#include <algorithm>

using namespace std;

const int INF = 1e9;

vector<int> check(vector<int> b, int n){
    if (n == 1){
        vector<int> ret;
        if (b[0] == 1)  ret.push_back(1);
        return ret;
    }
    vector<int> ans;
    for (int i=0; i<n; i++){
        if (b[i] > i+1)  return ans;
    }
    for (int i=1; i<=n; i++){
        if (b[i-1] == i){
            vector<int> b2 = b;
            b2.erase(b2.begin()+i-1);
            ans = check(b2, n-1);
            if (ans.size() != 0){
                ans.push_back(i);
                return ans;
            }
        }
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    vector<int> b(n);
    for (int i=0; i<n; i++){
        cin >> b[i];
    }
    vector<int> ans = check(b, n);
    if (ans.size() != 0){
        for (int i=0; i<n; i++){
            cout << ans[i] << endl;
        }
    }
    else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      //子供の人数
      int n = sc.nextInt();
      int total = 0;
      
      for(int i = 1;i <= n;i++){
        total += i;
      }
      System.out.print(total);
	}
}


Measured memory_bytes: 35352
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){

    string s,t;
    cin>>s>>t;
    
    int c=0;
    if(s[0]==t[0])c++;
    if(s[1]==t[1])c++;
    if(s[2]==t[2])c++;
    
    cout<<c<<endl;
}



Measured memory_bytes: 3144
n = int(input())
s = input()

ans = 0
for i in range(10):
    n = s.find(str(i))
    if n == -1:
        continue
    for j in range(10):
        m = s.find(str(j), n+1)
        if m == -1:
            continue
        for k in range(10):
            if str(k) in s[m+1:]:
                ans += 1
print(ans)


Measured memory_bytes: 3060
class Dice
	def initialize(n=Array.new(6,0))
		@num = n
		@position = { u: @num[0],
									d: @num[5],
									r: @num[2],
									l: @num[3],
									f: @num[4],
									b: @num[1]
		}
		@LRRoll = [:u, :b, :d, :f]
		@FBRoll = [:u, :l, :d, :r]
		@UDRoll = [:f, :l, :b, :r]
	end

	def value
		@position[:u]
	end

	def move(v)
		case v
		when "N"
			Roll(@LRRoll)
		when "S"
			Roll(@LRRoll, -1)
		when "E"
			Roll(@FBRoll)
		when "W"
			Roll(@FBRoll, -1)			
		end
	end

	def Roll(roll, v=1)
		v = -1 if v != 1
		t = @position[roll[0]]
		@position[roll[  0]] = @position[roll[1*v]]
		@position[roll[1*v]] = @position[roll[2*v]]
		@position[roll[2*v]] = @position[roll[3*v]]
		@position[roll[3*v]] = t
	end

end
n = gets.chomp.split(" ").map &:to_i
d = Dice.new(n)
gets.chomp.chars { |c| d.move(c) }
p d.value

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

int main() {
	int n;
	cin >> n;
	double ans = (n+1)/2 / (double) n;
	printf("%.10f\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	int[] S;
	int H = 0;
	int largest;
	void run() {
		Scanner sc = new Scanner(System.in);
		S = new int[2000001];
		while(true) {
			String s = sc.next();
			if(s.startsWith("i")){
				insert(sc.nextInt());
			}else if(s.startsWith("ex")) {
				int ans = extractMax();
				System.out.println(ans);
			}else if(s.startsWith("en")){
				break;
			}
		}
		sc.close();
	}
	
	void insert(int key) {
		H++;
		S[H] = -Integer.MAX_VALUE;
		heapIncreaseKey(H, key);
	}
	
	void heapIncreaseKey(int i, int key) {
		if(key < S[i]) return;
		S[i] = key;
		while(i > 1 && S[i/2] < S[i]) {
			int tmp = S[i];
			S[i] = S[i/2];
			S[i/2] = tmp;
			i = i/2;
		}
	}
	
	int extractMax() {
		if(H < 1) return -Integer.MAX_VALUE;
		int max = S[1];
		S[1] = S[H];
		H--;
		maxHeapify(1);
		return max;
	}
	
	void maxHeapify(int i) {
		int l = i*2;
		int r = i*2+1;
		if(l <= H && S[l] > S[i]) {
			largest = l;
		}else {
			largest = i;
		}
		if(r <= H && S[r] > S[largest]) {
			largest = r;
		}
		if(largest != i) {
			int tmp = S[i];
			S[i] = S[largest];
			S[largest] = tmp;
			maxHeapify(largest);
		}
		
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 556324
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int gcd(int n, int m) {
    if (n < m) swap(n, m);
    while (m != 0) {
        int r = n % m;
        n = m;
        m = r;
    }
    return n;
}

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

    int n;
    cin >> n;

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

    r = 0;
    for (int i = n - 1; i >= 0; i--) {
        r = gcd(r, a[i]);
        c[i] = r;
    }

    r = 0;
    for (int i = 0; i < n; i++) {
        r = max(r, gcd(b[i], c[i + 1]));
    }

    //a[0]を書き換えるなら、a[1]~a[n-1]のgcdでOK
    //a[0]を書き換えないなら、

    cout << r << endl;

    return 0;
}

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

int main() {
	string S; cin >> S;
  	if(S == "Sunny") cout << "Cloudy" << endl;
	else if(S == "Cloudy") cout << "Rainy" << endl;
  	else if(S == "Rainy") cout << "Sunny" << endl;
}

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

int main(){
  long int n,val=0,sum=0;
  long int arr[1000000];
  cin>>n;
  for(int i=0;i<n;i++)
  {
    arr[i]=val+1;
    val++;
  }int i=0;
  while(i<n){
    if(arr[i]%3==0)
    {
      arr[i]=atoi("Fizz");
    }
    else if(arr[i]%5==0)
    {
      arr[i]=atoi("Buzz");
    }
    else
    {
      arr[i]=i+1;
      sum+=arr[i];
    }
    i++;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 10788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#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)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll k,t;
bool check(vl a){
    ll cnt=0;
    rep(i,t){
        if(a[i]>0) cnt++;
    }
    return cnt==1;
}
int main(){
    cin>>k>>t;
    vl a(t);rep(i,t)cin>>a[i];
    int pre=-1;
    ll ans=0;
    rep(i,k){
        P mx={0,-1};
        bool nochoice=check(a);
        rep(j,t){
            if(mx.fi<a[j]){
                if(pre==j){
                    if(nochoice){
                        pre=j;
                        ans++;
                        mx={a[j],j};
                    }
                    else continue;
                }
                else{
                    mx={a[j],j};
                }
            }
        }
        a[mx.se]--;
        pre=mx.se;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
const int MOD = 1e9 + 7;
using pii=std::pair<int,int>;
using namespace std;

const int maxn = 1e5 + 5;

int n, m, x[maxn], y[maxn];
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 0; i < n; i++)
        cin >> x[i];
    for(int i = 0; i < m; i++)
        cin >> y[i];
    sort(x, x + n);
    sort(y, y + m);
    int xlosum = 0, ylosum = 0, xlensum = 0, ylensum = 0;
    for(int i = 0; i < n; i++)
    {
        xlensum += i * x[i] - xlosum;
        xlensum %= MOD;
        xlosum += x[i];
        xlosum %= MOD;
    }
    for(int i = 0; i < m; i++)
    {
        ylensum += i * y[i] - ylosum;
        ylensum %= MOD;
        ylosum += y[i];
        ylosum %= MOD;
    }
    cout << (xlensum * ylensum) % MOD << "\n";
    return 0;
}

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

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

    int push[100100] = {0};
    int now = 1;
    int t = -1;
    for (int i=1; i<=N; ++i) {
        if (a[now] == 2) {
            t = i;
            break;
        }
        else if (push[a[now]] == 1) break;
        else {
            push[a[now]] = 1;
            now = a[now];
        }
    }

    cout << t << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

//改造
typedef long long int ll;
using namespace std;

//ここから編集する

int main() {
    ll n, m;
    cin >> n >> m;
    ll x;
    if (n * 2 < m) {
        x = (m - 2 * n) / 4;
        cout << n + x << endl;
    }else{
        cout << m / 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
t="AKIHABARA"
old_s=input()
new_s=""
for c in old_s:
    if c!='A':
        new_s+=c
if new_s!="KIHBR":
    print('NO')
    sys.exit()
s=old_s
n=len(t)
for i in range(2**n):
    ans=""
    for j in range(n):
        if i&(1<<j):
            ans+=t[j]
    if ans==s:
        print('YES')
        sys.exit()
print('NO')

Measured memory_bytes: 9072
n = int(input())
dp = [0, 0, 0]
for i in range(n):
    todo = list(map(int, input().split()))
    ndp = [0, 0, 0]
    ndp[0] = max(dp[1], dp[2]) + todo[0]
    ndp[1] = max(dp[0], dp[2]) + todo[1]
    ndp[2] = max(dp[0], dp[1]) + todo[2]
    dp = ndp
print(max(ndp))

Measured memory_bytes: 47960
import numpy as np
n = int(input())
a = list(map(int, input().split()))

a.sort()
a = np.array(a)
min_index = a.argmin()

while True:
    damaged = a % a[min_index]
    nonzero_index = damaged.nonzero()
    nonzero = damaged[nonzero_index]
    if nonzero.size == 0:
        break
    target = nonzero.argmin()
    min_index = nonzero_index[0][target]
    a[min_index] = nonzero[target]
print(a[min_index])


Measured memory_bytes: 23104
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int main() {

	ll N, M, A[112345];

	scanf("%lld%lld", &N, &M);

	rep(i, N) scanf("%lld", &A[i]);

	map<ll, ll> mod;

	ll sum = 0;
	rep(i, N) {
		sum += A[i];
		mod[sum % M]++;
	}

	ll count = 0;
	for (auto m : mod) {
		if (!m.first) count += m.second;
		count += m.second * (m.second - 1) / 2;
	}

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

	return 0;
}

Measured memory_bytes: 4992
#include<iostream>

using namespace std;

int main(){

  int n;

  while(cin>>n){



    if(n==0){
      break;
    }
    int a[n];
    int max,min;

    max=0;
    min=1000;

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

      if(a[i]>max){
	max=a[i];
      }

      if(a[i]<min){
	min=a[i];
      }
    }

    int sum;

    sum=0;

    for(int p=0;p<n;p++){
      sum=sum+a[p];
    }

    sum=sum-max-min;

  

    cout << sum/(n-2) << endl; 

   

  }

  



  return 0;
}

Measured memory_bytes: 2964
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int 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 ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
 
int main()
{
  long long count;
  cin >> count;
  vector<long long> v(5);
  long long a, b, c, d, e;
 
  rep(i, 5) {
    //cin >> v.at(i);
    cin >> a >> b >> c >> d >> e;
  }
  
  //vector<long long>::iterator min = min_element(v.begin(), v.end());
 
  long long t;

  //t = count/(*min)
  
 
  cout << max({(count - 1)/a, (count - 1)/b, (count - 1)/c, (count - 1)/d, (count - 1)/e}) + 5 << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int  h, w, n, a[10000];
  int  i, j, k, o[100];

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

  k = 0;
  for( i = 0; i < h; i++) {

    if(i%2 == 0) {
      for( j = 0; j < w; j++) {
        printf("%d ", k+1);
        a[k]--;
        if(a[k] == 0) k++;
      }printf("\n");
    }

    else {
      for( j = w-1; j >= 0; j--) {
        o[j] = k+1;
        a[k]--;
        if(a[k] == 0) k++;
      }
      for( j = 0; j < w; j++) {
        printf("%d ", o[j]);
      }printf("\n");
    }
    
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
int i[1000000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,w;
  cin >>a;
  if(a==2){
    cout <<"2\n";
    return 0;
  }
  while(1){
    if(a%2!=0){
      bool can=true;
      for(int n=3;n<a;n++){
	if(a%n==0){
	  can=false;
	  break;
	}
      }
      if(can){
	cout <<a<<'\n';
	break;
      }
    }
    a++;
  }
  return (0);
}


Measured memory_bytes: 256
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  const len = +readLine();
  const arr = readLine()
    .split(" ")
    .map((n) => BigInt(n));
  const MOD = BigInt(1e9 + 7);
  let sum = arr.reduce((a, b) => a + b, BigInt(0));
  let result = BigInt(0);

  for (let i = 0; i < len; i++) {
    sum -= arr[i];
    result += arr[i] * sum;
    result %= MOD;
  }

  console.log(Number(result));
}


Measured memory_bytes: 76992
#include<cstdio>
#include<algorithm>
int a[1001];

int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
    std::sort(a+1,a+1+n);
    int ans = 0;
    for(int i = 1; i <= k; i++) ans += a[i];
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define PI 3.14159265358979323846
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
signed main(){
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}






Measured memory_bytes: 3620
from collections import deque

H, W = map(int, input().split())
S = ['#'*(W+2)]
white_num = 0
for _ in range(H):
    s = input()
    white_num += s.count('.')
    S.append('#'+s+'#')
S.append('#'*(W+2))

C = [[-1]*(W+2) for _ in range(H+2)]
C[1][1] = 1
q = deque()
q.append((1, 1))
xlist = [0, 0, 1, -1]
ylist = [1, -1, 0, 0]
while len(q) > 0:
    x, y = q.popleft()
    for i in range(4):
        mx = x + xlist[i]
        my = y + ylist[i]
        if S[mx][my] == '#' or C[mx][my] >= 0:
            continue
        C[mx][my] = C[x][y] + 1
        q.append((mx, my))
if C[H][W] == -1:
    print(-1)
else:
    print(white_num - C[H][W])


Measured memory_bytes: 3316
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

ll oddsolve(ll a) { return (a+1)/2 % 2; }
ll solve(ll a) {
    if (a % 2 == 1) return oddsolve(a);
    else return oddsolve(a+1) ^ (a+1);
}
int main() {
    long long A, B; cin >> A >> B;
    cout << (solve(B) ^ solve(A-1)) << endl;
    //B以下のxor和から、A未満のxor和を引く
    //ただし、xorにおいては加算が減算
}

Measured memory_bytes: 256
import java.util.*;

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

        int[] heights = new int[N];
        for (int i=0; i<N; i++) {
            heights[i] = sc.nextInt();
        }

        int[] dp = new int[N];
        dp[1] = Math.abs(heights[1] - heights[0]);
        int INF = 1<<29;
        for (int i=2; i<N; i++) {
            dp[i] = INF;
        }

        for (int i=2; i<N; i++) {
            dp[i] = Math.min(dp[i], dp[i-1] + Math.abs(heights[i] - heights[i-1]));
            dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(heights[i] - heights[i-2]));
        }

        System.out.println(dp[N-1]);
    }
}



Measured memory_bytes: 51260
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  int r,ss,p;cin>>r>>ss>>p;
  int ans=0;
  string s;cin>>s;
  map<int,string>robo;
  for(int i=1;i<=n;i++){
    if(robo.count(i%k))robo.at(i%k).push_back(s.at(i-1));
    else robo[i%k]=s.at(i-1);
  }
  for(auto robot:robo){
    int size=robot.second.size();
    int tmp=0;
    for(int i=0;i<size;i++){
      if(i>0&&robot.second.at(i-1)==robot.second.at(i)){
        tmp++;
      }
      else tmp=0;
      if(robot.second.at(i)=='r'){
        if((i==0||robot.second.at(i-1)!=robot.second.at(i))||tmp%2==0){
          ans+=p;
        }
      }
      if(robot.second.at(i)=='s'){
        if((i==0||robot.second.at(i-1)!=robot.second.at(i))||tmp%2==0){
          ans+=r;
        }
      }
      if(robot.second.at(i)=='p'){
        if((i==0||robot.second.at(i-1)!=robot.second.at(i))||tmp%2==0){
          ans+=ss;
        }
      }
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 10532
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    long long i,j;
    stack<char> st;
    string a,b;
    cin>>a>>b;
    long long matrix[a.size()+1][b.size()+1]= {0};
    memset(matrix,0,sizeof(matrix));
    for(i=1; i<=a.size(); i++)
    {
        for(j=1; j<=b.size(); j++)
        {
            if(a[i-1]!=b[j-1])
            {
                matrix[i][j]=max(matrix[i-1][j],matrix[i][j-1]);
            }
            else
            {
                matrix[i][j]=1+matrix[i-1][j-1];
            }
        }
    }
    for(i=a.size(),j=b.size(); i>=0,j>=0; )
    {
        if(matrix[i][j]==0)
        {
            break;
        }
        if(matrix[i][j]==matrix[i-1][j])
        {
            i--;
        }
        else if(matrix[i][j]==matrix[i][j-1])
        {
            j--;
        }
        else
        {
            st.push(a[i-1]);
            i--;
            j--;
        }
    }
    while(!st.empty())
    {
        cout<<st.top();
        st.pop();
    }
    return 0;
}


Measured memory_bytes: 70656
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

string S;
ll N;
vector<string> vs;

void dp(ll i = 0, string S = "") {
    if (S.length() == N) {
        vs.push_back(S);
        return;}
    S = S + to_string(i);

    ll max_n = -1;
    REP(i, S.length()) {
        if ((int)S[i]-'0' >= max_n) {
            max_n = (int)S[i] - '0' + 1;
        }
    }
    REP(i, max_n + 1) { dp(i, S); }
}

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

    dp();
    UNIQUE(vs)
    REP(j, vs.size()){
        REP(i, N){
            cout << char((int)(vs[j][i]-'0')+'a') ;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 40552
#include <iostream>

using namespace std;
using ll = long long;

#define IN_LL(v) ll v;cin>>v;
#define OUT(v) cout<<v<<endl

int main() {
  IN_LL(N); IN_LL(M);

  if (N * 2 < M) {
    ll k = (M - 2 * N) / 4 - 1;
    M -= 2 * k;
    N += k;
    while (N * 2 < M) {
      M-=2;
      N+=1;
    }
  }
  OUT(min(N, M/2));


  return 0;
}


Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]
A = []
for i in range(N):
    A.append([int(x) for x in input().split()])
A.sort()
result = 0
for i in range(N):
    tmp = 0
    if A[i][1] >= M:
        result += A[i][0]*M
        break
    else:
        result += A[i][0] * A[i][1]
        M -= A[i][1]
print(result)


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

using namespace std;

typedef long long int lli;

int main(int argc, char const *argv[]) {
  lli n, x, ans=0;
  cin >> n >> x;
  vector<lli> a(n);
  for (size_t i = 0; i < n; i++) cin >> a[i];
  for (size_t i = 0; i < n-1; i++) {
    if (a[i]+a[i+1] > x) {
      lli sub = (a[i]+a[i+1])-x;
      ans+=sub;
      a[i+1] -= sub;
      if (a[i+1] < 0) a[i+1]=0;
    }
    else continue;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  string s;
  cin >> s;
  vector<int> S(s.size());
  REP(i,S.size()){
    S.at(i) = s.at(i) - '0';
  }

  vector<int> A(S.size());
  vector<int> B(S.size());
  REP(i,S.size()){
    if(i%2 == 0){
      A.at(i) = 0;
      B.at(i) = 1;
    }else{
      A.at(i) = 1;
      B.at(i) = 0;
    }
  }

  int cnt1 = 0;
  int cnt2 = 0;
  REP(i,S.size()){
    if(S.at(i) == A.at(i)){
      cnt1++;
    }else if(S.at(i) == B.at(i)){
      cnt2++;
    }
  }
  cout << min(cnt1,cnt2) << endl;
}

Measured memory_bytes: 1664
#!/usr/bin/env python3
import sys
import heapq
INF = float("inf")


def argmax(a):
    m, n = -(1 << 31), -1
    for i, v in enumerate(a):
        if m < v:
            m, n = v, i
    return n


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.V = list(range(N))
        self.E = [[] for _ in range(N)]

    def add_edge(self, edge):
        """辺を加える。edgeは(始点, 終点、重み)からなるリスト
        重みがなければ、重み1とする。
        """
        if len(edge) == 2:
            edge.append(1)
        elif len(edge) != 3:
            print("error in add_edge")
            pass

        s, t, w = edge
        self.E[s].append([t, w])
        self.E[t].append([s, w])  # 無向グラフを仮定。逆向きにも辺を張る

        pass


def shortestPath(g: Graph, s: int):
    """ グラフgにおいて、始点sから各頂点への最短路を求める
    引数
    g: グラフ, s: 始点
    返り値
    dist: 始点からの距離が格納されたリスト
    prev: 始点から最短経路で移動する場合、各頂点に至る前の頂点のリスト
    """
    dist = [INF]*g.N
    dist[s] = 0

    prev = [None]*g.N
    Q = []
    heapq.heappush(Q, (dist[s], s))

    while len(Q) > 0:
        _, u = heapq.heappop(Q)
        for v, w in g.E[u]:
            if dist[v] > dist[u] + w:
                dist[v] = dist[u] + w
                prev[v] = u
                heapq.heappush(Q, (dist[v], v))
    return dist, prev


def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    g = Graph(N)
    for _f, _t in zip(a, b):
        g.add_edge([_f-1, _t-1])
    dist, prev = shortestPath(g, 0)
    s = argmax(dist)
    dist, prev = shortestPath(g, s)
    g = argmax(dist)

    c.sort()

    # print(dist, prev)
    ans = -1
    haichi = [0]*N
    while True:
        haichi[g] = c.pop()
        if ans == -1:
            ans = 0
        else:
            ans += haichi[g]
        if prev[g] == None:
            break
        else:
            g = prev[g]
    # 残っている箇所はスタートから近い順に埋めていく。
    buf = []
    for i in range(N):
        if haichi[i] == 0:
            buf.append(i)
    buf.sort(key=lambda x: dist[x])
    for b in buf:
        haichi[b] = c.pop()
        ans += haichi[b]
    print(ans)
    print(*haichi)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]"
    b = [int()] * (N-1)  # type: "List[int]"
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    c = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a, b, c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10092
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int ans = 0;
	for(int i = 1; i <= n; ++i){
		int x = i;
		int cnt = 0;
		while(x != 0){
			cnt++;
			x /= 10;
		}
		if(cnt % 2 != 0){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
string s=to_string(n);
int fn = 0;
for(auto c :s){
    fn += c - '0';
}
if(n%fn==0){
    cout << "Yes" << endl;
}
else{
    cout << "No" << endl;
}
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a.at(i);
    int previous = a.at(0);
    ll ans = 0;
    for (int i = 1; i < n; i++){
        if (previous > a.at(i)) {
            ans += previous - a.at(i);
        }
        else previous = a.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4044
#include "bits/stdc++.h"

using namespace std;

const int MOD = 1e9 + 7;

void solve(void)
{
	int h, w;
	cin >> h >> w;
	vector<string> g(h);
	for (int i = 0; i < h; i++)
	{
		cin >> g[i];
	}
	vector<vector<int>> hs(2020, vector<int>(2020)), ws(2020, vector<int>(2020));
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (j == 0)
			{
				ws[i][j] = g[i][j] == '.';
			}
			else
			{
				if (g[i][j] == '.')
				{
					ws[i][j] = ws[i][j-1] + 1;
				}
			}
		}
		for (int j = w-1; j > 0; j--)
		{
			if (ws[i][j-1] == 0 || ws[i][j] == 0)
			{
				continue;
			}
			ws[i][j-1] = ws[i][j];
		}
	}
	for (int j = 0; j < w; j++)
	{
		for (int i = 0; i < h; i++)
		{
			if (i == 0)
			{
				hs[i][j] = g[i][j] == '.';
			}
			else
			{
				if (g[i][j] == '.')
				{
					hs[i][j] = hs[i-1][j] + 1;
				}
			}
		}
		for (int i = h-1; i > 0; i--)
		{
			if (hs[i-1][j] == 0 || hs[i][j] == 0)
			{
				continue;
			}
			hs[i-1][j] = hs[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
	{
		if (g[i][j] == '.')
		{
			ans = max(ans, hs[i][j] + ws[i][j] - 1);
		}
	}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

int main(){
    int n, a, b, c, d;
    string s;
    string block_2, space_3;
    block_2 = "##";
    space_3 = "...";
    cin >> n >> a >> b >> c >> d;
    cin >> s;
    n -= 1;
    a -= 1;
    b -= 1;
    c -= 1;
    d -= 1;

    string s_s = s.substr(a, (c - a) + 1);
    string s_f = s.substr(b, (d - b) + 1);

    string ans;
    if (s_s.find(block_2) == string::npos and s_f.find(block_2) == string::npos){
        if(c > d){
            string S = s.substr(b - 1, (d - b) + 3);
            //cout << S << endl;
            if (S.find(space_3) == string::npos){
                ans = "No";
            }
            else{
                ans = "Yes";
            }
        }
        else{
            //cout << c << " " << d << endl;
            ans = "Yes";
        }
    }
    else{
        ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    cout<<max(max(A*C,A*D),max(B*C,B*D))<<endl;
    return 0;
}

Measured memory_bytes: 3688
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		private const int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start();
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			string str = Console.ReadLine();
			int q = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			LinkedList<char> list = new LinkedList<char>(str);
			bool reverse = false;
			for (int i = 0; i < q; i++) {
				string s = Console.ReadLine();
				if (s[0] == '1') {
					// 反転
					reverse = !reverse;
				} else {
					if ((!reverse && s[2] == '1') || (reverse && s[2] == '2')) {
						// 先頭に追加
						list.AddFirst(s[4]);
					} else {
						// 末尾に追加
						list.AddLast(s[4]);
					}
				}
			}
			char[] ans;
			if (reverse) {
				ans = list.Reverse().ToArray();
			} else {
				ans = list.ToArray();
			}
			Console.WriteLine(string.Concat(ans));


			Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(stopwatch.Elapsed);
		}
	}
}


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

int main(){
    int N,M,C;
    cin >> N >> M >> C;
    int call=0;
    //B配列
    vector<int> B(M, 0);
    for(int m=0; m<M; m++){
        cin >> B[m];
    }
    //A配列
    vector<vector<int>>  A(N, vector<int>(M));
    for(int n=0; n<N; n++){
        for(int m=0; m<M; m++){
            cin >> A[n][m];
        }
    }
    //回答
    for(int n=0; n<N; n++){
        int ans=0;
        for(int m=0; m<M; m++){
            ans += A[n][m]*B[m];
        }
        ans += C;
        if(ans>0){
            call += 1;
        }
    }

    cout << call  << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

void go(string s, char nxt, int n)
  {
  if(s.size() == n)
    {
    cout << s << endl;
    return;
    }

  for(char i = 'a'; i <= nxt; i++)
    {
    go(s + i, max(nxt, char(i+1)), n);
    }
  }

int main()
{
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  go("", 'a', n);
}


Measured memory_bytes: 1536
n,m=list(map(int,input().split()))

s=[0]*m
c=[0]*m

for i in range(m):
    ss,cc=list(map(int,input().split()))
    s[i]=ss
    c[i]=cc

if n==1:
    ns=0
    nt=9
elif n==2:
    ns=10
    nt=99
else:
    ns=100
    nt=999

for i in range(ns,nt+1):
    digs=[int(x) for x in str(i)]
    for j in range(m):
        if digs[s[j]-1]!=c[j]:
            break
    else:
        print(i)
        break
else:
    print(-1)

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

int main(void){
    int a, b;
    cin >> a >> b;
    int seki = a * b;

    if(seki % 2 == 0)
        cout << "Even" << endl;
    else if(seki % 2 != 0)
        cout << "Odd" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int num = 0;
  
  int a, b, c, d, e;
  for (int i = A; i < B + 1; i++) {
    e = i % 10;
    d = (i / 10) % 10;
    c = (i / 100) % 10;
    b = (i / 1000) % 10;
    a = i / 10000;

    if (a == e && b == d) {
      num++;
    }
  }
  
  cout << num;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

bool check(ll n, ll b) {
    if (b == 0) return false;
    return n / b == n % b;
}

int main() {

    ll n;
    cin >> n;
    ll ans = 0;
    for (ll x = 1; x * x <= n; x++) {
        if (n % x == 0) {
            if (check(n, x - 1)) ans += x - 1;
            if (check(n, (n / x) - 1)) ans += (n / x) - 1;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 380