akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_GN = 20;

/* typedef */

typedef deque<string> dqst;

enum { ASC_L, ASC_R };

/* global variables */

int gn;
int chgrp[256], ascs[MAX_GN];

/* subroutines */

string expr(string& str, int& pos, int pv) {
  if (pv >= gn) {
    if (str[pos] == '(') {
      pos++;
      string res = expr(str, pos, 0);
      pos++;
      return res;
    }

    return string(1, str[pos++]);
  }

  dqst q;
  q.push_back(expr(str, pos, pv + 1));

  while (chgrp[str[pos]] == pv) {
    //if (str[pos] == '/')
    //printf("pos=%d, str[pos]=%c, pv=%d\n", pos, str[pos], pv);
    q.push_back(string(1, str[pos++]));
    q.push_back(expr(str, pos, pv + 1));
  }

  string exp0;
  if (ascs[pv] == ASC_L) {
    exp0 = q.front(); q.pop_front();

    while (! q.empty()) {
      string op = q.front(); q.pop_front();
      string exp1 = q.front(); q.pop_front();
      exp0 = "(" + exp0 + op + exp1 + ")";
    }
  }
  else {
    exp0 = q.back(); q.pop_back();

    while (! q.empty()) {
      string op = q.back(); q.pop_back();
      string exp1 = q.back(); q.pop_back();
      exp0 = "(" + exp1 + op + exp0 + ")";
    }
  }

  return exp0;
}

/* main */

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

  for (bool first = true; tn--; first = false) {
    if (! first) cout << endl;

    memset(chgrp, -1, sizeof(chgrp));

    cin >> gn;
    for (int i = 0; i < gn; i++) {
      char lr;
      int m;
      cin >> lr >> m;
      ascs[i] = (lr == 'L') ? ASC_L : ASC_R;

      for (int j = 0; j < m; j++) {
	char op;
	cin >> op;
	chgrp[op] = i;
      }
    }

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
      string str;
      cin >> str;

      int pos = 0;
      cout << expr(str, pos, 0) << endl;
    }
  }

  return 0;
}

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

using namespace std;

int H;

void maxHeapify(int A[], int i) {
	int l = i * 2;
	int r = l + 1;
	int largest;

	if (l <= H && A[l] > A[i]) {
		largest = l;
	}
	else {
		largest = i;
	}
	if (r <= H && A[r] > A[largest]) {
		largest = r;
	}

	if (largest != i) {
		swap(A[i], A[largest]);
		maxHeapify(A, largest);
	}
}

void buildMaxHeap(int A[]) {
	for (int i = H / 2; i >= 1; i--) {
		maxHeapify(A, i);
	}
}

int main() {
	cin >> H;
	int heap[H + 1];

	for (int i = 1; i <= H; i++) {
		cin >> heap[i];
	}
	buildMaxHeap(heap);
	for (int i = 1; i <= H; i++) {
		cout << " " << heap[i];
	}
	cout << endl;

	return 0; 
}

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

