akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdint>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <sstream>

int main(void)
{
    int64_t N;
    std::cin >> N;

    int64_t min = INT64_MAX;
    int64_t count = 0;
    for (int64_t i = 0; i < N; ++i) {
        int64_t v;
        std::cin >> v;
        if (v <= min) {
            min = v;
            count++;
        }
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

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

  if (a==b && b==c) {
    cout <<1 <<endl;
  } else if (a!=b && b!=c && a!=c) {
    cout <<3 <<endl;
  } else {
    cout <<2 <<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<limits.h>
#include<utility>
#include<cstdlib>
#define LP(i,n) for(int i=0;i<n;i++)
#define LPIN(n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;
 
int main(){
  int n,m;
  cin >> n >> m;
  int a[n+2] ={};
  for(int i=0;i<m;i++){
int l,r;
cin >> l >> r;
a[l]++;
a[r+1]--;
}
  int ans=0;
  for(int i=1;i<n+1;i++){
    a[i]+=a[i-1];
  }
  for(int i=0;i<n+1;i++){
if(a[i] == m)ans++;
  }
 // LP(i,n+1)cout << a[i]  << " ";
 // cout << endl;
  cout << ans << endl;
return 0;
}

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

int ch[26];
int main() {
	string A; cin >> A;
	for(int i=0; i<A.size(); ++i) ++ch[A[i]-'a'];
	long ans=(long) 1+A.size()*(A.size()-1)/2;
	for(int i=0; i<26; ++i) ans -= (long) ch[i]*(ch[i]-1)/2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10 ** 6)
N = int(input())
G = [[] for i in range(N)]
for i in range(N - 1):
    a, b, c = map(int, input().split())
    G[a - 1].append((b - 1, c))
    G[b - 1].append((a - 1, c))

Q, K = map(int, input().split())
dist = [-1] * N


def dfs(u, par, d):
    dist[u] = d
    for w, cost in G[u]:
        if w == par:
            continue
        dfs(w, u, d + cost)


dfs(K - 1, -1, 0)

for i in range(Q):
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    print(dist[x] + dist[y])

Measured memory_bytes: 131688
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int du[maxn];
std::vector<int> v[maxn];
int vis[maxn];
int value[maxn];
int n;
int m;
int ans=0;
int dfs(int x)
{
    if(vis[x]==1)
    {
        return value[x];
    }else
    {
        int res=0;
        for(int i=0;i<(int)(v[x].size());i++)
        {
            int tt=v[x][i];
            res=max(res,dfs(tt)+1);
        }
        vis[x]=1;
        value[x]=res;
        ans=max(ans,res);
        return res;
    }
}
int main()
{
    scanf("%d %d",&n,&m);
    int x,y;
    repd(i,1,m)
    {
        gg(x);
        gg(y);
        du[y]++;
        v[x].pb(y);
    }
    repd(i,1,n)
    {
        if(du[i]==0)
        {
            dfs(i);
        }
    }
    printf("%d\n",ans );
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 40704
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;
int a[12][12];
const int INF = 1001001001;
int main(){	
	int a;
	cin >> a;
	int ans = a + a*a + a*a*a;
	cout << ans << endl;
	return 0;
}





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

using namespace std;

typedef long long ll;


int N, M, Q, A, B, C, cnt= 0;

int taken[1000005], seq[1000005];
int prefxor[1000005];
vector<int> pref[1000005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> M >> N;
	int xo = 0;
	if (N == 0){
		for (int i = 0; i < (1 << M); ++i){
			cout << i << ' ' << i << ' ';
		}
		cout << '\n';
		return 0;
	}
	for (int i = 0; i < (1 << M); ++i){
		if (i != N) xo ^= i;
	}
	if (xo != N){
		cout << -1 << '\n';
		return 0;
	}
	else{
		for (int i = 0; i < (1 << M); ++i){
			if (i != N) cout << i << ' ';
		}
		cout << N << ' ';
		for (int i = (1 << M)-1; i >= 0; --i){
			if (i != N) cout << i << ' ';
		}
		cout << N << '\n';
	}
}

Measured memory_bytes: 26368
#include <cstdio>
#include<iostream>
using namespace std;
 
int main(){
  int N;
 cin >> N;
  int t = N%10;
  if(t==2 || t==4 || t==5 || t==7 || t==9) printf("hon");
  else if(t==0 || t==1 || t==6 || t==8) printf("pon");
  else if(t==3) printf("bon");
  return 0;
  
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;

constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
class modint{
public:
  long long x;
  constexpr modint(long long x=0):x((x%MOD+MOD)%MOD){}
  constexpr modint operator-() const{return modint(-x);}
  constexpr modint& operator+=(const modint& a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  constexpr modint& operator-=(const modint& a){
    if((x+=MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  constexpr modint& operator*=(const modint& a){
    (x*=a.x)%=MOD;
    return *this;
  }
  constexpr modint operator+(const modint& a) const{return modint(*this)+=a;}
  constexpr modint operator-(const modint& a) const{return modint(*this)-=a;}
  constexpr modint operator*(const modint& a) const{return modint(*this)*=a;}
  constexpr bool operator==(const modint& a) const{return this->x==a.x;}
  constexpr bool operator!=(const modint& a) const{return this->x!=a.x;}
  constexpr modint pow(long long expo) const{
    if(expo==0)  return 1;
    modint a=pow(expo>>1);
    a*=a;
    if(expo&1)  a*=(*this);
    return a;
  }
  //for prime MOD
  constexpr modint inv() const{return pow(MOD-2);}
  constexpr modint& operator/=(const modint& a){return (*this)*=a.inv();}
  constexpr modint operator/(const modint& a) const{return modint(*this)/=a;}
};
istream& operator>>(istream& is,const modint& a){return is >> a.x;}
ostream& operator<<(ostream& os,const modint& a){return os << a.x;}

vector<vector<int>> graph;
vector<bool> visited;

modint dp(vector<vector<modint>> &memo,int V,int pa,int wb){
  if(visited.at(V)) return memo.at(V).at(wb);

  visited.at(V)=true;
  modint tmp0=1;
  modint tmp1=1;
  for(int i=0;i<sz(graph.at(V));i++){
    int nv=graph.at(V).at(i);
    if(nv==pa)  continue;
    tmp0*=(dp(memo,nv,V,0)+dp(memo,nv,V,1));
    tmp1*=dp(memo,nv,V,0);
  }
  memo.at(V).at(0)=tmp0;
  memo.at(V).at(1)=tmp1;
  return memo.at(V).at(wb);
}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  graph.resize(N);
  for(int i=0;i<N-1;i++){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    graph.at(x).pb(y);
    graph.at(y).pb(x);
  }
  visited.resize(N);
  for(int i=0;i<N;i++)  visited.at(i)=false;

  vector<vector<modint>> memo(N,vector<modint>(2,0));
  cout << dp(memo,0,-1,0)+dp(memo,0,-1,1) << endl;
  //for(int i=0;i<N;i++)  cout << i << " " << memo.at(i).at(0) << " " << memo.at(i).at(1) << endl;

  return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    int x, n;
    cin >> x >> n;
    set<int> seti;
    REP(i, n)
    {
        int a;
        cin >> a;
        seti.insert(a);
    }
    int dis = 0;
    int ans;
    while (1) {
        if (seti.find(x - dis) == seti.end()) {
            ans = x - dis;
            break;
        }
        if (seti.find(x + dis) == seti.end()) {
            ans = x + dis;
            break;
        }
        dis++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {

		
	    public static void main(String[] args) throws java.io.IOException{
	        Scanner scan = new Scanner(System.in);
	        while(true){
	        int n=scan.nextInt();
	        if(n==0)break;
	        int [] data = new int[n];
	        for(int i=0;i<n;i++)
	        	data[i]=scan.nextInt();
	        int tar = scan.nextInt();
	        int r=n-1;
	        int l= 0;
	        int count=0;
	        while(true){
	        	count++;
	        	int pos = (r+l)/2;
	        	if(data[pos] == tar || r==l){
	        		break;
	        	}
	        	else if(data[pos]>tar)r=pos-1;
	        	else l=pos+1;
	        	
	        	if(l>r)break;
	        }
	        System.out.println(count);
	        }
	      
	        }
	    }
	    

Measured memory_bytes: 12000
#include<iostream>
#include<cstring>
#define DIM 200005
using namespace std;
int n, i, nr;
long long sol;
char s[DIM];
int main(){
    cin>> s + 1;
    n = strlen(s + 1);
    for(i = 1; i <= n; i++){
        if(s[i] == 'A'){
            nr++;
        }
        else{
            if( (s[i - 1] == 'B' && s[i] == 'C') || (s[i] == 'B' && s[i + 1] == 'C') ){
                if(s[i] == 'C'){
                    sol += nr;
                }
            }
            else{
                nr = 0;
            }
        }
    }
    cout<< sol;
}


Measured memory_bytes: 512
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
func run() {
	n := nextInt()
	k := nextInt()
	s := nextInt()
	a := nextInt()
	
	Println((n-s)* (k-a))
}

// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int s[205000];
int main()
{
	
	int n;
	cin>>n;
	int x;
	for(int i=1;i<n;i++)
	{
		cin>>x;
		s[x]++;	
	}
	for(int i=1;i<=n;i++)
	{
		cout<<s[i]<<endl;
	}
	
	return 0;
} 

Measured memory_bytes: 4376
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	ll res,ans;
	res = 1; ans = 1;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		res *= 3;
		if(x%2==1) ans *= 1;
		else ans *= 2;
	}
	res -= ans;
	cout << res << endl;
	return 0;
}




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

using namespace std;

const int max_n = 303, mod = 998244353;

int n, m;
bitset<max_n> b;
vector<bitset<max_n>> v;

int power(int n) {
    int res = 1;
    for (int i = 0; i < n; ++i) {
        res *= 2;
        res %= mod;
    }
    return res;
}

bool operator < (const bitset<max_n> &a, const bitset<max_n> &b) {
    for (int i = 0; i < m; ++i) {
        if (a[i] != b[i]) {
            return a[i] < b[i];
        }
    }
    return false;
}

void add(bitset<max_n> b) {
    for (int i = 0; i < v.size(); ++i) {
        if ((b ^ v[i]) < b) {
            b ^= v[i];
        }
    }
    if (b == 0) {
        return;
    }
    for (int i = 0; i < v.size(); ++i) {
        if ((b ^ v[i]) < v[i]) {
            v[i] ^= b;
        }
    }
    v.push_back(b);
    //sort(v.begin(), v.end());
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            int x;
            cin >> x;
            b[j] = x;
        }
        add(b);
    }
    int ans = 1LL * power(n - v.size()) * (power(v.size()) - 1) % mod;
    ans = 1LL * ans * power(m - 1) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Task {
    String name;
    int time;
}

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

        int n = sc.nextInt();
        int quantum = sc.nextInt();

        Queue<Task> que = new ArrayDeque<>();

        for (int i = 0; i < n; i++) {
            Task task = new Task();
            task.name = sc.next();
            task.time = sc.nextInt();
            que.offer(task);
        }

        int time = 0;

        while(que.peek() != null) {
            Task task = que.poll();
            if (task.time > quantum) {
                time += quantum;
                task.time -= quantum;
                que.offer(task);
            } else {
                time += task.time;
                String output = String.format("%s %d", task.name, time);
                System.out.println(output);
            }
        }
        
        sc.close();
    }
}



Measured memory_bytes: 97480
#include<iostream>
// Need start
#include<vector>
#include<limits>
// Need end
using namespace std;
typedef long long ll;

// Copy start
template <class T>
class Bellmanford {
    private:
        T inf;
        struct edge {
            T from, to, cost;
        };
        vector<edge> es;
        vector<T> dist;
        vector<T> is_negative;
        T node_num, edge_num;
        bool negative_loop;
    public:
        Bellmanford(T v, T e) {
            inf = numeric_limits<T>::max();  // please set yourself
            node_num = v;
            edge_num = e;
            dist.resize(node_num);
            is_negative.resize(node_num);
            negative_loop = false;
            fill(dist.begin(), dist.end(), inf);
            fill(is_negative.begin(), is_negative.end(), false);
        }
        void add_edge(T from, T to, T cost) {
            edge e = {from, to, cost};
            es.push_back(e);
        }
        void calc_shortest_path(T start) {
            dist[start] = 0;
            for (T i = 0; i < node_num; i++) {
                for (T j = 0; j < edge_num; j++) {
                    edge e = es[j];
                    if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) {
                        dist[e.to] = dist[e.from] + e.cost;
                        if (i == node_num - 1) {
                            negative_loop = true;
                            is_negative[e.to] = true;
                        }
                    }
                    if (is_negative[e.from]) {
                        is_negative[e.to] = true;
                    }
                }
            }
        }
        bool is_negative_loop() {
            return negative_loop;
        }
        bool have_negative_path(T u) {
            // if path from start to u has negative loop, return true
            return is_negative[u];
        }
        T get_dist(T u) {
            return dist[u];
        }
};
// Copy end

int main() {
    // This sample is Atcoder Beginners Contest 61 D
    ll N, M;
    cin >> N >> M;
    ll a, b, c;
    Bellmanford<ll> B(N, M);
    for (int i = 0; i < M; i++) {
        cin >> a >> b >> c;
        a--, b--;
        B.add_edge(a, b, -c);
    }
    B.calc_shortest_path(0);
    ll ans = -B.get_dist(N - 1);
    if (B.is_negative_loop() && B.have_negative_path(N - 1)) {
        cout << "inf" << endl;
    }
    else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>

int a[200], b[200];
int n, m, x, y, ma = -1000, mb = 1000;

int main(){
	scanf("%d%d%d%d", &n, &m, &x, &y);
	x++;
	for(int i = 0; i < n; i++){
		int t;
		scanf("%d", &t);
		if(t > ma)
			ma = t;
	}
	ma++;
	for(int i = 0; i < m; i++){
		int t;
		scanf("%d", &t);
		if(t < mb)
			mb = t;
	}
	
	if(y < ma || x > mb || ma > mb){
		printf("War");
	} else {
		printf("No War");
	}
	
	return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let s: Vec<char> = input::<String>().chars().collect();
    println!(
        "{}",
        if s[0] == s[1] || s[1] == s[2] || s[2] == s[3] {
            "Bad"
        } else {
            "Good"
        }
    );
}


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

using namespace std;

typedef long long ll;

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

int n, x, y;
int a[N], b[N], c[N], d[N];

int dist[N], papa[N];
vector<int> graph[N];

int sp[N];
vector<int> gr[N];
int ans;

void dfs(int v, int p, int d)
{
    papa[v] = p;
    dist[v] = d;
    for (auto u : graph[v]) if (u != p)
    {
        dfs(u, v, d + 1);
    }
}

int dista(int v, int u)
{
    if (v == papa[u]) return 1;
    if (u == papa[v]) return 1;
    if (papa[v] == papa[u]) return 2;
    if (papa[papa[v]] == u) return 2;
    if (papa[papa[u]] == v) return 2;
    return 3;
}

void dfs2(int v, int p, int d)
{
    if (d >= dist[v]) return;
    if (sp[v])
    {
        cout << -1;
        exit(0);
    }
    ans = max(ans, dist[v]);
    for (auto u : gr[v]) if (u != p)
    {
        dfs2(u, v, d + 1);
    }
}

int main()
{
    cin >> n >> x >> y, x--, y--;
    for (int i = 0; i < n - 1; i++) cin >> a[i] >> b[i], a[i]--, b[i]--;
    for (int i = 0; i < n - 1; i++) cin >> c[i] >> d[i], c[i]--, d[i]--;
    for (int i = 0; i < n - 1; i++)
    {
        graph[c[i]].push_back(d[i]);
        graph[d[i]].push_back(c[i]);
    }
    dfs(y, y, 0);
    for (int i = 0; i < n - 1; i++)
    {
        gr[a[i]].push_back(b[i]);
        gr[b[i]].push_back(a[i]);
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (dista(a[i], b[i]) == 3)
        {
            sp[a[i]] = 1;
            sp[b[i]] = 1;
        }
    }
    dfs2(x, x, 0);
    cout << 2 * ans << "\n";
}


Measured memory_bytes: 76624
#include <bits/stdc++.h>
using namespace std;
# define ll  long long int
# define ld  long double
# define pb push_back
# define pp pop_back
# define ff first
# define ss second
# define mp make_pair
# define ac accumulate
# define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve(){
	int n;
	cin >> n;
	ll sum = 0;
	map<ll,ll> mpp;
	for(int i = 0; i < n; i++){
		ll x;
		cin >> x;
		mpp[x]++;
		sum += x;
	}
	int q;
	cin >> q;
	while(q--){
		int a,b;
		cin >> a >> b;
		ll cnt = mpp[a];
		ll diff = b - a;
		mpp.erase(a);
		mpp[b] += cnt;
		sum += cnt*diff;
		cout << sum << "\n";
	}
}

int  main()
{
    #ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
       freopen("output.txt", "w", stdout);
    #endif
     IOS;
     int t = 1;
     //cin >> t;
     while(t--){
     	solve();
     }
     return 0;
    
}

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

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

    for(int i=1; i<n-1; i++){
        if((p[i] > p[i-1] && p[i] < p[i+1]) || (p[i] < p[i-1] && p[i] > p[i+1])){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
lll = [0]*m
for i in range(n):
  k, *aaa = list(map(int, input().split()))
  for a in aaa:
    lll[a-1] += 1
count = 0
for l in lll:
  if l == n:
    count += 1
print(count)

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  cout << (s.size()%2 == 0 ^ s[0] == s.back() ? "Second" : "First") << endl;

  return 0;
}


Measured memory_bytes: 512
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = read().rstrip().decode()
cnt = [[0, 0] for i in range(len(s) + 1)]
ans = 0
for i in range(len(s)):
    if s[i] == '<':
        cnt[i + 1][0] += 1
    else:
        cnt[i][1] += 1
for i in range(1, len(s) + 1):
    if cnt[i - 1][1] == 0:
        cnt[i][0] += cnt[i - 1][0]
    if cnt[len(s) - i + 1][0] == 0:
        cnt[len(s) - i][1] += cnt[len(s) - i + 1][1]
for i in range(len(s) + 1):
    ans += max(cnt[i])
print(ans)


Measured memory_bytes: 70592
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k,i;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    ll sum=0;
    for(i=0;i<n-k;i++)
    sum=sum+a[i];
    cout<<sum;
    
}

Measured memory_bytes: 1024
with Ada.Text_IO;
with Ada.Integer_Text_IO;

use Ada.Text_IO;

procedure abc165a is
 s: Integer;
 w: Integer;
begin
 Ada.Integer_Text_IO.Get(s, 0);
 Ada.Integer_Text_IO.Get(w, 0);
 if s > w then
  Put_Line("safe");
 else
  Put_Line("unsafe");
 end if;
end abc165a;

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    int a[n],b[n],c[n],s[n][3]={0};
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    s[n-1][0]=a[n-1];
    s[n-1][1]=b[n-1];
    s[n-1][2]=c[n-1];
    for(i=n-2;i>=0;i--)
    {
        s[i][0]=max(s[i+1][1],s[i+1][2])+a[i];
        s[i][1]=max(s[i+1][0],s[i+1][2])+b[i];
        s[i][2]=max(s[i+1][1],s[i+1][0])+c[i];
    }
    cout<<max(s[0][0],max(s[0][1],s[0][2]));
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int ans[125][125];

int main(){
  int n;
  cin>>n;
  if(n==2){
    puts("-1");
    return 0;
  }
  REP(i,n-1){
    REP(j,n)ans[i][j] = (j+i+1)%n;
  }
  if(n%2==0){
    int n2 = n/2;
    REP(i,n2){
      if(rand()%2==1){
        swap(ans[n2-1][i],ans[n2][i]);
      }else{
        swap(ans[n2-1][i+n2],ans[n2][i+n2]);
      }
    }
  }
  REP(j,n){
    REP(i,n-1){
      printf("%d",ans[i][j]+1);
      if(i<n-2)putchar(' ');
      else puts("");
    }
  }
  return 0;
}


Measured memory_bytes: 384
H, W = [int(x) for x in input().split()]
a = [[None for _ in range(W)]] + \
    [[None] + [int(x) for x in input().split()] for _ in range(H)]


N = 0
y_from = [0]
y_to = [0]
x_from = [0]
x_to = [0]
for i in range(1, H):
    for j in range(1, W + 1):
        if a[i][j] % 2 == 0: continue
        N += 1
        a[i][j] -= 1
        y_from.append(i)
        x_from.append(j)

        a[i + 1][j] += 1
        y_to.append(i + 1)
        x_to.append(j)

for j in range(1, W):
    if a[H][j] % 2 == 0: continue
    N += 1
    a[H][j] -= 1
    y_from.append(H)
    x_from.append(j)

    a[H][j + 1] += 1
    y_to.append(H)
    x_to.append(j + 1)

print(N)
for i in range(1, N + 1):
    print(y_from[i], x_from[i], y_to[i], x_to[i])


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int n, d, x;
    cin >> n >> d >> x;

    int ans = x;
    rep(i, n){
        int a;
        cin >> a;

        ans += (d + a - 1) / a;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]

# エントリーポイント
def main():
    S = input(str)
    T = input(str)

    count = 0
    for a, b in zip(list(S), list(T)):
        if a == b:
            count += 1
    print(count)

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3456
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, const char *argv[]) {
  int N;
  long int comp;

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

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

  comp = A[0];
  for (int i = 1; i < N; i++) {
    if(A[i] ==  comp){
      cout << "NO" << endl;
      return 0;
    }
    comp = A[i];
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main (void){

int W,H,x,y,r;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

if(0<=x-r && 0<=y-r && x+r<=W && y+r<=H){

printf("Yes\n");

}

else{

printf("No\n");

}

return 0;

} 

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	ll x;
	cin >> N >> x;
	vector<ll> a(N * 2);
	vector<ll> list(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> a[i];
		a[i + N] = a[i];
		list[i] = a[i];
	}

	auto ans = LLONG_MAX;
	for (auto i = 0; i < N; ++i)
	{
		for (auto j = 0; j < N; ++j)
		{
			auto next = j - i + N;
			list[j] = min(list[j], a[next]);
		}
		auto sum = 0ll;
		for (auto j = 0; j < N; ++j)
		{
			sum += list[j];
		}
		sum += x * i;
		ans = min(ans, sum);
	}

	cout << ans << endl;

	return 0;
}

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

int main(void)
{
  int N, x, c=0;
  cin >> N >> x;
  priority_queue<int, vector<int>, greater<int> > q;
  for (int j = 0; j < N; ++j) {
    int a;
    cin >> a;
    q.push(a);
  }
  while(!q.empty()) {
    x -= q.top();q.pop();
    if (x >= 0) {
      c+=1;
    } else {
      break;
    }
  }
  if (x > 0) c -= 1;
  cout << c << endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S; cin >> S;
    string T; cin >> T;
    int size_S = S.length();
    int ans = 0;

    for(int i = 0; i < size_S; i++){
        char tmp_S = S[i];
        char tmp_T = T[i];
        if(tmp_S != tmp_T) ans ++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d)
        cout<<"Left"<<endl;
    else if(a+b==c+d)
        cout<<"Balanced"<<endl;
    else
        cout<<"Right"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int ans = 0;
	rep(i, 3) {
		if (s.at(i) == '1')ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
a = list(map(int,input().split()))
A = a[0]
B = a[1]
C = a[2]
X = a[3]
Y = a[4]
if A + B <= 2*C:
    print(str(A*X + B*Y))
else:
    if X <= Y:
        #2X枚のABピザを作る。残りY-X枚のBピザが必要
        if B <= 2*C:
            print(str(2*X*C + (Y-X)*B))
        else:
            print(str(2*Y*C))
    else:
        if A <= 2*C:
            print(str(2*Y*C + (X-Y)*A))
        else:
            print(str(2*X*C))

Measured memory_bytes: 3064
Imports System

Module Program
    Sub Main(args As String())

        Dim S As String = Console.ReadLine()
        Dim T As String = Console.ReadLine()

        Dim ans As Integer = Len(S)

        For i As Integer = 1 To Len(S) - Len(T) + 1
            Dim kaisu As Integer = 0
            For j As Integer = 1 To Len(T)
                If Mid(S, i + j - 1, 1) <> Mid(T, j, 1) Then
                    kaisu += 1
                End If
            Next
            If ans > kaisu Then
                ans = kaisu
            End If
        Next

        Console.WriteLine(ans)

    End Sub
End Module


Measured memory_bytes: 38196
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    print((1000 - N % 1000) % 1000)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10152
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mes(a,b) memset((a),(b),sizeof((a)))
#define syio std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
#define lson l, mid, rt << 1
#define rson mid+1, r, rt << 1 | 1
typedef long long ll;
typedef long double real;
typedef pair<int, int> pii;

const int oo = ~0u >> 2;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mxn = 100033;
inline int read(){
    int x = 0,f = 1;char c = getchar();
    while(!isdigit(c))f = c == '-' ? -1 : 1,c = getchar();
    while(isdigit(c))x = x * 10 + c - '0',c = getchar();
    return x * f;
}
int main()
{
    syio;
    string s;
    cin>>s;
    int res = 0;
    for (int i = 0; i < s.size(); ++ i)
    res += s[i] - '0';
    if (res % 9 == 0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main() {
  int A, B, Ans=0;
  string S;
  cin >> A >> B >> S;
  rep(i, A){
    if(S.at(i)<'0' || '9'<S.at(i)){
      Ans=1;
      break;
    }
  }
  if(S.at(A)!='-') Ans=1;
  rep(j, B)
    if(S.at(j+A+1)<'0' || '9'<S.at(j+A+1)){
      Ans=1;
      break;
    }
  if (Ans==1) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int[] B = new int[M];

        for (int i = 0; i < M; i++) {
            B[i]= sc.nextInt();
        }

        int count =0;
        for (int i = 0; i < N; i++) {
            int sum = 0;
            for (int j = 0; j < M; j++) {
                int a= sc.nextInt();
                sum += a * B[j];

            }
            if(sum+C > 0){
                count++;
            }

        }

        System.out.println(count);

    }

}


Measured memory_bytes: 24020
n, k = map(int, input().split())
a = list(map(int, input().split()))
asum = [0 for _ in range(n+1)]
psum = [0 for _ in range(n+1)]
for i in range(n):
    asum[i+1] = asum[i] + a[i]
    psum[i+1] = psum[i] + max(0, a[i])
ans = 0
for i in range(n-k+1):
    ans = max(ans, psum[i]-psum[0]+asum[i+k]-asum[i]+psum[n]-psum[i+k])
    ans = max(ans, psum[i]-psum[0]+psum[n]-psum[i+k])
print(ans)

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

int main(){

    long int N;
    cin >> N;

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

    sort(A, A+N);

    // for (int i=0; i<N; i++) {
    //     cout << A[i] << " ";
    // }
    // cout << endl;

    long int ans1 = 0;
    long int ans2 = 0;

    if (N%2 == 0) {
        for (int i=0; i<(N/2)-1; i++) {
            ans1 -= 2*A[i];
        }
        ans1 -= A[(N/2)-1];
        ans1 += A[N/2];
        for (int i=(N/2)+1; i<N; i++) {
            ans1 += 2*A[i];
        }
        cout << ans1 << endl;
    } else {
        // ans1
        for (int i=0; i<(N-1)/2-1; i++) {
            ans1 -= 2*A[i];
        }
        ans1 -= A[(N-1)/2-1];
        ans1 -= A[(N-1)/2];
        for (int i=(N-1)/2+1; i<N; i++) {
            ans1 += 2*A[i];
        }
        // ans2
        for (int i=0; i<(N-1)/2; i++) {
            ans2 -= 2*A[i];
        }
        ans2 += A[(N-1)/2];
        ans2 += A[(N-1)/2+1];
        for (int i=(N-1)/2+2; i<N; i++) {
            ans2 += 2*A[i];
        }
        if (ans1 > ans2) {
            cout << ans1 << endl;
        } else {
            cout << ans2 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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








int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    vector<pair<ll, ll>> v(n);
    REP(i, n){
        cin >> a[i] >> b[i];
        v[i] = {a[i] + b[i], i};
    }
    sort(v.begin(), v.end(), greater<pair<ll, ll>>());
    ll ans = 0;
    REP(i, n){
        if(i % 2 == 0){
            ans += a[v[i].second];
        }
        else{
            ans -= b[v[i].second];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}

	max := 0
	c := 0
	for i := 1; i < n; i++ {
		if h[i] <= h[i - 1] {
			c++
		} else {
			c = 0
		}
		if c > max {
			max = c
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
   long long m,n;
   cin>>m>>n;
   vector<long long> v(n);
   for(int i=0;i<n;i++)
   {
      cin>>v[i];
   }

   int sum=0;
   for(auto x:v)
   {
   	 sum+=x;
   }

   
   if(sum>m)
   {
   	 cout<<-1;
   }
   else
   {
   	 cout<<m-sum<<" ";
   }

}
main()
{
int t;
t=1;
while(t--)
{
solve();

}
}

Measured memory_bytes: 3676
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>







const int N=1e5+10;
ll n,a[N];



ll f(ll s)
{
	ll ret=0;
	for(int i=2;i<=n;i++)
	{
		if(s>0)
		{
			s+=a[i];
			if(s>=0)
			{
				ret+=s+1;
				s=-1;
			}
		}
		else
		{
			s+=a[i];
			if(s<=0)
			{
				ret+=1-s;
				s=1;
			}
		}
	}
	return ret;
}






void solve()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	if(a[1]>0)
	{
		cout<<min(f(a[1]),f(-1)+a[1]+1)<<"\n";
	}
	else if(a[1]<0)
	{
		cout<<min(f(a[1]),f(1)-a[1]+1)<<"\n";
	}
	else
	{
		cout<<min(f(1)+1,f(-1)+1)<<"\n";
	}
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main()
{
	char S[11];
	scanf("%s", &S);
	
	int i, j, l, min = 1000, tmp;
	for (l = 0; S[l] != 0; l++);
	for (i = 0; i < l - 2; i++) {
		tmp = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + S[i+2] - '0';
		if (abs(tmp - 753) < min) min = abs(tmp - 753);
	}
	
	printf("%d\n", min);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	string x;
	cin >> x;
	int count = 0;
	for (int i = 0 ; i < x.size() - 1 ; i++)
	{
		if (x[i] == x[i + 1])
		{
			count++;
		}
	}
	if (count > 0)
	{
		cout << "Bad";
		return 0;
	}
	cout << "Good";
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, = map(int, input().split())
S = list(input().strip())

ans = 0
for i in range(1, N):
    x = set(S[0:i])
    y = set(S[i:])
    
    ans = max(ans, len(x & y))
    
print(ans)

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

int main(){
  int kind[101];
  int n;
  cin >> n;
  for(int i = 0; i < 102; i++){
    kind[i] = 0;
  }
  int order = 0;
  for(int i = 0; i < n; i++){
    int temp;
    cin >> temp;
    if(temp > 0){
      order++;
      if(kind[temp] == 0){
      kind[temp] = order;
      }else{
        cout << i+1 << endl;
        return 0;
      }
    }
    if(temp < 0){
      if(kind[temp*-1] == order&&order != 0){
        kind[temp*-1] = 0;
      }else{
        cout << i+1 << endl;
        return 0;
      }
      order--;
    }
  }
  cout << "OK" << endl;
}



Measured memory_bytes: 3092
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
const long double PI = acos(-1);
const long long INF = 1e15;
const ll DEP = (1LL << 50);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
template<class T> bool chmax(T& a,T b){ if(a < b) {a = b; return true;} return false;}
template<class T> bool chmin(T& a,T b){ if(a > b) {a = b; return true;} return false;}
template<typename T>
T GCD(T x,T y){
    return y ? GCD(y,x%y) : x;
}
template<typename T>
string toString( const T &a ){
    ostringstream oss;
    oss << a;
    return oss.str();
};


/* 
void toporogical_sort(){
    for(int i = 0; i < v; i++){
        if(!In[i].size()) Q.push(i);
    }
    while(!Q.empty()){
        int t = Q.front(); 
        Q.pop();
        ans.push_back(t);
        for(int i = 0; i < Out[t].size(); i++){
            int nx = Out[t][i];
            int size = In[nx].size();
            for(int j = 0; j < size; j++){
                if(In[nx][j] == t){
                    In[nx].erase(In[nx].begin()+j);
                    break;
                }
            }
            if(!In[nx].size()) Q.push(nx);
        }
    }
}
*/

int N; 
int main(){
    while(true){
        cin >> N;
        if(N == 0) break;
        int a, mn = MM,mx = 0,ans = 0;
        for(int i = 0; i < N; i++){
            cin >> a;
            mn = min(mn,a);
            mx = max(mx,a);
            ans += a;
        }
        ans -= (mn+mx);
        ans /= (N-2);
        //cout << "ans=";
        cout << ans << endl;
    }
}


Measured memory_bytes: 2992
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] data = br.readLine().split(" ");
    double a = Integer.parseInt(data[0]);
    double b = Integer.parseInt(data[1]);
    double h = Integer.parseInt(data[2]);
    double x = h/a/a;
    
    double result;
    if (x >= b/2.0){
      double bMinus = 2*(b-x);
      result = 90 - Math.atan(a/bMinus) * 180.0 / Math.PI;
    } else {
      double aDash = 2*a*x/b;
      result = Math.atan(b/aDash) * 180.0 / Math.PI;
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 21204
s='#';n,*a=open(0).readlines();n=int(n);f,e=[sum(i==t.count(s)for t in zip(*a))for i in(n,0)];r=range(n);print(-(e>n)or min(n*2-f-a[i].count(s)+all(s<a[j][i]for j in r)for i in r))

Measured memory_bytes: 3316
N = int(raw_input())
A = map(int, raw_input().split())

def bubbleSort(A, N):
    count = 0
    flag = 1
    while flag:
        flag = 0
        for i in range(N-1, 0, -1):
            if A[i] < A[i-1]:
                temp = A[i]
                A[i] = A[i-1]
                A[i-1] = temp
                flag = 1
                count += 1
    return count

count = bubbleSort(A, N)

print " ".join(map(str, A))
print count

Measured memory_bytes: 6380
def main():
    N = int(input())
    S = input()
    ans = {}
    for s in range(ord('a'),ord('z')+1):
        ans[chr(s)] = 0
    for s in S:
        if not ans[s]:
            ans[s] = 1
        else:
            ans[s] += 1
    res = 1
    for _, v in ans.items():
        res *= v+1
    return res - 1


if __name__ == '__main__':
    print(main() % (10**9+7))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define M 998244353
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<double,ll> pll;
#define pb push_back
#define M6 5000009
#define M5 500009
#define pi 3.14159265
ll power(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=(res*x)%M;
        n/=2;
        x=(x*x)%M;
    }
    return res;
}
ll prime[M6];
void sieve(){
    for(int i=2;i<M6;i++) prime[i]=1;
    for(int i=2;i*i<M6;i++){
        if(prime[i]==0) continue;
        for(int j=i*2;j<M6;j+=i) prime[j]=0;
    }
}
ll n,m,A[M5];
vector<ll> v[M5];
int  main()
{   ios_base::sync_with_stdio (0), cin.tie (0);
    //sieve();
    //init();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll tc=1,t=0,i,j,k,l,a,b,c,d;
    //cin>>tc;
    while(t++<tc){
        cin>>n>>m;
        for(i=1;i<=n;i++){
            cin>>a>>b;
            if(a<=m){
                v[a].pb(b);
            }
        }
        ll ans=0;
        priority_queue<ll> pq;
        for(i=1;i<=m;i++){
            for(auto u:v[i]) pq.push(u);
            if(!pq.empty()){
                ans+=pq.top();
                pq.pop();
            }
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 17664