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

using namespace std;

typedef long long ll;

int main() {
    int K;
    ll sum = 0;

    scanf("%d", &K);
    for (int a = 1; a <= K; a++)
        for (int b = 1; b <= K; b++)
            for (int c = 1; c <= K; c++)
                sum += __gcd(__gcd(a, b), c);

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

    return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

using llint = long long int;

using state = std::array<llint, 3>;

std::vector<state> walk_all(const std::vector<std::vector<char> > &S,
			    const state &now,
			    std::vector<std::vector<int> > &step){
  std::priority_queue<state> tmp;
  std::vector<state> ret;
  tmp.push(now);
  while(!tmp.empty()){
    state now_ = tmp.top();
    tmp.pop();
    ret.push_back(now_);
    
    for(int x=-1; x<=1; x+=2){
      for(int y=1; y<=2; y++){
	state next = {now_[0], now_[1], now_[2]};
	next[y] += x;
	if(next[1]<0) continue;
	if(next[2]<0) continue;
	if(next[1]>=S.size()) continue;
	if(next[2]>=S[0].size()) continue;
	if(S[next[1]][next[2]] == '#') continue;
	if(step[next[1]][next[2]] != -1 && step[next[1]][next[2]] <= -next[0] ) continue;
	
	step[next[1]][next[2]] = -next[0];
	tmp.push(next);
      }
      
    }
  }

  return ret;
}
std::vector<state> warp_all(const std::vector<std::vector<char> > &S,
			    const std::vector<state> & walked,
			    std::vector<std::vector<int> > &step){
  std::vector<state> ret;
  
  for(const auto& now: walked){
    for(int x=-2; x<=2; x+=1){
      for(int y=-2; y<=2; y+=1){
	state next = {now[0]-1, now[1]+x, now[2]+y};
	if(next[1]<0) continue;
	if(next[2]<0) continue;
	if(next[1]>=S.size()) continue;
	if(next[2]>=S[0].size()) continue;
	if(S[next[1]][next[2]] == '#') continue;
	if(step[next[1]][next[2]] != -1 && step[next[1]][next[2]] <= -next[0] ) continue;
	
	step[next[1]][next[2]] = -next[0];
	ret.push_back(next);
      }
    }
  }

  return ret;
}

void solve(void){

  int h, w, ch, cw, dh, dw;
  std::cin >> h >> w >> ch >> cw >> dh >> dw;

  std::vector<std::vector<char> > S(h+2, std::vector<char>(w+2, '#'));
  std::vector<std::vector<int>  > step(h+2, std::vector<int>(w+2, -1));

  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      std::cin >> S[i][j];
    }
  }

  std::priority_queue<state> pq;
  pq.push({-0, ch, cw});
  step[ch][cw] = 0;
  bool update = false;
  int checked_cnt = 0;
  while(!pq.empty()){
    //std::cout << ++checked_cnt << std::endl;
    auto now = pq.top();
    pq.pop();
    //std::cout << now[0] << " " << now[1] << " " << now[2] << std::endl;
    std::vector<state> walked_list = walk_all(S, now, step);
    std::vector<state> warped_list = warp_all(S, walked_list, step);
    for(const auto& elem: warped_list){
      pq.push(elem);
    }
  }
  //for(int i=0; i<step.size(); i++){
  //  for(int j=0; j<step[0].size(); j++){
  //    std::cout << step[i][j] << " ";
  //  }
  //  std::cout << std::endl;
  //}

  std::cout << step[dh][dw] << std::endl;

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





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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi t(n+1), x(n+1), y(n+1);
	t[0] = 0; x[0] = 0; y[0] = 0;
	REP(i, n)cin >> t[i+1] >> x[i+1] >> y[i+1];
	int f = 1;
	REP(i, n) {
		int dt = t[i + 1] - t[i], d = abs(x[i] - x[i + 1]) + abs(y[i] - y[i + 1]);
		if (dt % 2 != d % 2||d>dt)f = 0;
	}
	if (f)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <cmath>

typedef long long ll;

using namespace std;
ll mod = 1000000007;
int n, m;