int main(void){
	int n;
	while(cin >> n, n){
		int s[2000];
		double average = 0;
		for(int i=0; i<n; i++){
			cin >> s[i];
			average += s[i];
		}
		average /= n;
		double sigma = 0;
		for(int i=0; i<n; i++){
			sigma += (s[i] - average)*(s[i] - average);
		}
		sigma /= n;
		sigma = sqrt(sigma);

		printf("%.8f\n", sigma);
	}
	

	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
  int h,w,i,j;
  string s;
  cin >> h >> w;
  for (i=0;i<h;i++){
    for (j=0;j<w;j++){
      cin >> s;
      if (s=="snuke") break;
    }
    if (j!=w) break;
  }
  cout << (char)('A'+j) << i+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define mod 1000000007
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int dp[M];
int main()
{
	memset(dp, 0, sizeof(dp) );
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int tmp;
		cin >> tmp;
		dp[tmp] = -1;
	}
	dp[0] = 1;
	for(int i = 1; i <= n; i++) {
		if(dp[i] == -1) continue;
		if(i-1 >= 0 && dp[i-1] != -1) dp[i] = (dp[i]+dp[i-1]) % mod;
		if(i-2 >= 0 && dp[i-2] != -1) dp[i] = (dp[i]+dp[i-2]) % mod;
	}
	cout << dp[n] << endl;
	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

const int MAXN = 1e5+10;
const int MAXL = 2*sqrt(MAXN)+10;
const int L = 18;

int n, q;
vector<pair<int,int>> adj[MAXN]; // < v, index of edge >
int a[MAXN], b[MAXN], c[MAXN], d[MAXN];

int depth[MAXN], be[MAXN], en[MAXN];
vector<int> edges;
vector<int> vert;
int vbe[MAXN], ven[MAXN];
int ans[MAXN];

int ql[MAXN], qr[MAXN], qc[MAXN], qd[MAXN];
bool comp(int i, int j) {
  return (ql[i]/MAXL < ql[j]/MAXL || (ql[i]/MAXL == ql[j]/MAXL && qr[i] < qr[j]));
}

void dfs(int u, int p=-1) {
  be[u] = edges.size();
  for(auto pp: adj[u]) {
    int v = pp.first;
    int id = pp.second;
    if (v==p) continue;
    depth[v] = depth[u]+1;
    edges.push_back(id);
    dfs(v,u);
    edges.push_back(id);
  }
  en[u] = edges.size()-1;
}

bool eset[MAXN];
ll ccnt[MAXN];
ll cold[MAXN];//sum of lengths for each c
ll totd;

void add(int i) {
  i = edges[i]; //d[i] and c[i]
  //cerr << "adding " << i << " " << c[i] << endl;
  int m = eset[i]? -1:1;
  totd+=m*d[i];
  cold[c[i]]+=m*d[i];
  ccnt[c[i]]+=m;
  eset[i]^=1;
}

int main(){
  cin.tie(0); ios_base::sync_with_stdio(0);
  cin >> n >> q;
  for(int i=0;i<n-1;i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    adj[a[i]].emplace_back(b[i],i);
    adj[b[i]].emplace_back(a[i],i);
  }
  dfs(1);
  //cerr << "EDGES " << endl; for(int i:edges) cerr << i << " "; cerr <<endl;
  //cerr << "be " << endl; for(int i=1;i<=n;i++) cerr << be[i] << " "; cerr <<endl;
  vector<int> qs;
  for(int i=0;i<q;i++) {
    cin >> qc[i] >> qd[i] >> ql[i] >> qr[i];
    ql[i] = be[ql[i]];
    qr[i] = be[qr[i]];
    qs.push_back(i);
  }
  sort(qs.begin(),qs.end(),comp);
  int l = 0, r = 0; // inclusive exclusive
  for(int q: qs) {
    int tl = ql[q];
    int tr = qr[q];
    int tc = qc[q];
    int td = qd[q];
    //cerr << "QUERY" << tl << " " << tr << " " << tc << " " << td << endl;
    while(l>tl) add(--l);
    while(l<tl) add(l++);
    while(r>tr) add(--r);
    while(r<tr) add(r++);
    //cerr << totd << " " << cold[tc] << " " << ccnt[tc] <<endl;
    //cerr << totd-cold[tc]+ccnt[tc]*td <<endl;
    ans[q] = totd-cold[tc]+ccnt[tc]*td;
  }
  for(int i=0;i<q;i++) cout << ans[i] <<endl;
}


Measured memory_bytes: 20852
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        #[allow(unused_mut)]
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: [[usize; 3];3],
        n: usize,
        b: [usize; n]
    }
    let mut t = vec![vec![false; 3]; 3];
    for i in 0..3 {
        for j in 0..3 {
            if b.contains(&a[i][j]) {
                t[i][j] = true;
            }
        }
    }

    let mut ans = false;
    for i in 0..3 {
        ans |= t[i][0] && t[i][1] && t[i][2];
        ans |= t[0][i] && t[1][i] && t[2][i];
    }
    ans |= t[0][0] && t[1][1] && t[2][2];
    ans |= t[0][2] && t[1][1] && t[2][0];
    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int N = 1e7 + 1;
int main()
{
	boost;
	int k, i;
	cin >> k;
	if(k & 1) {
		int curr = 0;
		foe(i, 1, N) {
			curr = (curr * 10 + 1) % k;
			int x = (curr * 7) % k;
			if(x == 0) {
				cout << i;
				return 0;
			}
		}
		cout << -1;
	}
	else cout << -1;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    cout << (M1 != M2 ? 1 : 0) << endl;
    return 0;
}


