akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;
using std::vector;

#define MAX_N 100

void print(vector<int>& A, int N) {
  for (int i = 0; i < N - 1; i++)
    cout << A[i] << " ";
  cout << A[N-1] << endl;
}

int main() {

  vector<int> A;
  int N;

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

  // Insertion sort
  for (int i = 1; i <= N; i++) {
    print(A, N);
    int v = A[i];
    int j = i - 1;
    while ((j >= 0) && (A[j] > v)) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
  }

  
  return 0;
}

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

using namespace std;

int main(){

	long long int n, sqn, ma;

	cin>> n;

	sqn=sqrt(n)+1;

	for(long long int i=1;i<=sqn;i++){
		if(n%i==0) ma=i;
	}

	cout<< n/ma+ma-2 <<endl;

}


Measured memory_bytes: 256
/*
	watch me go
*/

#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;*/

//#define d long double
#define pii pair<int,int>
#define pb push_back
#define inf (int)1e18
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod=998244353;
int const mod1=1000000007;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 #define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// ******** Using PBDS ********
 /*typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
                os; */

int modexp(int x, int n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
 
int modinv(int n)
{
	return modexp(n,mod-2);
}

signed main()
{
    haha
   int a,b,c,k;
   cin>>a>>b>>c>>k;
   int s=0;
  
       if(k<=a)
       {
          cout<<k;
       }
      
       else if(k<=(a+b))
       {
           
           cout<<a;
       }
       else
       {
            cout<<2*a+b-k;
           
       }
     // cout<<s<<" "<<k<<endl;
      
   
   
    
    
    
    
    
    
    
   
     
}

Measured memory_bytes: 3648
import math


N,H = map(int, input().split())
A = []
B = []
for _ in range(N):
    a,b = map(int, input().split())
    A.append(a)
    B.append(b)

nage_count = 0
huri_count = 0
A_max = max(A)
for b in sorted(B, reverse = True):
  if b > A_max:
    nage_count += 1
    H -= b
    if H <= 0:
      break
  else: 
    break

# 今度は一番強いやつを振り続ける. 
if H>0:
  huri_count = math.ceil(H/A_max)
print(huri_count + nage_count)

Measured memory_bytes: 62296
#include <bits/stdc++.h>
#define long long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar
using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }

const int N= (int)1e5+10;
int n,K;
vector<int> a[N];
int p[18][N],h[N],listH[N],in[N],out[N],Time;
int res= 0;
struct segment_tree
{
	int low[4*N],high[4*N],it[4*N];
	void build(int x,int l,int r)
	{
        low[x]= l; high[x]= r; it[x]= 0;
        if (l==r) return;
        int m= (l+r)/2;
        build(2*x,l,m); build(2*x+1,m+1,r);
	}

	void update(int x,int l,int r)
	{
        if (low[x]> r or high[x]<l) return;
        if (low[x]>=l and high[x]<=r)
		{
			it[x]++; return;
		};
        update(2*x,l,r); update(2*x+1,l,r);
	}
	int query(int x,int pos)
	{
        if (low[x]== high[x]) return it[x];
        if (pos<= high[2*x]) return it[x]+ query(2*x,pos);
        else return it[x]+ query(2*x+1,pos);
	}
}exist;
void input()
{
    cin>>n>>K;
    up(i,1,n)
    {
        if (i==1)
		{
			int u; cin>>u; if (u!=1) res++;
		}
		else
		{
			cin>>p[0][i];
			a[p[0][i]].push_back(i);
		}
    }
}

void dfs(int u,int par,int curH)
{
	p[0][u]= par; h[u]= curH;
	in[u]= ++Time;
	for (auto v: a[u])
		if (v!= par) dfs(v,u,curH+1);
	out[u]= Time;
}
bool byH(int i,int j)
{
	return h[i]> h[j];
}
int getbit(int x,int k)
{
	return (x>>k) & 1;
}
int par_k(int u)
{
	down(i,17,0)
	 if (getbit(K-1,i)) u= p[i][u];
	return u;
}
void solve()
{
    Time= 0; dfs(1,0,0);
    up(i,1,17)
     up(j,1,n)
      p[i][j]= p[i-1][p[i-1][j]];
    up(i,1,n) listH[i]= i;
    sort(listH+1,listH+1+n,byH);

    exist.build(1,1,n);
    up(id,1,n)
    {
    	int u= listH[id];
        if (h[u]<=K or exist.query(1,in[u])!=0 ) continue;
        int p= par_k(u);
        exist.update(1,in[p],out[p]); res++;
    }

    cout<<res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// don't use when interactive

    #ifdef I_Love_Pork
    #define TASK "tmp"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
	#endif

    input();
    solve();

    return 0;
}