bool cmp(const pair<ll,ll>& l, const pair<ll,ll>& r) {
    if (l.second != r.second) {
        return l.second > r.second;
    } else {
        return l.first > r.first;
    }
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll ans = 0;
    cin >> n >> m;
    vector<ll> A(n+1);
    vector<pair<ll,ll>> B(m);
    for (int i = 1; i <= n; i++) {
        cin >> A[i];
        ans += A[i];
    }
    sort(A.begin(), A.end());
    for (int i = 0; i < m; i++) {
        cin >> B[i].first >> B[i].second;
    }
    sort(B.begin(), B.end(), cmp);
    int l = 1;
    for (int i = 0; i < m; i++){
        int cnt = 0;
        for (int j = l; (j <= n)&&(cnt < B[i].first); j++){
            if (A[j] < B[i].second) {
                ans += B[i].second - A[j];
                l++;
                B[i].first--;
            } else {
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll X[2];
    ll Y[2];
    cin >> X[0] >> X[1] >> Y[0] >> Y[1];

    ll ans = -2e18;
    rep(i,2) {
        rep(j,2) {
            ll tmp = X[i]*Y[j];
            ans = max(tmp,ans);
        }
    } 
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
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;}
const long long INF = 1LL << 60;
typedef pair<int, int> P;
/*
int main() {
    int N;
    cin >> N;
    printf("%10lf", (N-N/2)/(double)N);


}*/
int N, K;
int h[100000];

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> h[i];
    int count = 0;
    for (int i = 0; i < N; i++) {
        if (h[i] >= K) count++;
    }
    cout << count << "\n"; 
}

/*
座標圧縮の例
int compress(int *x1, int *x2, int w) {
    vector<int> xs;

    for (int i = 0; i < N; i++ {
        for (int d = -1; d <= 1; d++) {
            int tx1 = x1[i] + d; tx2 = x2[i] + d;
            if (1 <= tx1 && tx1 <= W) xs.push_back(tx1);
            if (1 <= tx2 && tx2 <= H) xs.push_back(tx2);
        }
    }
    sort(xs.begin());
    xs.erase(unique(xs.begin(), xs.end(), x1[i]) - xs.begin());

    for (int i = 0; i < N; i++) {
        x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
        x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
    }

    return xs.size();
}

*/


/*
組み合わせ計算アルゴリズム
v[i][j]がiCjを意味する
std::vector<std::vector<long long>> comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]) % R;
    }
  }
  return v;
}
*/

/*
行列べき乗  mat A(m,vec(n)); からAに何かしら代入して A = pow(A,n);

typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A, mat &B) {
    mat C(A.size(), vec(B[0].size()));
    for (int i = 0; i < A.size(); i++) {
        for (int k = 0; k < B.size(); k++) {
            for (int j = 0; j < B[0].size(); j++) {
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % M;
            }
        }
    }
    return C;
}

mat pow(mat A, ll n) {
    mat B(A.size(), vec(A.size()));
    for (int i = 0; i < A.size(); i++) {
        B[i][i] = 1;
    }
    while (n > 0) {
        if (n & 1) B = mul(B,A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

//ctoi関数　stringを扱いたくてバグが酷い時にどうぞ
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}
*/

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second

ll n,cnt=0,ans=0;

int main(){
    cin >> n;
    vector<ll> v;//最初にsizeを宣言していたが、初期値書いてないと勝手に０でしまわれるため注意
    
    for(ll i=0;i < n;i++)
    {
        int x;
        cin >> x;
        v.push_back(abs(x));
        if(x < 0){
            cnt++;
        }
    }

    if(cnt%2==0){
        for(int i=0;i < v.size();i++)
        {
            ans+=v.at(i);
        }
    }else{
        sort(v.begin(),v.end());
        for(int i=1;i < v.size();i++)
        {
            ans+=v.at(i);
        }
        ans-=v.at(0);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1528
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

ll n = 0LL;
ll ans = 0LL;
string s[] = {"7", "5", "3"};
string k = "";
int x3, x5, x7;

void dfs(){
  if(k.size()==9) return;
  if(x3 && x5) if(n >= stoi(k+s[0]))ans++;
  if(x3 && x7) if(n >= stoi(k+s[1]))ans++;
  if(x7 && x5) if(n >= stoi(k+s[2]))ans++;
  k += s[0];
  x7++;
  dfs();
  k = k.substr(0, k.size()-1) + s[1];
  x7--; x5++;
  dfs();
  k = k.substr(0, k.size()-1) + s[2];
  x5--; x3++;
  dfs();
  x3--;
  k = k.substr(0, k.size()-1);
}

int
main(void){  
  ios_base::sync_with_stdio(false);

  cin >> n;

  dfs();
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
int main()
{
  int N, input;
  vector<int> A;
  bool exist_odds;
  int counter = 0;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> input;
    A.push_back(input);
  }

  while(true){
    exist_odds = false;
    for (auto it = A.begin(); it != A.end(); ++it) {
      if(*it%2 == 0) {*it/=2;}
      else {exist_odds = true;}
    }
    if(exist_odds) break;
    else counter ++;
  }

  cout << counter << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int w, a, b;
  cin >> w >> a >> b;
  if (a < b) {
    int x = b - (w + a);
    if (x < 0) {
      x = 0;
    }
    cout << x << endl;
  } else {
    int x = a - (w + b);
    if (x < 0) {
      x = 0;
    }
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 3160
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int k = sc.nextInt();
		Long[] a = new Long[x];
		Long[] b = new Long[y];
		Long[] c = new Long[z];
		for(int i = 0; i < x; i++){
		    a[i] = sc.nextLong();
		}
		for(int i = 0; i < y; i++){
		    b[i] = sc.nextLong();
		}
		for(int i = 0; i < z; i++){
		    c[i] = sc.nextLong();
		}
		
		// 計算
		Arrays.sort(a, Comparator.reverseOrder());
		Arrays.sort(b, Comparator.reverseOrder());
		Arrays.sort(c, Comparator.reverseOrder());
		PriorityQueue<Long[]> pq = new PriorityQueue<Long[]>((s, t) -> Long.compare(t[0], s[0]));
		HashSet<String> hs = new HashSet<String>();
		Long[] cakes = new Long[4];
		cakes[0] = a[0] + b[0] + c[0];
		cakes[1] = 0L;
		cakes[2] = 0L;
		cakes[3] = 0L;
		pq.add(cakes);
		hs.add(Arrays.toString(cakes));
		for(int i = 0; i < k; i++){
		    Long[] now = pq.poll();
		    System.out.println(now[0]);
		    if(now[1] < x - 1){
		        Long[] cakesA = new Long[4];
		        cakesA[0] = a[now[1].intValue() + 1] + b[now[2].intValue()] + c[now[3].intValue()];
		        cakesA[1] = now[1] + 1;
		        cakesA[2] = now[2];
		        cakesA[3] = now[3];
		        //System.out.println("A:" + Arrays.toString(cakesA));
		        if(!hs.contains(Arrays.toString(cakesA))) {pq.add(cakesA); hs.add(Arrays.toString(cakesA));}
		    }
		    if(now[2] < y - 1){
		        Long[] cakesB = new Long[4];
		        cakesB[0] = a[now[1].intValue()] + b[now[2].intValue() + 1] + c[now[3].intValue()];
		        cakesB[1] = now[1];
		        cakesB[2] = now[2] + 1;
		        cakesB[3] = now[3];
		        //System.out.println("B:" + Arrays.toString(cakesB));
		        if(!hs.contains(Arrays.toString(cakesB))) {pq.add(cakesB); hs.add(Arrays.toString(cakesB));}
		    }
		    if(now[3] < z - 1){
		        Long[] cakesC = new Long[4];
		        cakesC[0] = a[now[1].intValue()] + b[now[2].intValue()] + c[now[3].intValue() + 1];
		        cakesC[1] = now[1];
		        cakesC[2] = now[2];
		        cakesC[3] = now[3] + 1;
		        //System.out.println("C:" + Arrays.toString(cakesC));
		        if(!hs.contains(Arrays.toString(cakesC))) {pq.add(cakesC); hs.add(Arrays.toString(cakesC));}
		    }
		    
		}
		
		// 出力
		//System.out.println(result);
        
	}
}


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

using namespace std;

#define MAX_N 114
#define MAX_V 514

int V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v] = true;
  for(int i = 0 ; i < (int)G[v].size() ; i++){
    int u = G[v][i],w = match[u];
    if(w < 0 || !used[w] && dfs(w)){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res = 0;
  memset(match,-1,sizeof(match));
  for(int v = 0 ; v < V ; v++){
    if(match[v] < 0){
      memset(used,false,sizeof(used));
      if(dfs(v)){ res++; }
    }
  }
  return res;
}

int main(){
  int N,h[MAX_N],w[MAX_N];
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    cin >> w[i] >> h[i];
  }
  V = N*2;
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < N ; j++){
      if(i == j){ continue; }
      if((h[i] < h[j] && w[i] < w[j]) || (h[i] < w[j] && w[i] < h[j])){
        add_edge(i,j+N);
      }
    }
  }
  cout << N-bipartite_matching() << endl;
  return 0;
}


Measured memory_bytes: 1276
#include<iostream>
using namespace std;
int main(void) {
  int a;
  cin>>a;
  int b;
  b=a-a/100*100;
  int c;
  c=a/100*10+a/100;
  int d;
  d=a/100;
  if (b>c){cout<<(d+1)*100+(d+1)*10+(d+1)<<"\n";}
  else{cout<<d*100+d*10+d<<"\n";}
  return 0;
  }


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main{
	public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		String str = in.nextLine();
		int sum = 0;
		for(int i=0;i<str.length();i++){
			sum += str.charAt(i) - '0';
		}
		if(sum%9 == 0)
			out.println("Yes");
		else
			out.println("No");
	}
}