Measured memory_bytes: 256
/**
*    created: 31.05.2020 21:35:11
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    map<int, int> div;
    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }

    if (n % 2 == 0){
        while (n % 2 == 0){
            div[2]++;
            n /= 2;
        }
    }
    for (int i = 3; i*i <= n; i += 2){
        while (n % i == 0){
            div[i]++;
            n /= i;
        }
    }
    if (n != 1) div[n]++;
    
    auto f = [&](int n) {
        int k = 1;
        while(true) {
            if (k*(k+1)/2 > n) return k-1;
            k++;
        }
    };
    
    int cnt = 0;
    for (auto p : div) {
        int i = p.second;
        cnt += f(p.second);        
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define sorted(vector) sort(vector.begin(),vector.end())
#define vmax(vector) *max_element(vector.begin(),vector.end())
#define vsum(vector) accumulate(vector.begin(),vector.end(),0)
#define append(a) push_back(a)
#define int(a) stoi(a)
#define str(a) to_string(a)


int main(void){
    int n,k,tmp;
    vector<int> v,motimono,ans;
    cin>>n>>k;
    for(int i=0  ;i<n  ;i++){
        cin>>tmp;
        v.push_back(tmp);
    }
    
    
    if (k>=n){
        k-=n;
        ans.append(vsum(v));
        sorted(v);
        for(int i=0  ;i< min<unsigned long>(k,n) ;i++){
            v[i]=0;
            ans.append(vsum(v));
            }
    }else{
        for(int i=0  ;i<n  ;i++){
            v.append(v[i]);
        }
        for(int j=1  ;j<k+1  ;j++){  //長さ
            for(int i=n-j  ;i<n+1  ;i++){ //開始index
                vector<int> motimono;
                for(int r=i  ;r<i+j  ;r++){
                    motimono.append(v[r]);
                }
                ans.append(vsum(motimono));
                sorted(motimono);
                for(int i=0  ;i< min<unsigned long>(k-j,motimono.size())  ;i++){
                    motimono[i]=0;
                    ans.append(vsum(motimono));
                }
            }
        }
    }
    cout<<vmax(ans)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100005
#define MOD 1000000007

typedef long long int lli;

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

  int l[MAX], r[MAX];
  rep(i, 0, Q) scanf("%d %d", &l[i], &r[i]);

  int np[MAX] = {0};
  int n[MAX] = {0};
  np[1] = 1;
  for ( lli i = 2; i <= 100000; i++ ) {
    if ( np[i] ) continue;
    for ( lli j = i * i; j <= 100000; j += i ) 
      np[j] = 1;
    if ( np[(i+1)/2] == 0 ) n[i] = 1;
  }

  
  int sum[MAX];
  sum[1] = 0;
  for ( int i = 1; i <= 100000; i++ ) {
    sum[i + 1] = sum[i] + n[i];
  }

  rep(i, 0, Q) {
    printf("%d\n", sum[r[i]+1] - sum[l[i]]);
  }
  return 0;
}


Measured memory_bytes: 2560
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    L = [ii() for _ in range(m)]

    FIBO = [0] * (n+1)    # FIBO[i] = k 段目から k+i 段目に行く場合の数
    for i in range(n+1):
        if i == 0 or i == 1:
            FIBO[i] = 1
        else:
            FIBO[i] = (FIBO[i-1] + FIBO[i-2]) % mod

    prev = 0
    ans = 1
    for broken_step in L:
        if prev == broken_step:
            print(0)
            exit()
        ans = (ans * FIBO[broken_step - 1 - prev]) % mod
        prev = broken_step + 1
    ans = (ans * FIBO[n - prev]) % mod
    print(ans)





if __name__ == "__main__":
    main()

Measured memory_bytes: 11048
K = int(input())

nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
        1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(nums[K - 1])


Measured memory_bytes: 2940
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL L, T;
LL X[100011];
char W[100011];
LL B[100011];
LL ans[100011];

LL f(LL x, LL y) {
    return x / L + (x % L > y? 1: 0);
}

void MAIN() {
    scanf("%d%lld%lld", &N, &L, &T);
    REP (i, N) {
	scanf("%lld%s", X+i, W+i);
    }

    bool flip = (W[0] == '2');
    if (flip) {
	REP (i, N) {
	    W[i] = (W[i] == '1'? '2': '1');
	    X[i] = L-1-X[i];
	}
	reverse(W+1, W+N);
	reverse(X+1, X+N);
    }

    LL cross = 0;
    REP (i, N) if (W[i] == '2') {
	LL x = X[0], y = X[i];
	cross += f(x+2*T, y) - f(x, y);
    }

    REP (i, N) {
	if (W[i] == '1') {
	    B[i] = (X[i] + T) %L;
	} else {
	    B[i] = (X[i] - T) %L;
	    if (B[i] < 0) B[i] += L;
	}
    }
    sort(B, B+N);
    REP (i, N) if (B[i] == (X[0]+T)%L) {
	REP (j, N) {
	    ans[(cross+j)%N] = B[(i+j)%N];
	}
	break;
    }

    if (flip) {
	REP (i, N) {
	    ans[i] = L-1-ans[i];
	}
	reverse(ans+1, ans+N);
    }
    REP (i, N) printf("%lld\n", ans[i]);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000001145
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans=1;
int k,n;

vector<int> factor;
void div(int n){
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			factor.push_back(i);
			factor.push_back(n/i);
		}
	}
}

signed main(){
	cin>>n>>k;
	div(k);
	for(auto x:factor){
		if(k%x==0 && n*x<=k){
			ans=max(ans,x);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int n,m,c;
    cin>>n>>m>>c;
    vector<int> b(m);
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    int cnt=0;
    for(int i=0;i<n;i++){
        int sum=c;
        for(int j=0;j<m;j++){
            sum+=a[i][j]*b[j];
        }
        if(sum>0) cnt++;
    }
    cout<<cnt<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<climits>
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
using namespace std;

class Set{
    vector<int> parent;
    public:

    Set(int n)
    {
        for(int i = 0;i<n;i++)
        {
            parent.push_back(i);
        }
    }

    int getSuperParent(int x)
    {
        if(x==parent[x])
        {
            return x;
        }
        return parent[x] = getSuperParent(parent[x]);
    }

    void join(int a, int b)
    {
        a = getSuperParent(a);
        b = getSuperParent(b);
        if(a!=b)
        {
            parent[b] = a;
        }
    }

    void ifConnected(int a, int b)
    {
        a = getSuperParent(a);
        b = getSuperParent(b);
        if(a==b)
        {
            cout<<1<<endl;
        }
        else{
            cout<<0<<endl;
        }
    }
};


int main()
{
    int n,k;
    cin>>n>>k;
    Set s(n);

    int op,a,b;
    for(int i = 0;i<k;i++)
    {
        cin>>op>>a>>b;
        if(!op)
        {
            s.join(a,b);
        }
        else{
            s.ifConnected(a,b);
        }
    }
    return 0;
}


Measured memory_bytes: 3804
N = gets.to_i
ps = gets.split.map(&:to_i)
#N = 20000
#ps = (1..20000).to_a.shuffle
rev = []
N.times do |i|
    rev[ps[i]-1] = i
end

as, bs = [1], [10**9]
(N-1).times do |i|
    diff = rev[i+1] - rev[i]
    if diff > 0
        as[i+1] = as[i] + diff + 1
        bs[i+1] = bs[i] - 1
    else
        as[i+1] = as[i] + 1
        bs[i+1] = bs[i] + diff - 1
    end
end
puts as.join(' ')
puts bs.join(' ')

#(N-1).times do |i|
#    if as[ps[i]-1] + bs[ps[i]-1] >= as[ps[i+1]-1] + bs[ps[i+1]-1]
#        puts 'WA'
#        exit
#    end
#end

Measured memory_bytes: 5244
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
using namespace std;
int main() {
  int x,y;cin>>x>>y;
  int answer=GCD(x,y);
  cout<<answer<<endl;
}
   


Measured memory_bytes: 3092
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

using namespace std;
using ll=long long;

void solve(){
  int num;
  cin >> num;
  string s=to_string(num);
  int res=0;
  for(int i=0;i<s.size();i++)
    res+=s[i]-'0';

  cout << (num%res?"No":"Yes") << endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){

	int n, sum = 0;
	
	scanf("%d", &n);
	
	int a[n], b[n];
	
	for (int i = 0; i < n; i++){
		scanf("%d%d", &a[i], &b[i]);
		sum += abs(b[i]-a[i])+1;
	}
	printf("%d\n", sum);

	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
#define N 3005
#define mo 1000000007
using namespace std;
int f[N][2*N][2],n,m;
int main()
{
	cin>>n>>m;
	f[0][0][1]=1;
	fo(i,1,n) f[0][i][0]=1;
	int ans=0;
	fo(i,1,m)
	{
		fo(j,0,n)
		{
			fo(p,0,1)
			{
				if(j) (f[i][j-1][p|(j==1)]+=f[i-1][j][p])%=mo,(f[i][j][p|(j==1)]+=f[i-1][j][p])%=mo;
				if(j<n) (f[i][j+1][p]+=f[i-1][j][p])%=mo,(f[i][j][p|(j==0)]+=f[i-1][j][p])%=mo;
			}
		}
	}
	fo(i,0,n) (ans+=f[m][i][1])%=mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 139648
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define int long long

using ll = long long;
const ll mod = LLONG_MAX;

int n,ans;
int d[310][310],a[310][310];

signed main(){
  cin>>n;
  rep(i,n)rep(j,n){
    cin>>d[i][j];
    a[i][j]=d[i][j];
  }
  rep(k,n)rep(i,n)rep(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  bool f=true;
  rep(i,n)rep(j,n)if(d[i][j]!=a[i][j])f=false;

  if(f==false){
    cout<<-1<<endl;
    return 0;
  }

  rep(i,n){
    for(int j=i+1;j<n;j++){
      bool flag=true;
      rep(k,n){
        if(a[i][j]==a[i][k]+a[k][j]&&k!=i&&k!=j)flag=false;
      }
      if(flag)ans+=a[i][j];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1664
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
  int a, b; cin >> a >> b;
  int num = 1, cnt = 0;
  while(num < b){
      num += a - 1;
      cnt++;
  }
  cout << cnt << ln;
}



Measured memory_bytes: 3568
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

x = I()

ans = 0
ans += (x // 500) * 1000
x = x - (x // 500) * 500
ans += (x // 5) * 5
print(ans)

Measured memory_bytes: 63852
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n;
	cin >> n;
	vector<pair<pair<pair<pair<int,int>,char>,LL>,string>> p(n);
	rep(i, n) {
		int v, w;
		char t;
		LL d;
		string s;
		cin >> v >> w >> t >> d >> s;
		p[i] = mp(mp(mp(mp(v, w), t), d), s);
	}
	SORT(p);
	rep(i, n) {
		cout << p[i].first.first.first.first << " " << p[i].first.first.first.second << " " << p[i].first.first.second << " " << p[i].first.second << " " << p[i].second << endl;
	}
}


Measured memory_bytes: 12196
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, a: [usize; n]);

    const A_SIZE: usize = 1_000_002;
    let mut do_continue = true;
    let mut ans = "pairwise coprime";
    let mut aaa: Vec<usize> = vec![0usize; A_SIZE];
    for v in &a {
        aaa[*v] += 1;
    }

    for i in 2..A_SIZE {
        let mut count = 0;
        for j in (0..A_SIZE).skip(i).step_by(i) {
            count += aaa[j];
        }
        if count > 1 {
            do_continue = false;
            ans = "not coprime";
            break;
        }
    }

    if !do_continue {
        let mut c = a[0];
        for i in 1..n {
            c = num::integer::gcd(c, a[i]);
        }
        if c == 1 {
            ans = "setwise coprime";
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 24484
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
    ll n, d;
    cin >> n >> d;
    ll cnt = 0;
    for (ll i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= d*d) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3632
N,L=(int(i) for i in input().split())
x=0
y=[]
z=[]
zy=[]
for i in range(1,N+1):

    x+=i+L-1
    y.append(i+L-1)
    z.append(i+L-1)


for i in y:

    z.remove(i)

    zy.append(sum(z))


    z.append(i)

sa=x-zy[0]



for i in zy:
    if((x-i)<abs(sa)):
        sa=x-i
num=zy.index(x-sa)
print(zy[num])


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <climits>
#include <set>
#include <deque>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {

	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";

    return out;

}

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {

	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}

		out << "\n";
	}
		
    return out;

}

int main() {

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	string t;
	for (int i = 0; i < s.size(); ++i) {
		t.push_back((((s[i] - 'A') + n) % 26) + 'A');
	}

	cout << t << "\n";

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define read_input         freopen("in.txt","r", stdin)
#define print_output       freopen("out.txt","w", stdout)
typedef long long ll;
typedef long double ld;
using namespace std;

ll a[200005], n;

ll f(ll b) {
    ll sum = 0;
    for(ll i = 0; i < n; i++) sum += abs(a[i] - i - 1 - b);
    return sum;
}

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

    ll lo = -1e9-7, hi = 1e9+7;
    while(lo <= hi) {
        ll mid = lo + hi >> 1;
        if(f(mid) >= f(mid+1)) lo = mid+1;
        else hi = mid-1;
    }
    //cout << lo << endl;
    ll ans = f(lo);
    cout << ans << endl;
    
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int A[N];
  for(int k=0;k<N;k++){
    cin >> A[k];
  }

  int count=0;
  int flag=1;
  while(flag){
    flag = 0;
    for(int j=N-1;j>0;j--){
      if(A[j]<A[j-1]){
        int tmp = A[j];
        A[j] = A[j-1];
        A[j-1] = tmp;
        flag = 1;
        count++;
      }
    }
  }

  for(int k=0;k<N-1;k++){
    cout << A[k] << " ";
  }
  cout << A[N-1] << endl;
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 1164
// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    "9 12" => "21",
    "19 0" => "19",
    "23 2" => "1",
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: u8,
        b: u8,
    }
    
    ((a + b) % 24).to_string()
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;

using namespace std;
int MOD = 1000000007;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  vector<int> p(n,0);
  REP(i,n) {
    cin >> p[i];
  }
  sort(p.begin(),p.end());
  int sum = 0;
  REP(i,k) {
    sum += p[i];
  }
  cout << sum << endl;
  return 0;
}



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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

//https://www.youtube.com/watch?v=L8grWxBlIZ4&t=9858
//https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
int mod = MODA;
struct modint {
    ll x;
    modint (ll x):x(x%mod){}
    modint& operator+=(const modint a){
        (x += a.x ) %= mod;
        return *this;
    }
    modint& operator-=(const modint a){
        (x -= a.x ) %= mod;
        if (x < 0) x += mod;
        return *this;
    }
    modint& operator*=(const modint a){
        (x *= a.x ) %= mod;
        return *this;
    }
    modint operator+(const modint a) const{
        modint res(*this);
        return res+=a;
    }
    modint operator-(const modint a) const{
        modint res(*this);
        return res-=a;
    }
    modint operator*(const modint a) const{
        modint res(*this);
        return res*=a;
    }
};
modint modpow(modint x, ll n){
    modint res=1;
    while(n > 0){
        if(n & 1) res = res * x.x;
        x = x * x;
        n >>= 1;
    }
    return res;
}

ll memo[60][2][2][2];
ll L, R;

ll f(int pos,int fx, int fy, int fz){
    //cout << pos << " " << fx << " " << fy << " " << fz << endl;
    //cout << (ll)(1 << pos) << endl;
    if(pos == -1) return 1;
    if(memo[pos][fx][fy][fz]!=-1) return memo[pos][fx][fy][fz];
    ll ret = 0;
    ll hoge = (ll)1 << (ll)pos;
    //x 0, y 0
    if(fx == 1 || !(L & hoge)){
        //cout << pos << " " << fx << " " << fy << " " << fz << endl;
        if(R & hoge) ret += f(pos - 1, fx, 1, fz);
        else ret += f(pos - 1, fx, fy, fz);
    }
    //x0,y1
    if((fx == 1 || !(L & hoge))&&(fy == 1 || (R & hoge))&&fz==1){
        //cout << pos << " " << fx << " " << fy << " " << fz << endl;
        ret += f(pos - 1, fx, fy, fz);
    }
    //x1,y1
    if(fy == 1 || (R & hoge)){
        //cout << pos << " " << fx << " " << fy << " " << fz << endl;
        if(!(L & hoge))ret += f(pos - 1, 1, fy, 1);
        else ret += f(pos - 1, fx, fy, 1);
    }
    ret %= mod;
    memo[pos][fx][fy][fz] = ret;
    return ret;
}

int main() {
    ll ans;
    REP(i,60)REP(j,2)REP(k,2)REP(l,2) memo[i][j][k][l] = -1;
    
    //cout << memo[0][0][0][0];
    cin >> L >> R;
    ans = f(59,0,0,0);
    cout << ans << endl;
}

Measured memory_bytes: 256
def kaijou(n, r, mo):
    c = 1
    for i in range(r+1, n+1):
        c *= i
        c %= mo
    return c

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def invmod(a, m):
    g, x, y = xgcd(a, m)
    return x % m

def kaijou_inv(ans, n, mo):
    for i in range(1,n+1):
        ans *= invmod(i, mo)
        ans %= mo
    return ans


x, y = map(int, input().split())
mo = 10**9 + 7
if (x+y) % 3 != 0:
    print(0)
else:
    a = (2*x-y) // 3
    b = (2*y-x) // 3
    if a<0 or b<0:
        print(0)
    else:
        te = kaijou(a+b, max(a, b), mo)
        tem = kaijou_inv(te, min(a,b), mo)
        print(tem)

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


int main() {
    int N;
    cin >> N;
    vector<int> a(N+1);//1始まり
    rep(i,N) cin >> a[i+1];

    vector<int> ball(N+1);//1始まり

    for (int i = N; i > 0; --i) {
        ll sum = 0;
        for (int j = 2; i * j <= N; ++j) sum += ball.at(i * j);
        ball.at(i) = (sum % 2 ^ a.at(i)); 
    }
    cout << count(ball.begin(), ball.end(), 1) << endl;
    rep(i,N) if (ball[i+1]) cout << i + 1 << " ";
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    int h,w;
    cin >> h >> w;
    
    char a[w][h];
    rep(i,h){
        rep(j,w){
            cin >> a[j][i];
        }
    }

    rep(i,w+2)    cout << '#';
    cout << endl;

    rep(i,h){
        rep(j,w+2){
            if(j==0||j==w+1)    cout << "#";
            else    cout << a[j-1][i];
        }
        cout << endl;
    }

    rep(i,w+2)    cout << '#';
    cout << endl;

    return 0;
}

Measured memory_bytes: 3640
from collections import Counter


def main():
    N, K, Q = map(int, input().split())

    winners = [int(input()) for _ in range(Q)]

    count = Counter(winners)

    k_sub_q = K - Q
    for i in range(1, N + 1):
        if k_sub_q + count.get(i, 0) > 0:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 11904
#include<stdio.h>

void sort(int p[],int n);

void sort(int p[],int n)
{
    int i,j,temp;

    for (i = 0; i < n - 1; i++) {
        for (j = n - 1; j > i; j--) {
            if (p[j-1] > p[j]) {
                temp = p[j];
                p[j] = p[j-1];
                p[j-1] = temp;
            }
        }	
    }
}

int main(void)
{
	int i;
	int j;
	int k;
	int n;
	int d[20];
	int p[100];
	int sum;
	int ave;
	
	j=0;
	while(1){


		scanf("%d",&n);
		if(n==0) 
			break;
			
		for(i=0;i<n;i++){
		scanf("%d",&p[i]);
		}

		sort(p,n);	
	
		sum = 0;
		for(i=1;i<n-1;i++){
			sum += p[i];
		}
			
			d[j] = sum / (n-2);
			j++;

	}
	
	for(k=0;k<j;k++)
		printf("%d\n",d[k]);

	return 0;
}

Measured memory_bytes: 1028
def way8(ball, box):
    """ball: True / box: False / constraints: 1 or less
    -> ans = int(ボールの数 <= 箱の数)
    """
    return int(ball <= box)


n, k = map(int, input().split())
MOD = 10 ** 9 + 7

print(way8(n, k))


Measured memory_bytes: 5612
#include <stdio.h>
int main()
{
  int r,x,y,x2;

  scanf("%d%d",&x,&y);
 
  if(x < y){
    x2 = x;
    x = y;
    y = x2; }

  while(y > 0){
    r = x % y;
    x = y;
    y = r; }

  printf("%d\n",x);

  return 0;
}


Measured memory_bytes: 2080
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	int a[3][3];
	rep(i, 3) rep(j, 3) cin >> a[i][j];
	int n; cin >> n;
	rep(i, n){
		int b; cin >> b;
		rep(i, 3) rep(j, 3) if(a[i][j] == b) a[i][j] = -1;
	}

	rep(i, 3){
		bool bingo = true;
		rep(j, 3){
			if(a[i][j] != -1) bingo = false;
		}
		if(bingo){
			cout << "Yes" << endl;
			return 0;
		}
	}
	rep(i, 3){
		bool bingo = true;
		rep(j, 3){
			if(a[j][i] != -1) bingo = false;
		}
		if(bingo){
			cout << "Yes" << endl;
			return 0;
		}
	}
	if(a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1){
		cout << "Yes" << endl;
		return 0;
	}
	if(a[2][0] == -1 && a[1][1] == -1 && a[0][2] == -1){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
class Factorial:
    def __init__(self,n,mod):
        self.f=[1]
        self.mod=mod
        for i in range(1,n+1):
            self.f.append(self.f[-1]*i%mod)
        self.i=[pow(self.f[-1],mod-2,mod)]
        for i in range(1,n+1)[::-1]:
            self.i.append(self.i[-1]*i%mod)
        self.i.reverse()
    def factorial(self,i):
        return self.f[i]
    def ifactorial(self,i):
        return self.i[i]
    def comb(self,n,k):
        return self.f[n]*self.i[n-k]%self.mod*self.i[k]%self.mod if n>=k else 0
from collections import*
M=10**9+7
n,*a=map(int,open(0).read().split())
v,_=Counter(a).most_common(1)[0]
l=-1
for i,b in enumerate(a):
  if b==v:
    if l<0:l=i
    else:r=n-i
c=Factorial(n+1,M).comb
for k in range(n+1):print((c(n+1,k+1)-c(l+r,k))%M)

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


int main(){
    int w,h,n;
    cin >> w >> h >> n;
    int kaku[w][h] =  {1};
    int x[n],y[n],a[n];
    int xmax = 0,xmin = w,ymax = 0,ymin = h;
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> a[i];
    }
    for(int i = 0; i < n; i++){
        if(a[i] == 1){
            xmax = max(xmax,x[i]);
        }else if(a[i] == 2){
            xmin = min(xmin,x[i]);
        }else if(a[i] == 3){
            ymax = max(ymax,y[i]);
        }else if(a[i] == 4){
            ymin = min(ymin,y[i]);
        }
        // cout << xmin << xmax << ymin << ymax << endl;
    }
    if(xmin < xmax || ymin < ymax){
        cout << 0 << endl;
    }else{
        cout << (xmin - xmax)*(ymin - ymax) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<ll,ll>
#define vi vector<ll>
#define vpi vector< pi >
#define ff first
#define ss second
const int N=100010;
int a[N],b[N],c[N],bit[2*N];
ll n;
void upd(int x)
{
	x+=N;
	while(x<2*N)
	{
		bit[x]+=1;
		x+=(x&-x);
	}
}
ll query(int x)
{
	x+=N;
	ll res=0;
	while(x)
	{
		res+=bit[x];
		x-=(x&-x);
	}
	return res;
}
ll hh(int x)
{
	memset(bit,0,sizeof bit);
	c[0]=0;
	ll res=0;upd(0);
	for(int i=1;i<=n;i++)
	{
		if(a[i]<=x)
			c[i]=-1;
		else c[i]=1;
		c[i]+=c[i-1];
		upd(c[i]);
		res+=query(n)-query(c[i]);
	}
	return res;
}
int main()
{
	
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	ll m=n*(n+1)/2/2 +1,l=1,r=n;
	while(l<r)
	{
		int mid=(l+r)/2;
		if(hh(b[mid])<m) l=mid+1;
		else r=mid;
	}
	cout<<b[r];
	
	return 0;
}

Measured memory_bytes: 2176
N = int(input())
A =  input()
B =  input()
C =  input()

str_len = len(A)

count = 0


for i in range(str_len):
    #print(f'i: {i}')
    if A[i]==B[i]:
        if C[i]==B[i]:
            continue
        else:
            count = count + 1
    elif A[i]==C[i]:
        count = count + 1
    elif B[i]==C[i]:
        count = count + 1
    else:
        count = count + 2
print(str(count))

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(true){
				int n = sc.nextInt(), s = sc.nextInt();
				if(n == 0 && s == 0) break;
				System.out.println(dfs(0, 0, s, n));
			}
		}
	}
	public static int dfs(int total, int addv, int target, int n){
		if(n == 0) return total == target ? 1 : 0;
		else if(total > target || addv > 9) return 0;
		else return dfs(total + addv, addv + 1, target, n - 1) + dfs(total, addv + 1, target, n);
	}
}

Measured memory_bytes: 25976