Measured memory_bytes: 24704
#include <stdio.h>

int main() {
  int a[101][101] = {0};
  int b[101] = {0};
  int d[101] = {0};
  int i,j,r,c;
  int x;
  int e = 0;

  scanf("%d %d" , &r,&c);

  for(j=0; j<r; j++) {
    for(i=0; i<c; i++) {
      scanf("%d",&x);
      a[j][i] = x;
    }
  }

  for(j=0; j<r; j++){
    for(i=0; i<c; i++) {
      b[i] += a[j][i];
    }
  }

  for(j=0; j<r; j++){
    for(i=0; i<c; i++){
      d[j] += a[j][i];
    }
  }

  for(j=0; j<r; j++) {
    for(i=0; i<c; i++) {
      printf("%d ",a[j][i]);
    }
    printf("%d\n", d[j]);
  }
  for(i =0; i<c; i++) {
    printf("%d " ,b[i]);
    e += b[i];
  }
  printf("%d\n", e);

  return 0;
}

Measured memory_bytes: 648
import java.util.*;
import java.io.*;

class Main{
  static int A[] = new int[2000000];
  static int H = 0;
  public static void main(String args[])throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String [] s = new String[2];
    while(true){
      s = br.readLine().split("\\s+");
      if(s[0].charAt(0) == 'i'){
        insert(Integer.parseInt(s[1]));
      }else if(s[0].charAt(1) == 'x'){
        System.out.println(heapExtractMax(A));
      }else{
        break;
      }
    }
  }

  static void insert(int key){
    H++;
    A[H] = (int)Double.NEGATIVE_INFINITY;
    heapIncreaseKey(A, H, key);
  }

  static void heapIncreaseKey(int A[], int i, int key){
    int tmp = 0;
    if(key<A[i]){
      return;
    }
    A[i] = key;
    while(i >1 && A[parent(i)]< A[i]){
      tmp = A[i];
      A[i] = A[parent(i)];
      A[parent(i)] = tmp;
      i = parent(i);
    }
  }

  static int heapExtractMax(int A[]){
    if(H<1){
      System.out.println("under flow");
      return (int)Double.NEGATIVE_INFINITY;
    }
    int max = A[1];
    A[1] = A[H--];
    maxHeapify(A, 1);

    return max;
  }

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

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

    if(r<=H && A[r] > A[largest] ) largest = r;

    if(largest != i){
      tmp = A[i];
      A[i] = A[largest];
      A[largest] = tmp;
      maxHeapify(A, largest);
    }
  }
  static int parent(int i){
    return i/2;
  }

}


Measured memory_bytes: 551376
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

struct UnionFind {
  vector<int> d;
  UnionFind(int n = 0): d(n, -1) {}
  int find(int x) {
    if(d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) {return -d[find(x)];}
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(200010);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    uf.unite(a, b);
  }