Measured memory_bytes: 41148
n, m = map(int, input().split())
A = [[] for i in range(n)]
b = []
for i in range(n):
    *Ai, = map(int, input().split())
    A[i] = Ai
for j in range(m):
    b.append(int(input()))
for i in range(n):
    print(sum([A[i][j]*b[j] for j in range(m)]))



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

using namespace std;

int main() {
  string str;
  getline(cin, str);

  int ans = 0;
  string::size_type index = 0;
  while ((index = str.find("O", index)) != string::npos) {
    int len = 1;
    int first_idx = index;
    while (str[++index] == 'O') { len++; }
    bool flag = true;
    for (int i = 0; i < len; i++) {
      if (first_idx > 0) {
        if (str[--first_idx] != 'J') {
          flag = false;
          break;
        }
      } else flag = false;
    }
    if (!flag) continue;
    for (int i = 0; i < len; i++) {
      if (index < str.length()) {
        if (str[index++] != 'I') {
          flag = false;
          break;
        }
      } else flag = false;
    }
    if (!flag) continue;
    ans = max(ans, len);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1984
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;

struct edge
{
    int v,w,nxt;
}e[400050];

int head[100050],ecnt;

void adde(int u,int v,int w)
{
    e[++ecnt].v = v;
    e[ecnt].w = w;
    e[ecnt].nxt = head[u];
    head[u] = ecnt;
}

int N,M;
int l[200050],r[200050];
int d[200050];
long long dist[100005];
queue<int> que;
bool vis[100050],inq[100050];

bool spfa(int st)
{
    que.push(st);
    inq[st] = true;
    dist[st] = 0;
    while(!que.empty())
    {
        int u = que.front();
        que.pop();
        for(int i = head[u];i;i = e[i].nxt)
        {
            int v = e[i].v;
            if(dist[v] == 12345678987654321)
            {
                dist[v] = dist[u] + e[i].w;
                vis[v] = 1;
                if(!inq[v])
                    que.push(v);
            }
            else if(dist[v] != dist[u] + e[i].w)
                return false;
        }
        inq[u] = false;
    }
    return true;
}

int main()
{
    for(int i = 1;i <= 100000; ++ i)
        dist[i] = 12345678987654321;
    scanf("%d%d",&N,&M);
    for(int i = 1;i <= M; ++ i)
    {
        scanf("%d%d%d",&l[i],&r[i],&d[i]);
        adde(l[i],r[i],d[i]);
        adde(r[i],l[i],-d[i]);
    }
    for(int i = 1;i <= N; ++ i)
    {
        if(!vis[i])
        {
            vis[i] = 1;bool l = spfa(i);
            if(!l)
            {
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

LLi SM(vector<LLi> smv) {
	LLi tmp=0;
	rep(i, (int)smv.size()) tmp+=smv[i];

	return tmp;
}

int main(){

	LLi n, wid, k=1, ans=0;
	vector<LLi> a, v;

	cin>> n;
	a.resize(n+1);
	v.resize(n+1);

	rep(i, n+1) cin >> a[i];

	if(n==0){
		if(a[0]==1)	cout<< "1" <<endl;
		else cout<< "-1" <<endl;
		return 0;
	}

	if(a[0]!=0){
		cout<< "-1" <<endl;
		return 0;
	}

	wid=SM(a);
	//cout<< wid <<endl;

	v[0]=1;

	for(int i=0;i<n;i++){
		/*if(v[i-1]*2<a[i]){
			cout<< "-1" <<endl;
			return 0;
		}*/

		wid-=a[i];

		v[i+1]=2*(v[i]-a[i]);

		if(v[i+1]<a[i+1]){
			cout<< "-1" <<endl;
			return 0;
		}

		if(v[i+1]>=wid){
			v[i+1]=wid;
			i++;
			while(i<n){
				v[i+1]=v[i]-a[i];
				i++;
			}
			break;
		}
	}

	//PVL(a);
	//PVL(v);
	cout<< SM(v) <<endl;
 
	return 0;
}

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

ll curr_cost(vector<ll>&slimes, ll i, ll j)
{
	ll sum = 0;
	for (ll k = i; k <= j; k++)
	{
		sum += slimes[k];
	}
	return sum;
}
ll min_cost(vector<ll>&slimes, ll i, ll j, vector<vector<ll>>&dp)
{
	if (i >= j)
	{
		return 0;
	}
	if (dp[i][j] != -1)
	{
		return dp[i][j];
	}
	ll ans = LLONG_MAX;
	ll cost = curr_cost(slimes, i, j);
	for (ll k = i; k < j; k++)
	{
		ll temp_ans = min_cost(slimes, i, k, dp) + min_cost(slimes, k + 1, j, dp) + cost ;
		ans = min(ans, temp_ans);
	}
	return dp[i][j] = ans;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	vector<ll>slimes(n);
	for (ll i = 0; i < n; i++)
	{
		ll d;
		cin >> d;
		slimes[i] = d;
	}
	vector<vector<ll>>dp(n + 1, vector<ll>(n + 1, -1));
	ll ans = min_cost(slimes, 0, n - 1, dp);
	cout << ans << endl;
	return 0;

}

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

int main(){
    int pasta[3];
    int juice[2];
    int min = 1000000;
    cin >> pasta[0] >> pasta[1] >> pasta[2] >> juice[0] >> juice[1];

    for(int i=0; i<3; ++i){
        for(int j=0; j<2; ++j){
            int sum = pasta[i] + juice[j] - 50;
            if(min > sum) min = sum;
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[i];
  sort(a,a+n);
  ll ans=0;
  int o=n;
  o-=2;
  int u=n-1;
  ans+=a[u];
  u--;
  while(o>0){
    if(o==1){
      ans+=a[u];
      o--;
    }
    else{
      o-=2;
      ans+=(2*a[u]);
      u--;
    }
  }
  cout << ans << endl;
}


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

int main(){
  int n, m, sum = 0;
  int t[101] = {0}, p[101] = {0}, x[101] = {0};
  cin >> n;
  for ( int i = 1; i <= n; i++ ){
    cin >> t[i];
    sum += t[i];
  }
  
  cin >> m;
  for ( int i = 0; i < m; i++ ){
    cin >> p[i] >> x[i];
  }
  
  for( int i = 0; i < m; i++ ){
    cout << sum - t[ p[i] ] + x[i] << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    int N=s.size();

    REP(S,1<<(N-1)){
        int sum=s[0]-'0';
        string ans; ans+=s[0];
        REP(i,N-1){
            if(S>>i&1){
                sum+=s[i+1]-'0';
                ans=ans+'+'+s[i+1];
            }
            else{
                sum-=s[i+1]-'0';
                ans=ans+'-'+s[i+1];
            }
        }
        if(sum==7){
            ans+="=7";
            cout<<ans<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
    int t,a[999],i,j=0,k,l,o,p=0,m=0;
    cin>>t;
    for(i=0;i<t;i++)
        cin>>a[i];
    sort(a,a+t);
    for(i=t-1;i>=0;i--)
    {
        if(j%2==0)
            p+=a[i];
        else
            m+=a[i];
        j++;

    }
    cout<<p-m<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    int n,x=0;
    cin >> n >> s;
    
    if(n%2 != 0){
        cout<< "No" <<endl;
    }
    
    else{
        for(int i = 0; i < n/2; i++){
                if(s[i]==s[i+n/2]){
                        x++;
                }
        }
        if(x==n/2){
                cout<< "Yes" <<endl;
        }
        else{
                cout<< "No" <<endl;
        }
    }
    
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter pr = new PrintWriter(System.out);
		while(true){
		int n = sc.nextInt();
		int m = sc.nextInt();
		int a = sc.nextInt();
		if(n==0&&m==0&&a==0) break;
		int [][] map = new int[1001][n+2];
		while(m-->0){
			int h = sc.nextInt();
			map[h][Math.min(sc.nextInt(), sc.nextInt())] = 1;
		}
		int h = 1000;
		while(h-->0){
			if(map[h][a]==1){
				a++;
			}else if(map[h][a-1]==1){
				a--;
			}
		}
		pr.println(a);
		}
		pr.flush();
		sc.close();
	}
}

Measured memory_bytes: 72452
N, K = gets.split.map(&:to_i)
P_LIST = gets.split.map(&:to_i)
kitaichi = P_LIST.map do |x|
  (x + 1).to_f / 2
end
max = sum = kitaichi[0..(K-1)].inject(0){|a,b| a + b }

K.upto(N-1) do |x|
  sum += kitaichi[x]
  sum -= kitaichi[x-K]
  if sum > max
    max = sum
  end
end

puts max

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

using ll = long long;
const ll MOD = 998244353;

int main() {
    int N, ans = 0;
    string S;
    cin >> N >> S;
    rep(i, N - 2) if (S.substr(i, 3) == "ABC") ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
        static void SolveA()
        {
            var xy = ReadAndParseIntArr();
            int x = xy[0];
            int y = xy[1];
            int ans = x + y / 2;
            Console.WriteLine(ans);
        }
        
        
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
n = int(input())

m = {}
for i in range(n):
  s, p = input().split()
  p = int(p)
  if s not in m:
    m[s] = []
  
  m[s].append((p, i+1))

shops = sorted(m.items(), key=lambda x : x[0])

for x in shops:
  city, scores = x[0], sorted(x[1], reverse=True, key=lambda x : x[0])
  for score in scores:
    print(score[1])

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 100;
int n;
int w[MAX_N];

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n;
  forn(i,n) cin >> w[i];

  int res = INT_MAX;
  for (int c = 1; c <= n-1; c++) {
    chmin(res,abs(accumulate(w,w+c,0)-accumulate(w+c,w+n,0)));
  }

  cout << res << endl;


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<algorithm>

using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> PP;
int n;
string str;
int dp[15][10001];
//stage/division
int fie[15][10001];
int p_divs[15][10001];
int p_divl[15][10001];
int p_div[15][10001];
int stdiv[15];
vector<int> vec[15][10001];
int memo(int st,int div){
	if(dp[st][div]!=-1)return dp[st][div];
	int siz=0;
	if(fie[st][div]==0){
		for(int i=p_divs[st][div];i<=p_divl[st][div];i++){
			vec[st][div].push_back(memo(st+1,i));
			siz++;
		}
	}else return dp[st][div]=(fie[st][div]+1)/2;
	sort(vec[st][div].begin(),vec[st][div].end());
	int res=0;
	for(int i=0;i<(siz+1)/2;i++)res+=vec[st][div][i];
	vec[st][div].clear();
	return dp[st][div]=res;
}

int main(void){
	scanf("%d",&n);
	for(int kkkk=0;kkkk<n;kkkk++){
		cin >> str;
		memset(dp,-1,sizeof(dp));
		memset(fie,-1,sizeof(fie));
		memset(p_div,-1,sizeof(p_div));
		memset(p_divs,-1,sizeof(p_divs));
		memset(p_divl,-1,sizeof(p_divl));
		memset(stdiv,0,sizeof(stdiv));
		int stage=0,num=0,maxst=0;
		for(int i=0;i<str.size();i++){
			if(str[i]=='['){
				stage++;
				maxst=max(maxst,stage);
			}else if(str[i]==']'){
				fie[stage][stdiv[stage]]=num;
				p_div[stage][stdiv[stage]]=stdiv[stage-1];
				if(p_divs[stage-1][stdiv[stage-1]]==-1)p_divs[stage-1][stdiv[stage-1]]=stdiv[stage];
				p_divl[stage-1][stdiv[stage-1]]=stdiv[stage];
				stdiv[stage]++;
				stage--;
				num=0;
			}else{
				num*=10;
				num+=str[i]-'0';
			}
		}
		printf("%d\n",memo(1,0));
	}
	return 0;
}

Measured memory_bytes: 7804
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int n, d;
  cin >> n >> d;

  if (n % (d * 2 + 1) == 0) cout << n / (d * 2 + 1) << endl;
  else cout << n / (d * 2 + 1) + 1 << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
kouho = [list(map(int,input().split())) for i in range(n)]
kouho = sorted(kouho,key=lambda x :x[2],reverse=True)

for cx in range(101):
    for cy in range(101):
        h = kouho[0][2] + abs(kouho[0][0]-cx) + abs(kouho[0][1]-cy)
        flag = False
        for i in range(1,n):
            now = max(h - abs(kouho[i][0]-cx) - abs(kouho[i][1]-cy),0)
            if now != kouho[i][2]:
                flag = True
                break
        if not flag:
            print(str(cx) + " " + str(cy) + " " + str(h))
            exit()

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	m := make(map[int]int, n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		m[a]++
	}


	var t []int
	for _, v := range m {
		t = append(t, v)
	}
	sort.Ints(t)

	wcount := 0
	for i := 0; i < len(t); i++ {
		if len(t) > k {
			k++
			wcount += t[i]
			continue
		}
		fmt.Println(wcount)
		return
	}
}


Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
bool prime[20000000];

int main(){

  for(int i=2;i*i<20000000;i++)
    for(int j=2;j<20000000/i&&!prime[i];j++) prime[i*j]=1;

  vector <int> n;
  for(int i=2;i<20000000;i++)if(!prime[i])n.push_back(i);
					      
  int p,q;
  cin>>p>>q;
  int a=__gcd(p,q);
  p/=a,q/=a;

  int ans=1;
  for(int i=0;i<n.size();i++)
    if(q%n[i]==0){
      ans*=n[i];
      while(q%n[i]==0)q/=n[i];
    }
  ans*=q;

  cout << ans<<endl;

  return 0;

}

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

char tile[150][150];
bool flag[150][150];

int solve(int x,int y){
	if(flag[x][y]) return -1;
	int ans;
	
	flag[x][y]=true;
	switch(tile[x][y]){
	case '>':
		ans=solve(x+1,y);
		break;
	case '<':
		ans=solve(x-1,y);
		break;
	case 'v':
		ans=solve(x,y+1);
		break;
	case '^':
		ans=solve(x,y-1);
		break;
	case '.':
		ans=x*1000+y;
		break;
	default:
		break;
	}
	return ans;
}

int main(){
	int W,H,ans;

	while(1){
		cin>>H>>W;
		if(W==0&&H==0) break;
	
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				flag[j][i]=false;
			}
		}
		
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>tile[j][i];
			}
		}
		
		if((ans=solve(0,0))==-1) cout<<"LOOP"<<endl;
		else cout<<ans/1000<<" "<<ans%1000<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;
 
int n,m,r;
const int INF=1e7;
int d[2][200][200],z[1000];
typedef pair<int,int> P;
 
int main(){
 
 
    while(scanf("%d %d",&n,&m),n){
	    
	   for(int i=0;i<n;i++){
		  for(int j=0;j<n;j++) d[0][i][j]=d[1][i][j]=INF;
		  d[0][i][i]=d[1][i][i]=0;
	   }
	    
	   for(int i=0;i<m;i++){
		  int x,y,t;
		  char c;
		  scanf("%d %d %d %c",&x,&y,&t,&c);
		  x--; y--;
		  
		  d[c=='L'][x][y]=min(d[c=='L'][x][y],t);
		  d[c=='L'][y][x]=min(d[c=='L'][y][x],t);
	   }
	    
	   for(int x=0;x<2;x++){
	   for(int k=0;k<n;k++){
		  for(int i=0;i<n;i++){
			 for(int j=0;j<n;j++){
				d[x][i][j]=min(d[x][i][j],d[x][i][k]+d[x][k][j]);
			 }
		  }
	   }
	   }
	    
	   scanf("%d",&r);
	   for(int i=0;i<r;i++){
		  scanf("%d",&z[i]);
		  z[i]--;
	   }
	    
	   vector<vector<int> > dp(1000,vector<int>(200,INF));
	   dp[0][z[0]]=0;
 
	   //int res=INF;
	   for(int i=1;i<r;i++){
		  for(int j=0;j<n;j++){
						    
			 for(int k=0;k<n;k++){
				dp[i][k]=min(dp[i][k],dp[i-1][j]+d[1][z[i-1]][j]+d[0][j][k]+d[1][k][z[i]]);
				//if(i==r-1 && res>dp[i][k]) res=dp[i][k];
			 }
			 dp[i][j]=min(dp[i][j],dp[i-1][j]+d[1][z[i-1]][z[i]]);
			 //if(i==r-1 && res>dp[i][j]) res=dp[i][j];
		  }
	   }
 
	   printf("%d\n",*min_element(dp[r-1].begin(),dp[r-1].end()));
	    
    }
}

Measured memory_bytes: 4052
for i in range (0,10000) :
    a,op,b=input().split()
    a,b=[int(a),int(b)]
    if op=="+":
        print(a+b)
    if op=="-":
        print(a-b)
    if op=="*":
        print(a*b)
    if op=="/":
        print(a//b)
    if op=="?":
        break


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

int main(){

  int n,d;
  cin>>n>>d;
  double x[n][d];
  for(int i=0;i<n;i++){
      for(int j=0;j<d;j++){
          cin>>x[i][j];
      }
  }

double r;
int cnt=0;
double sq;
for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
        sq=0;
        for(int k=0;k<d;k++){
            sq+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        r=sqrt(sq);
        //cout<<"AMARI"<<r<<endl;
        if(r==(int)r){
           //cout<<"YES"<<endl;
           cnt+=1;
        }
    }
}

cout<<cnt<<endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 999999999ll
#define MIN -999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(x) cout<<x<<endl
#define gcd(x,y) __gcd(x,y) 
#define Gput(a,b) G[a].push_back(b)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*(y/z);
}
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
vector<bool> seen;
void dfs(const Graph &G,ll v){
    seen[v]=true;
    for(auto nextv:G[v]){ 
        if(seen[nextv])continue;
        dfs(G,nextv);
    }
}

int main() {
  cout << fixed << setprecision(16);
 ll n;
 cin>>n;
 vec a(n);
 loop(i,n){
 cin>>a[i];
 }
 ll ans=0;
 ll down=0;
 ll up=0;
 loop(i,n-1){
 if(a[i]<a[i+1]&&down){
  
 ans++;
   i++;
  down=0;
 
 }
 if(a[i]>a[i+1]&&up){
 ans++;
   i++;
 up=0;
 
 }
 if(a[i]<a[i+1]){
 up++;
 }
 if(a[i]>a[i+1]){
 down++;
 }
 
 
 
 
 }
 putout(ans+1);
 
 
 
 
 
 
 
 
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Collection;
import java.util.LinkedList;
import java.util.Queue;

class Main{
          public static void main(String[] args) {
                  Scanner scan = new Scanner(System.in);
                  int count = 0;
                  int N = scan.nextInt();
                  int a[] = new int[N];
                  for (int i = 0; i < N; i++) {
                          a[i] = scan.nextInt();
                  }
                  for(int j = 1; j < N; j++){
                          if (a[j-1] == a[j]) {
                                  a[j] = 10001;
                                  count++;
                          }
                  }
                  System.out.println(count);
                  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const int INF=1000000;
ll p[55][55];
void reg(int n1){
	for(int i=0;i<=n1;++i){
		p[i][0]=1;
		p[i][i]=1;
	}
	for(int i=2;i<=n1;++i){
		for(int j=1;j<i;++j){
			p[i][j]=p[i-1][j-1]+p[i-1][j];
		}
	}
}
int main() {
	int n,a,b;
	ll v[51];
	cin>>n>>a>>b;
	for(int i=0;i<n;++i){
		cin>>v[i];
	}
	sort(v,v+n,greater<>());
	ll t=0;
	for(int i=0;i<a;++i)t+=v[i];
	printf("%f\n",(double)t/a);
//	cout<<(double)t/a<<endl;
	reg(n);
	if(v[0]!=v[a-1]){
		int x=0,y=0;
		for(int i=0;i<n;++i){
			if(v[i]==v[a-1])++x;
		}
		for(int i=0;i<a;++i){
			if(v[i]==v[a-1])++y;
		}
		cout<<p[x][y]<<endl;
	}else{
		int x=0;
		ll ans=0;
		for(int i=0;i<n;++i)if(v[a-1]==v[i])++x;
		for(int i=a;i<=b;++i)ans+=p[x][i];
		cout<<ans<<endl;
	}

	return 0;
}


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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}
VI edges[100];
int d[100];
int f[100];
int tern = 0;
void dfs(int c) {

  if(d[c] != 0)
    return;

  d[c] = tern;

  rep(i, edges[c].size()) {
    if(d[edges[c][i]] == 0) {
      tern++;
      dfs(edges[c][i]);
    }
  }
  tern++;
  // cout << c << ":" << tern << endl;
  f[c] = tern;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  rep(i, n) {
    int _, k, x;
    cin >> _ >> k;
    rep(j, k) {
      cin >> x;
      x--;
      edges[i].push_back(x);
    }
  }
  rep(i, n) {
    if(d[i] == 0) {
      tern++;
      dfs(i);
    }
  }

  rep(i, n) { cout << i + 1 << " " << d[i] << " " << f[i] << endl; }

  return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

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

int N;

int main() {
  string s;
  cin >> s;
  int pos = 0;
  int rpos = s.size()-1;
  int ans = 0;
  while (pos < rpos) {
    int num = 0;
    while (pos < s.size() && s.at(pos) == 'x') {
      num++;
      pos++;
    }
    int rnum = 0;
    while (rpos >= 0 && s.at(rpos) == 'x') {
      rnum++;
      rpos--;
    }
    ans += abs(num - rnum);
    if (pos > rpos) {
      break;
    }
    if (s.at(pos) != s.at(rpos)) {
      cout << -1 << endl;
      return 0;
    }
    pos++;
    rpos--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    int x = b / a;
    if(x > c) x = c;

    System.out.println(x);
    
  }

}


Measured memory_bytes: 21844
#include<stdio.h>

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

  scanf("%d %d %d", &a, &b, &c);

  if((a == b && b != c) || (a == c && b != c) || (b == c && a != b)) printf("Yes\n");

  else printf("No\n");

  return 0;
}

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

typedef struct{
  int num;
  char first_area;
} Data;

bool ask(Data& left, Data& right){
  return left.num < right.num;
}

int main(){
  int n;
  Data data[100010];
  cin >> n;

  char tmp[2] = {'g','k'};
  int now = 1;
  for(int i = 0;i < n;i++){
    cin >> data[i].num;
    data[i].first_area = tmp[now];
    now = (now+1)%2;
  }

  sort(data,data+n,ask);

  now = 1;
  int ans = 0;
  for(int i = 0;i < n;i++){
    if(data[i].first_area != tmp[now] && now == 1){
      ans++;
    }
    now = (now+1)%2;
  }

  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 1024
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines

    import numpy as np

    N = int(readline())
    A = np.array(readline().split(), np.int32)
    B = np.array(readline().split(), np.int32)

    idx = B.argsort(); B = B[idx]; A = A[idx]

    Asorted = np.msort(A)
    if any(Asorted > B):
        print('No')
        return

    if any(Asorted[1:] <= B[:-1]):
        print('Yes')
        return

    perm = A.argsort().tolist()
    x = 0
    period = 0
    while True:
        period += 1
        x = perm[x]
        if x == 0:
            break

    print('Yes' if period != N else 'No')
    return

main()

Measured memory_bytes: 18856
#include<bits/stdc++.h>
using namespace std;
#define nn 307
#define mod 1000000007
#define ll long long
ll dp[2][nn][nn];
int val[nn*2];int n;
ll f[2*nn],rf[2*nn];
ll qpow(ll x,ll y)
{
	ll res=1;
	while(y)
	{
		if(y&1) res=res*x%mod;
		x=x*x%mod;y=y/2;
	}
	return res;
}

void add(ll &x,ll y)
{
	x=(x+y)%mod;
}
int del[nn*2],vis[nn*2];
int main()
{
	f[0]=1;rf[0]=1;for(int i=1;i<nn*2;i++) f[i]=f[i-1]*i%mod,rf[i]=qpow(f[i],mod-2);
	scanf("%d",&n);
	for(int i=1;i<=n+n;i++) scanf("%d",&val[i]);
	
	int t1=0,t0=0;
	for(int i=1;i<=n+n;i+=2) 
	{
		if(val[i]>0 and val[i+1]>0) del[val[i]]=del[val[i+1]]=1;
		else if(val[i]>0 or val[i+1]>0) vis[max(val[i],val[i+1])]=1;
		else t0++;
	}
	
	int now=0;
	dp[0][0][0]=1;
	for(int i=n+n;i>=1;i--) if(!del[i])
	{
		now^=1;memset(dp[now],0,sizeof dp[now]);
		if(!vis[i])
		for(int j=0;j<nn;j++)
			for(int k=0;k<nn;k++)
				if(dp[now^1][j][k])
				{
					if(j+1<nn)add(dp[now][j+1][k],dp[now^1][j][k]);
					if(j)add(dp[now][j-1][k],dp[now^1][j][k]);
					if(k)add(dp[now][j][k-1],dp[now^1][j][k]*k);
				}
		if(vis[i])
		for(int j=0;j<nn;j++)
			for(int k=0;k<nn;k++)
				if(dp[now^1][j][k])
				{
					if(k+1<nn)add(dp[now][j][k+1],dp[now^1][j][k]);
					if(j)add(dp[now][j-1][k],dp[now^1][j][k]);
				}
	}
	cout<<dp[now][0][0]*f[t0]%mod;
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int D[2020][2020];
const int INF = 1e9;
int main() {
    int N, X, Y; cin >> N >> X >> Y; X--, Y--;
    vector<vector<int>> G(N);
    for (int i = 0; i < N - 1; i++) {
        G[i].push_back(i + 1);
        G[i + 1].push_back(i);
    }
    G[X].push_back(Y);
    G[Y].push_back(X);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            D[i][j] = INF;
        }
    }
    for (int i = 0; i < N; i++) {
        queue<pair<int, int>> Q;
        Q.emplace(i, 0);
        while (!Q.empty()) {
            int node, dist; tie(node, dist) = Q.front(); Q.pop();
            if (D[i][node] == INF) {
                D[i][node] = dist;
                for (auto next : G[node]) {
                    Q.emplace(next, dist + 1);
                }
            }
        }
    }
    vector<int> ans(N);
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            ans[D[i][j]]++;
        }
    }
    for (int k = 1; k < N; k++) cout << ans[k] << '\n';
    return 0;
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int h,w;
    cin >> h >> w;
    string a[1010];
    for (int i = 0;i < h;++i) cin >> a[i];
    vector<vector<int>> dist(h,vector<int>(w,10000));
    deque<P> que;
    int d[4] = {0,1,0,-1};
    for (int i = 0;i < h;++i) for (int j = 0;j < w;++j) if (a[i][j] == '#') {
        dist[i][j] = 0;
        que.push_back(P(i,j));
    }
    while (!que.empty()) {
        P t = que.front();
        que.pop_front();
        for (int i = 0;i < 4;++i) {
            int x = t.first+d[i],y = t.second+d[i^1];
            if (x < 0 || x >= h || y < 0 || y >= w) continue;
            if (dist[x][y] == 10000) {
                dist[x][y] = dist[t.first][t.second]+1;
                que.push_back(P(x,y));
            }
        }
    }
    int ans = 0;
    for (int i = 0;i < h;++i) for (int j = 0;j < w;++j) ans = max(ans,dist[i][j]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13456