  int ans = 0;
  rep(i, n) {
    ans = max(ans, uf.size(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 4048
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! 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")
    };
}
fn main() {
    input! {
        n: usize,
        a: [i32; n],
    }
    println!("{}", a.into_iter().enumerate().filter(|&(i, x)| i % 2 == 0 && x % 2 == 1).count());
}

Measured memory_bytes: 2104
#include <bits/stdc++.h>
   using namespace std;
   int main()
   {
      //    string in;
      //  getline(cin,in);
      //  cout<<in;
      //  int t;
      //  cin >> t;
      //  while (t--)
      //  {
         long long num;
         string str;
         cin >> num;

         char temp;
         while (num > 0)
         {
               temp = num % 26;
               if (temp == 0)
               {
                  if (num / 26 != 0)
                  {
                     str.push_back('z');
                     num--;
                  }
               }
               else
               {
                  temp = temp + 96;
                  str.push_back(temp);
                  //cout<<temp;
               }
               temp = 0;
               num /= 26;
         }

         reverse(str.begin(), str.end());
         cout << str << endl;
         
      //  }
   }

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

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int s[] = new int[M];
		int c[] = new int[M];
		
		for(int i = 0; i < M; i++){
			s[i] = sc.nextInt() - 1;
			c[i] = sc.nextInt();
		}
		
		int ans = -1;
		for(int n = (N == 1)?0:(int)Math.pow(10, N-1); n < (int)Math.pow(10, N); n++){
			String str = String.valueOf(n);
			boolean flag = false;
			for(int j = 0; j < M; j++){
				if(str.charAt(s[j])-'0' != c[j]){
					flag = true;
					break;
				}
			}
			if(flag)continue;
			else {
				ans = n;
				break;
			}
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
h,w = map(int, input().split())
s = [list(input()) for _ in range(h)]

ans = [[0]*w for _ in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      ans[i][j] = "#"
      for i2 in range(i-1, i+2):
        if i2 < 0 or h-1 < i2: continue
        for j2 in range(j-1, j+2):
          if (j2 < 0 or w-1 < j2): continue
          elif ans[i2][j2] == "#": continue
          ans[i2][j2] += 1
for i in ans:
  print("".join(map(str,i)))

Measured memory_bytes: 9148
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
	init();
	string s;cin>>s;
	ll size=s.size();
	while(!s.empty()){
		s.pop_back();
		ll n=s.size();
		if(n%2==1)continue;
		string t=s.substr(0,n/2);
		string u=s.substr(n/2,n/2);
		if(t==u){
			cout<<n<<endl;
			return 0;
		}
	}
}



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

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

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

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int n, u, v;
    cin >> n >> u >> v;
    u--; v--;
    auto g = make_vec<int>({n, 0});
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> dist_v(n), dist_u(n), par(n);
    auto dfs = [&](auto self, vector<int>& dist, int nv, int p = -1) -> void {
        for (int nu : g[nv]) {
            if (nu == p) continue;
            par[nu] = nv;
            dist[nu] = dist[nv] + 1;
            self(self, dist, nu, nv);
        }
    };
    dfs(dfs, dist_u, u);
    dfs(dfs, dist_v, v);

    vector<bool> available(n);
    auto dfs2 = [&](auto self, int nv, int p = -1) -> void {
        for (int nu : g[nv]) {
            if (nu == p) continue;
            if (dist_v[nu] <= dist_u[nu]) continue;
            available[nu] = true;
            self(self, nu, nv);
        }
    };
    available[u] = true;
    dfs2(dfs2, u);

    int x = -1;
    int now = 0;
    rep(i, n) if (available[i]) {
        if (chmax(now, dist_v[i])) x = i;
    }
    int ans = dist_v[par[x]];
    cout << ans << '\n';
}


Measured memory_bytes: 18924
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        
        System.out.println(
            s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5)?"Yes":"No"
        );
    }
}

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

int main()
{
    int n;
    cin >> n;
    int imos[100010] = {};
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        ++imos[a];
        --imos[b + 1];
    }
    int ans;
    int a = 0;
    for (int i = 0; i < 100010; ++i) {
        a += imos[i];
        if (a + 1 >= i) {
            ans = i - 1;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3480
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
 
#pragma comment(linker, "/STACK:336777216")  
 
using namespace std;

const int MAXN = 200000 + 10;

int N, M;

void Work()
{
	scanf("%d%d", &N, &M);
	if (N >= M)
		swap(N, M);
	long long Ans = 0;
	if (N == 1 && M == 1)
		Ans = 1;
	else if (N == 1)
		Ans = M - 2;
	else
		Ans = (long long) (N - 2) * (long long) (M - 2);
	printf("%lld\n", Ans);
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N, L;
  cin >> N >> L;
  
  if(L >= 0 )
    cout << ((2*L+N)*(N-1))/2 << endl;
  else if(L+N-1 < 0)
    cout << ((2*L+N-2)*(N-1))/2 <<endl;
  else
    cout << ((2*L+N-1)*N)/2 <<endl;
  
  
    
		
}

Measured memory_bytes: 256
public class Main {
	MyScanner sc = new MyScanner();
	int N, M, a, b, w;
	int[] parent;
	Node[] node;

	void run() {
		for (;;) {
			N = sc.nextInt(); // 荷物数
			M = sc.nextInt(); // クエリ数
			if ((N | M) == 0) {
				return;
			}
			parent = new int[N + 1];
			node = new Node[N + 1];
			init();

			for (int i = 0; i < M; i++) {
				String query = sc.next();
				a = sc.nextInt();
				b = sc.nextInt();
				if (query.equals("!")) {
					w = sc.nextInt();
					union(a, b, w);
				} else if (query.equals("?")) {
					System.out.println(same(a, b) ? node[b].weight
							- node[a].weight : "UNKNOWN");
				}
			}
		}
	}

	void init() {
		for (int i = 0; i <= N; i++) {
			parent[i] = i;
			node[i] = new Node(0, 0);
		}
	}

	void union(int x, int y, int w) {
		int rootX = find(x);
		int rootY = find(y);
		if (rootX == rootY) {
			return;
		}
		if (node[rootX].rank < node[rootY].rank) {
			node[rootX].weight = -w - node[x].weight + node[y].weight;
			parent[rootX] = rootY;
		} else {
			node[rootY].weight = w - node[y].weight + node[x].weight;
			parent[rootY] = rootX;

			if (node[rootX].rank == node[rootY].rank) {
				node[rootX].rank++;
			}
		}
	}

	int find(int target) {
		if (parent[target] == target) {
			return target;
		} else {
			int tmp = find(parent[target]);
			node[target].weight += node[parent[target]].weight;
			return parent[target] = tmp;
		}
	}

	boolean same(int x, int y) {
		return find(x) == find(y);
	}

	class Node {
		int weight;
		int rank;

		/**
		 * @param weight
		 * @param rank
		 */
		public Node(int weight, int rank) {
			super();
			this.weight = weight;
			this.rank = rank;
		}
	}

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

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 143412
/* ***********************************************
Author        :yang12138
Created Time  :2017/12/2 3:31:46
File Name     :B.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;


const int N=1e6+10;
char s[N];

ll get(int n){
	return 1LL*n*(n+1)/2;
}

int cnt[30];
void solve(){
	scanf("%s",s);
	int len=strlen(s);
	ll ans=get(len);
	for(int i=0;i<len;i++) cnt[s[i]-'a']++;
	for(int i=0;i<26;i++) ans-=get(cnt[i]);
	cout<<ans+1<<endl;
}


int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	solve();
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<string>

using namespace std;


void Solution()
{
    int amount = 0;
    int income = 0;
    
    int m, n;
    
    int count = 0;
    
    char comma;
    
    while(cin>>m>>comma>>n)
    {
        income += m * n;
        amount += n;
        count++;
    }
    
    cout<<income<<endl;
    cout<<(int)((double)amount / count + 0.5)<<endl;   //this way also can be used to solve half-adjusting
}

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

Measured memory_bytes: 1160
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    maxes = [0] * (N + 1)
    for i in range(M):
        A, B = map(int, input().split())
        maxes[A] = max(maxes[A], H[B-1])
        maxes[B] = max(maxes[B], H[A-1])
        
    # print(maxes)
    print(sum([1 for h, m in zip(H, maxes[1:]) if h > m]))


if __name__ == '__main__':
    main()

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

int main(){
  int n,m;
  cin >> n >> m;
  
  vector <int> from(m);
  vector <int> to(m);
  vector <int> town(n);

  for(int i = 0;i<m;i++){
    cin >> from.at(i);
    cin >> to.at(i);
    town.at(from.at(i)-1) += 1;
    town.at(to.at(i)-1) += 1;
  }
  for(int i = 0;i<n;i++){
    cout << town.at(i) << endl;
  }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLine()?.split(" ")?.map(String::toInt) ?: return
    val a = mutableListOf<String>()
    repeat(n) {
        a.add(readLine() ?: return)
    }
    val b = mutableListOf<String>()
    repeat(m) {
        b.add(readLine() ?: return)
    }
    0.until(n - (m - 1)).forEach { i ->
        0.until(n - (m - 1)).forEach { j ->
            var match = true
            b.forEachIndexed loop@{ index, bs ->
                val s = a[i + index].substring(j, j + bs.length)
                if (s != bs) {
                    match = false
                    return@loop
                }
            }
            if (match) {
                println("Yes")
                return
            }
        }
    }
    println("No")
}

Measured memory_bytes: 36724
#include<stdio.h>

int n,A[50];

int solve(int i,int m){
  if(m == 0)return 1;
  if(i >= n)return 0;
  int ans = solve(i + 1,m) || solve(i + 1,m - A[i]);
  return ans;
}

int main(){
  int q,M,i;

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

  scanf("%d",&q);

  for(i = 0;i < q;i++){
    scanf("%d",&M);
    if(solve(0,M))printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b;
    cin >> a >> b;
   // cout << a << " " << b << endl;
    if(a[0] == 'H' && b[0] == 'H')
        cout << "H" << endl;
    else if(a[0] == 'D' && b[0] == 'D')
        cout << "H" << endl;
    else if(a[0] == 'D' && b[0] == 'H')
        cout << "D" << endl;
    else if(a[0] == 'H' && b[0] == 'D')
        cout << "D" << endl;


    return 0;
}


Measured memory_bytes: 384
# ------------------------------------------------------------
# THIS IS METADATA FOR ATCODER_TOOLS
# BE CAREFULL WHEN YOU CHANGE THE VALUE
# 
# METADATA::START
# test-1
# input: "1900\n"
# output: "100\n"
# test-2
# input: "3000\n"
# output: "0\n"
# MODE: TEST
# METADATA::FINISH
# 
# you can add your original test case 
# you can select MODE from NONE, DEBUG, RUN, TEST
# problem_url: https://atcoder.jp/contests/abc173/tasks/abc173_a
# submission_url: https://atcoder.jp/contests/abc173/submissions/me
# -------------------------------------------------------------

# snippets
n = gets.to_i
# arr = gets.split(' ').map(&:to_i)

puts 1000-(((n-1)%1000) + 1)



Measured memory_bytes: 14260
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int x, y, z;
    cin >> x >> y >> z;
    cout << (x*y)/2 << std::endl;
    return 0;
}

Measured memory_bytes: 764
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
H=n1()

dp=[0]*n
dp[1]=abs(H[0]-H[1])
for i in range(2,n):
    dp[i]=min(dp[i-2]+abs(H[i-2]-H[i]),dp[i-1]+abs(H[i-1]-H[i]))

print(dp[n-1])

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

using namespace std;
using namespace __gnu_pbds;

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

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

ll arr[100001];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n,k;
    cin>>n>>k;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        arr[a]+=b;
    }
    ll count=0;
    for(ll i=1;;i++){
        count+=arr[i];
        if(count>=k){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
package main

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

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	maxSize := 300000 * 2
	buf := make([]byte, maxSize)
	sc.Buffer(buf, maxSize)
	n := scanLineInt(sc)
	s := scanLineStr(sc)

	var count int
	for i := 0; i < n; i++ {
		if s[i] == 'E' {
			count++
		}
	}

	min := count
	for i := 0; i < n; i++ {
		if s[i] == 'E' {
			count--
		}
		if i > 0 && s[i-1] == 'W' {
			count++
		}
		if count < min {
			min = count
		}
	}
	fmt.Println(min)
}

func scanLineStr(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanLineInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


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

int main(void)
{
    char s[15];
    int i, num, smallest = 753;
    scanf("%s", s);

    num = 100 * (s[0] - '0');


    for (i = 0; s[i + 2] != '\0'; i++)
    {
        num = abs((100 * (s[i] - '0') + 10 * (s[i + 1] - '0') + (s[i + 2] - '0')) - 753);
        if (smallest > num) smallest = num;
    }

    printf ("%d", smallest);

    return (0);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        string result = "";

        int sx = int.Parse(str[0]);
        int sy = int.Parse(str[1]);
        int tx = int.Parse(str[2]);
        int ty = int.Parse(str[3]);
        int nowX = sx;
        int nowY = sy;

        // 1st go
        while(nowX != tx)
        {
            nowX++;
            result += "R";
        }
        while (nowY != ty)
        {
            nowY++;
            result += "U";
        }
        // 1st back
        while (nowX != sx)
        {
            nowX--;
            result += "L";
        }
        while (nowY != sy)
        {
            nowY--;
            result += "D";
        }

        // 2nd go
        nowY--;
        result += "D";
        while (nowX != tx + 1)
        {
            nowX++;
            result += "R";
        }
        while (nowY != ty)
        {
            nowY++;
            result += "U";
        }
        nowX--;
        result += "L";

        // 2nd back
        nowY++;
        result += "U";
        while (nowX != sx - 1)
        {
            nowX--;
            result += "L";
        }
        while (nowY != sy)
        {
            nowY--;
            result += "D";
        }
        nowX++;
        result += "R";

        Console.Write(result);
    }
}

Measured memory_bytes: 34772
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a <= c && c <= b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){

  int x,res = -1;
  cin >> x;
  for(int i = 2;i*i <= x;i++){
    int n = i;
    while(n*i <= x){
      n *= i;
    }
    if(n != i)res = max(res,n);
  }
  if(x <= 3)res = 1;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ok[200001],test[200001];
int main()
{
	string s, t;
	cin>>s>>t;
	for (int i = 0; i < s.size(); i++)
	{
		if (ok[(int)s[i]] == 0)
		{
			ok[(int)s[i]] = (int)t[i];
		}
		else if (ok[(int)s[i]] != (int)t[i])
		{
			cout<<"No";
			return 0;
		}
		if (test[(int)t[i]] == 0)
		{
			test[(int)t[i]] = (int)s[i];
		}
		else if (test[(int)t[i]] != (int)s[i])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 776
from collections import defaultdict


def main():
    n = int(input())
    a = [int(an) for an in input().split()]
    cnt = defaultdict(int)
    for an in a:
        cnt[an - 1] += 1
        cnt[an] += 1
        cnt[an + 1] += 1
    print(max(cnt.values()))


if __name__ == "__main__":
    main()


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

int main() {
    int x, y, z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << endl;


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include <algorithm>
#include<string>
using namespace std;

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

        int num=stoi(to_string(a)+to_string(b));
        int root=(int)sqrt(num);

        cout << (root*root==num ? "Yes" : "No") << endl;
        return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        String str=sc.nextLine();
        int cnt=0;
        for(int i=0;i<str.length();i++){
            if(str.charAt(i)=='1'){
                cnt++;
            }
        }
        System.out.print(cnt+"\n");
    }
}

Measured memory_bytes: 21076
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
	int n;
	cin >> n;
 
	vector<pair<int, int>> r(n), b(n);
	for (int i = 0; i < n; ++i) {
		cin >> r[i].second >> r[i].first;
	}
	for (int i = 0; i < n; ++i) {
		cin >> b[i].first >> b[i].second;
	}
 
 	sort(r.begin(), r.end());
  	sort(b.begin(), b.end());
  	vector<int> used(n);
  	int idx, res = 0;
  	for (int i = 0; i < n; ++i) {
    	bool f = false;
    	for (int j = 0; j < n; ++j) {
      		if (r[j].second < b[i].first && r[j].first < b[i].second) { 
        		if (used[j]==0) {
          			f = true;
          			idx = j;
        		}
      		}
    	}
    	if (f) {
      		++res;
      		used[idx] = 1;
    	}
  	}
  	cout << res << endl;
 }


Measured memory_bytes: 256
n, m = map(int, input().split())
mat = []
for _ in range(n):
    mat.append(list(map(int, input().split())))

vec = []
for _ in range(m):
    vec.append(int(input()))

result = []
for line in mat:
    c = sum([line[i] * vec[i] for i in range(m)])
    result.append(c)

print("\n".join(map(str, result)))


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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               2e9
#define INF_LL            1LL<<60
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 一次元累積和
template<class T>
class Ruiseki
{
private:
	int num;

public:
	vector<T> sumVal;
	Ruiseki(const vector<T> &srcVal)
	{
		num = srcVal.size();
		sumVal.resize(num + 1, 0);
		for (int i = 0; i < num; i++) {
			sumVal[i + 1] = sumVal[i] + srcVal[i];
		}
	}

	T GetSumAll()
	{
		return sumVal[num];
	}

	T GetSumRange(int startIdx, int endIdx)
	{
		return sumVal[endIdx] - sumVal[startIdx];
	}

	T GetSumFromTop(int endIdx)
	{
		return sumVal[endIdx] - sumVal[0];
	}

	T GetSumFromEnd(int startIdx)
	{
		return sumVal[num] - sumVal[startIdx];
	}
};


// 処理
void Solve()
{
	ll N, M, V, P;
	cin >> N >> M >> V >> P;
	vector<ll> A(N);
	REP(i, N) {
		cin >> A[i];
	}
	sort(ALL(A), greater<ll>());
	
	ll minScore = A[P - 1];
	ll nokori = V - (P - 1);
	ll ans = 0;
	reverse(ALL(A));
	Ruiseki<ll> seki(A);
	for (int i = 0; i < N; i++) {
		if (minScore <= A[i]) {
			ans++;
		} else {
			ll sameCnt = 0;
			for (; i < N - 1; i++) {
				sameCnt++;
				if (A[i] != A[i + 1]) {
					break;
				}
			}

			ll num = nokori - i - 1;
			ll addVal = A[i] + M;
			if (minScore <= addVal) {
				if (num <= 0) {
					ans += sameCnt;
				} else {
					ll nokoriNum = N - P - i; 
					ll nokoriSum = addVal * nokoriNum - seki.GetSumRange(i + 1, i + 1 + nokoriNum);
					if (nokoriSum >= num * M) {
						ans += sameCnt;
					}
				}
			}
		}
	}

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N;
int A[100010];
int B[100010];

int main() {
    cin >> N;
    for (int i = 0; i < N+1; ++i) cin >> A[i];
    for (int i = 0; i < N; ++i) cin >> B[i];

    ll ans = 0;
    for (int i = N-1; i >= 0; --i) {
        if (B[i] >= A[i+1]) {
            ans += A[i+1];
            B[i] -= A[i+1];
        } else {
            ans += B[i];
            B[i] = 0;
        }
        if (B[i] >= A[i]) {
            ans += A[i];
            A[i] = 0;
        } else {
            ans += B[i];
            A[i] -= B[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
# coding: utf-8
import fractions 
import functools 

def pin(type=int):
    return map(type,input().split())

INF = float("inf")

def Flog_1(N,H):
    dp=[INF for i in range(N)]
    dp[0]=0  #h1=0
    dp[1]=abs(H[1]-H[0])
    for i in range(2,N):
        hop1=dp[i-1]+abs(H[i-1]-H[i]) 
        hop2=dp[i-2]+abs(H[i-2]-H[i]) 
        #print(hop1,hop2)
        dp[i]=hop1 if hop1<hop2 else hop2
    return dp
def Flog_1_Another(N,H):
    dp=[INF for i in range(N)]
    dp[0]=0  #h1=0
    for i in range(0,N):
        for k in [1,2]:
            if i+k <N:
                dp[i+k]=min(dp[i+k],dp[i]+abs(H[i+k]-H[i]))
    return dp

def Flog_2(N,K,H):
    dp=[INF for i in range(N)]
    dp[0]=0  #h1=0,default position
    for i in range(1,N):
        temp = INF
        for k in range(1,K+1):
            if i-k < 0:break
            else:
                temp = min(temp,(dp[i-k]+abs(H[i-k]-H[i])))
                
        dp[i]=temp
    return dp
def Flog_2_Another(N,K,H):
    dp=[INF for i in range(N)]
    dp[0]=0  #h1=0
    for i in range(0,N):
        for k in range(1,K+1):
            if i+k <N:
                dp[i+k]=min(dp[i+k],dp[i]+abs(H[i+k]-H[i]))
    return dp
def Flog_2_YETAnother(N,K,H):
    if N == 1:
        return 0
    else:
        map(min,[Flog_2_YETAnother(N-i,K,H) for i in range(1,N+1)])
 
def vacation(N):
   
    dp=[[0]*3 for i in range(N)]
    dp[0]=list(pin())
    for i in range(1,N):
       
        temp=list(pin())
       
        dp[i][0]= max(dp[i-1][1],dp[i-1][2])+temp[0]
        dp[i][1]= max(dp[i-1][2],dp[i-1][0])+temp[1]
        dp[i][2]= max(dp[i-1][0],dp[i-1][1])+temp[2]
        
    return max(dp[-1])

N,=pin()
 
#output
print(vacation(N))

Measured memory_bytes: 24760
#include<bits/stdc++.h>
using namespace std;
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int main(){
	int a,b,c,d;
	char aa,bb,cc,dd;
	cin>>aa>>bb>>cc>>dd;
	int tmp=0;
	char op1,op2,op3;
	a=ctoi(aa);
	b=ctoi(bb);
	c=ctoi(cc);
	d=ctoi(dd);
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<2;k++){
				tmp=a;
				if(i==0){
					tmp+=b;
					op1='+';
					//cout<<tmp<<endl;
				}else{
					tmp-=b;
					op1='-';
				}
				if(j==0){
					tmp+=c;
					op2='+';
				}else{
					tmp-=c;
					op2='-';
				}
				if(k==0){
					tmp+=d;
					op3='+';
				}else{
					tmp-=d;
					op3='-';
				}
				if(tmp==7){
					cout<<a<<op1<<b<<op2<<c<<op3<<d<<"=7"<<endl;
					return 0;
				}/*else{
					cout<<a<<op1<<b<<op2<<c<<op3<<d<<endl;
				}*/
			}
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

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

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

int main() {
    int n, w;
    cin >> n >> w;
    vector<ll> weight(n), value(n);
    rep(i, n) cin >> weight[i] >> value[i];

    vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, 0));
    rep(i, n) {
        rep(k, w + 1) {
            chmax(dp[i + 1][k], dp[i][k]);
            if(k - weight[i] >= 0) chmax(dp[i + 1][k], dp[i][k - weight[i]] + value[i]); 
        }
    }
    cout << dp[n][w] << endl;

    return 0;
}


Measured memory_bytes: 80256
#include<stdio.h>
int main(void)
{
	int b=0,i=0,c=0;
	int a[1000]={0};
	for(i=0;i<5;i++){
	scanf("%d",&a[i]);
		if(40>=a[i]){
		a[i]=40;
	}
}
	b=a[0]+a[1]+a[2]+a[3]+a[4]+a[5];
	c=b/5;
	printf("%d\n",c);
	return 0;
}



Measured memory_bytes: 2060
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 3e18;
long long int mod = 4294967296;
double Pi = 3.1415926535897932384626;

//vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}

ll i,j,k,ii,jj;
ll n,m,num,sum;
ll ans;
ll a,b,c,e,g,h,w,ok,ng;
ll x[100005],y[100005],z[100005];
ll t[100005],d[100005];
bool flag,dame;
char s[1000005];
bool use1[100005],use2[100005];


int main(){
    cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> t[i] >> d[i];
		if(!use1[t[i]]){
			a++;
			use1[t[i]] = true;
		}
	}
	for(i=0;i<n;i++){
		x[t[i]] = max(x[t[i]],d[i]);
	}
	for(i=0;i<n;i++){
		if(use2[t[i]] || d[i] != x[t[i]]){
			y[num++] = d[i];
		}
		if(x[t[i]] == d[i]){
			use2[t[i]] = true;
		}
	}
	b = num;
	sort(y,y+b);
	reverse(y,y+b);
	num = 0;
	for(i=1;i<=n;i++){
		if(x[i] != 0){
			z[num++] = x[i];
		}
	}
	assert(a == num);
	sort(z,z+num);
	reverse(z,z+num);
	for(i=1;i<=a;i++){
		x[i] = z[i-1];
	}
	for(i=2;i<=a;i++){
		x[i] += x[i-1];
	}
	for(i=b;i>=1;i--){
		y[i] = y[i-1];
	}
	for(i=2;i<=b;i++){
		y[i] += y[i-1];
	}
	for(i=1;i<=a;i++){
		//pe(x[i]);
	}
	//el;
	for(i=1;i<=b;i++){
		//pe(y[i]);
	}
	//el;
	assert(a + b == n);
	x[0] = 0;
	y[0] = 0;
	assert(a >= 1);
	for(i=1;i<=a;i++){
		if(k-i < 0)break;
		ans = max(ans,x[i] + y[k-i] + i * i);
		//pe(ans);
	}
	//el;
	p(ans);
	return 0;
}

Measured memory_bytes: 4096
<?php
$N = trim(fgets(STDIN));
$arr = explode(" ",trim(fgets(STDIN)));
$T = $arr[0];
$A = $arr[1];
$array = explode(" ",trim(fgets(STDIN)));


for($i=0; $i<$N; $i++){
    $h[] = abs($A - ($T - $array[$i] * 0.006));
}

$ans = array_keys($h, min($h));
echo $ans[0] + 1;
?>

Measured memory_bytes: 4728
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>


using namespace std;

struct UnionFind {
	vector<int>d;
	UnionFind(int i = 0) :d(i, -1) {}
	int find(int x) {
		if (d[x] < 0)return x;
		else return d[x] = find(d[x]);
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return false;
		else {
			if (d[x] > d[y])swap(x, y);
			d[x] += d[y];
			d[y] = x;
			return true;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		return -d[find(x)];
	}
};

int main() {
	int N, M, K;
	cin >> N >> M >> K;
	vector<int>deg(N);
	UnionFind uf(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		deg[a]++;
		deg[b]++;
		uf.unite(a, b);
	}
	vector<vector<int>>block(N);
	for (int i = 0; i < K; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		block[a].push_back(b);
		block[b].push_back(a);
	}
	for (int i = 0; i < N; i++) {
		int ans = uf.size(i) - 1 - deg[i];
		for (int j :block[i]) {
			if (uf.same(i, j))ans--;
		}
		cout << ans << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 6784
def main():
    a,b,h,m = map(int,input().split())
    ji = 0.5*(h*60+m)
    fun = 6*m
    r = max(ji,fun)-min(ji,fun)

    import math
    print(math.sqrt((a**2 + b**2) - 2*a*b*math.cos(math.radians(r))))

if __name__ == '__main__':
    main()


Measured memory_bytes: 62576
#include<stdio.h>

int main()
{
   int a,b,temp;
   for(;;)
   {
       scanf("%d%d",&a,&b);
       if(a==0 && b==0)
        break;
       if(a>b)
       {
           temp=b;
        b=a;
        a=temp;
       }

       printf("%d %d\n",a,b);
   }

}



Measured memory_bytes: 2072
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int N;
	cin>>N;
	vector<int> C(N);
	rep(i,N) cin>>C[i];
	vector<int> a(N);
	int Q;
	cin>>Q;
	rep(i,Q){
		int t,x,d;
		cin>>t>>x>>d;
		x--;
		if(t==1){
			a[x] += d;
			if(a[x]>C[x]){
				cout<<x+1<<endl;
				return 0;
			}
		}else{
			a[x] -= d;
			if(a[x]<0){
				cout<<x+1<<endl;
				return 0;
			}
		}
	}
	cout<<0<<endl;
}



Measured memory_bytes: 3108
#include<iostream>
using namespace std;
int main(){
    int S,h,m,s;
    cin >> S;
    h = S / 3600;
    S = S % 3600;
    m = S / 60;
    s = S % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3100