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

using namespace std; 
struct node {
	long long key;
	long long pri;
	node* left;
	node* right;
};

node* root;
node* rightRotate(node* t);
node* leftRotate(node* t);
node* insert(node* t, long long k, long long p);
node* delete_node(node* t, long long k);
node* _delete(node* t, long long k);

node* rightRotate(node* t) {
	node* s = t->left;
	t->left = s->right;
	s->right = t;
	if (t == root) {
		root = s;
	}
	return s;
} 

node* leftRotate(node* t) {
	node* s = t->right;
	t->right = s->left;
	s->left = t;
	if (t == root) {
		root = s;
	}
	return s;
}

node* insert(node* t, long long k, long long p) {
	if (t == NULL) {
		if (root == NULL) {
			root = new node{k,p,NULL,NULL};
			return root;
		}
		return (new node{k,p});
	}
	if (k < t->key) {
		t->left = insert(t->left,k,p);
		if (t->pri < t->left->pri) {
			t = rightRotate(t);
		}
	}
	else {
		t->right = insert(t->right,k,p);
		if (t->pri < t->right->pri) {
			t = leftRotate(t);
		}
	}
	return t;
}

node* delete_node(node* t, long long k) {
	if (t == NULL) {
		return NULL;
	}
	if (k < t->key) {
		t->left = delete_node(t->left,k);
	}
	else if (k > t->key) {
		t->right = delete_node(t->right,k);
	}
	else {
		return _delete(t,k);
	}
	return t;
}

node* _delete(node* t, long long k) {
	if (t->left == NULL && t-> right == NULL) {
		if (t == root) {
			root = NULL;
		}
		return NULL;
	}
	else if (t->left == NULL) {
		t = leftRotate(t);
	}
	else if (t->right == NULL) {
		t = rightRotate(t);
	}
	else {
		if (t->left->pri > t->right->pri) {
			t = rightRotate(t);
		}
		else {
			t = leftRotate(t);
		}
	}
	return delete_node(t,k);
}

bool find_node(long long k) {
	node* now = root;
	while (now != NULL) {
		if (k == now->key) {
			return true;
		}
		else if (k > now->key) {
			now = now->right;
		}
		else {
			now = now->left;
		}
	}
	return false;
}

void inorder_walk(node* t) {
	if (t == NULL) {
		return;
	}
	inorder_walk(t->left);
	cout << " " << t->key;
	inorder_walk(t->right);
	return;
}

void preorder_walk(node* t) {
	if (t == NULL) {
		return;
	}
	cout << " " << t->key;
	preorder_walk(t->left);
	preorder_walk(t->right);
	return;
}

int main(void) {
	int nop;
	cin >> nop;

	root = NULL;
	string ope;
	long long k,p;
	for (int q = 0; q < nop; ++q) {
		cin >> ope;
		if (ope == "print") {
			inorder_walk(root);
			cout << endl;
			preorder_walk(root);
			cout << endl;
		}
		else {
			cin >> k;
			if (ope == "insert") {
				cin >> p;
				insert(root,k,p);
			}
			else {
				if (ope == "find") {
					if (find_node(k)) {
						cout << "yes" << endl;
					}
					else {
						cout << "no" << endl;
					}
				}
				else {
					delete_node(root,k);
				}
			}
		}
	}
	return 0;
}



Measured memory_bytes: 12600
using System;

public class Program
{
	public static void Main(string[] args)
	{
		var ss = new StreamScanner();
		//---------------------------------
		var x = ss.Next<int>();
		var y = ss.Next<int>();
		var z = ss.Next<int>();
		if (x <= y && y <= z)
		{
			Console.WriteLine(x + " " + y + " " + z);
		}
		else if (x <= z && z <= y)
		{
			Console.WriteLine(x + " " + z + " " + y);
		}
		else if (y <= x && x <= z)
		{
			Console.WriteLine(y + " " + x + " " + z);
		}
		else if (y <= z && z <= x)
		{
			Console.WriteLine(y + " " + z + " " + x);
		}
		else if (z <= x && x <= y)
		{
			Console.WriteLine(z + " " + x + " " + y);
		}
		else 
		{
			Console.WriteLine(z + " " + y + " " + x);
		}
	

		/*
		//????????????int, double, string?????????????????£????????????
		int i = ss.Next<int>();
		double d = ss.Next<double>();
		string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		int[] array = ss.Next<int>(10);
		*/
		//---------------------------------
	}
}



public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

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

int main(void){
 int n;
  int *mon,*yu;
  unsigned long teki=0;
  scanf("%d",&n);
  
  mon = (int *)malloc(sizeof(unsigned long) * n + 1);
  yu = (int *)malloc(sizeof(unsigned long) * n);
  
  for(int i = 0; i < n+1; i++)
    scanf("%lu",&mon[i]);
  
  for(int i = 0; i < n; i++)
    scanf("%lu",&yu[i]);
  
  for(int i = 0; i < n; i++){
   	if( yu[i] <= mon[i] ){
    	teki += yu[i];
      	mon[i] -= yu[i];
      	continue;
    }else{
     	teki += mon[i];
      	yu[i] -= mon[i];
      	if( yu[i] >= mon[i+1] ){
          	teki += mon[i+1];
      	  	mon[i+1] = 0;
        }else{
          teki += yu[i];
          mon[i+1] -= yu[i];
        }
    }
  }
  
  
  printf("%lu",teki);
  
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
  // 整数の入力
  ll K;
  cin >> K;
  vector<vector<string>> RunRun(30,vector<string>());
  for(int i = 0;i< 10;i++){
    RunRun[0].push_back(to_string(i));
  }
  for(int i = 1;i<=10;i++){
    for(auto r:RunRun[i-1]){
      ll head = r[0] - '0';
      if (0 <= head + 1 && head + 1 <= 9 ){
        RunRun[i].push_back(to_string(head + 1) + r);
      }
      RunRun[i].push_back(to_string(head) + r);
      if (0 <= head - 1 && head - 1 <= 9 ){
        RunRun[i].push_back(to_string(head - 1) + r);
      }
    }
  }
  vector<ll> Numbers;
  for(int i = 0;i<=10;i++){
    for(auto r: RunRun[i]){
      if(r[0] != '0'){
        Numbers.push_back(stoll(r));
      }
    }
  }
  sort(Numbers.begin(),Numbers.end());
  cout << Numbers[K-1]<< endl;
  return 0;
}

Measured memory_bytes: 44652
from heapq import*
L,R=[],[]
B=t=0
Q,*E=open(0)
for e in E:
	if' 'in e:_,a,b=map(int,e.split());t=1-t;a*=2*t-1;c=heappushpop([L,R][t],a);heappush([R,L][t],-c);B+=b+a-c-c
	else:w=-L[0];print(w,B+w*t)

Measured memory_bytes: 28596
//****************************//
/**********  main *************/
//****************************//
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for(i = 0; i < n; i++)
#define FOR(i, a, b) for(i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())

double pi = 3.141592653589793;

int gcd(int a, int b) {
    if(a % b == 0) {
        return (b);
    } else {
        return (gcd(b, a % b));
    }
}

int main() {

    std::cin.tie(0);

    ll n;
    string ab = "zabcdefghijklmnopqrstuvwxyz";
    string res;

    ll i, tmp;
    bool flag = true;
    ll mod_tmp, div_tmp;

    cin >> n;

    div_tmp = n;

    while(flag) {
        mod_tmp = div_tmp % 26;
        div_tmp = div_tmp / 26;

        res = ab[mod_tmp] + res;

        if(div_tmp == 1 && mod_tmp == 0) {
            flag = false;
        }

        if(div_tmp <= 0) {
            flag = false;
        }

        // if(div_tmp > 26 && mod_tmp == 0) {
        //     div_tmp = div_tmp - 1;
        // }
        if(mod_tmp == 0) {
            div_tmp = div_tmp - 1;
        }
    }
    cout << res << endl;

    return 0;
}


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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int a, b;
	cin >> a >> b;
	int ans = 0;
	int kuchi = 1;
	while(kuchi < b){
		kuchi--;
		kuchi += a;
		ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<stack>
#include<cmath>
#include<queue>
#include<set>
#include<map>

using namespace std;

int main()
{
	string s;
	cin>>s;
	int loc = -1,sum = 0;
	for (int i=0;i<s.length()-1;i++)
	{
		if ((s[i]!='0') && ((s[i]-'0')+(s[i+1]-'0') <= (s[i]-'0')+8))
		{
			loc = i;
			sum += s[i]-'1';
			break;
		}
		else
			sum += s[i]-'0';
	}
	
	if (loc != -1)
		sum += (s.length()-loc-1)*9;
	else
		sum += s[s.length()-1]-'0';
	printf ("%d\n",sum);
	return 0;
}


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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

struct Solution
{
    Solution() {}
    void solveCase();
};

void Solution::solveCase()
{
    int n;
    cin >> n;
    vector<int> v;
    for (size_t i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        v.pb(x);
    }
    int res = 0;
    for (size_t i = 0; i < n; i++)
    {
        int x = v[i];
        for (size_t j = 0; j < i; j++)
        {
            if (x == v[j])
                continue;
            for (size_t z = 0; z < j; z++)
            {
                if (x == v[z])
                    continue;
                if (v[j] == v[z])
                    continue;
                if (v[j] + v[z] > x)
                    if (x + v[z] > v[j])
                        if (v[j] + x > v[z])
                            res++;
            }
        }
    }
    cout << res << '\n';
}

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


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

#define rep(a, b, c) for(int a = b; a < c; a++ )

using namespace std;

int main() {
    while (true) {
        int N, R;
        cin >> N >> R;
        if (N == 0 && R == 0) break;
        int yama[N];
        rep(i, 0, N) {
            yama[i] = N - i;
        }
        rep(i, 0, R) {
            int P, C;
            cin >> P >> C;
            int rem[C];
            rep(j, 0, C) {
                rem[j] = yama[j + P - 1];
            }
            for (int j = P - 2; j >= 0; j--) {
                yama[j + C] = yama[j];
            }
            rep(j, 0, C) {
                yama[j] = rem[j];
            }
        }
        cout << yama[0] << endl;
    }
    return 0;
}

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

using namespace std;

void dfs2(int v, vector<vector<int>>& graph, vector<int>& dist2, int d){
  int n = (int)graph.size();
  if(dist2[v] == -1) dist2[v] = d;
  else return;
  for(int i : graph[v]){
    dfs2(i, graph, dist2, d + 1);
  }
}

int dfs1(int u, vector<vector<int>>& graph, vector<int>& dist1, vector<int>& dist2){
  int n = (int)graph.size();
  
  stack<int> s;
  s.push(u);
  
  int max_dist = dist2[u];
  int max_dist_node = u;
  
  while(!s.empty()){
    int node = s.top();
    s.pop();
    for(int i : graph[node]){
      if(dist2[i] <= dist1[node] + 1) continue;
      if(dist1[i] != -1) continue;
      dist1[i] = dist1[node] + 1;
      if(max_dist < dist2[i]){
        max_dist = dist2[i];
        max_dist_node = i;
      }
      s.push(i);
    }
  }
  
  return max_dist_node;
}

int main(){
  int N;
  cin >> N;
  int u, v;
  cin >> u >> v;
  u--; v--;
  
  vector<vector<int>> graph(N);
  for(int i = 0; i < N - 1; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  
  vector<int> dist1(N, -1);
  vector<int> dist2(N, -1);
  dfs2(v, graph, dist2, 0);
  int max_dist_node = dfs1(u, graph, dist1, dist2);
  cout << dist2[max_dist_node] - 1 << endl;
  
  return 0;
}

Measured memory_bytes: 10368
#include<stdio.h>
#include<bits/stdc++.h>
#define f(a,b,c) for(register int a=(b);a<=(c);++a)
#define ff(a,b,c) for(register int a=(b);a>=(c);--a)
#define ll long long
//#define int long long
char pbuf[1<<20],*pp1=pbuf;
inline void push(char c){*pp1=c;pp1=(pp1-pbuf==(1<<20)-1)?(fwrite(pbuf,1,1<<20,stdout),pbuf):(pp1+1);}
#define pc push
//#define pc putchar
#define pe pc('\n')
#define ps pc(' ')
#define wer rd()
char *p1,*p2,buf[1<<20];
#define GC (p1==p2&&(p1=buf,p2=buf+fread(buf,1,1<<20,stdin),p1==p2)?0:(*(p1++)))
//#define GC getchar()
using namespace std;
inline ll wer{
	ll ans;char t,k;
	while(((t=GC)!='-')&&(t>'9'||t<'0'));
	k=(t=='-');
	ans=k?0:(t-'0');
	while((t=GC)>='0'&&t<='9')ans=ans*10+t-'0';
	return k?-ans:ans;
}
inline void wt(ll k)
{
	if(k<0)pc('-'),wt(-k);
	else
	{
		if(k<10)pc('0'+k);
		else wt(k/10),pc('0'+k%10);
	}
	return;
}

int n,a,b;
int ans[1000001];
void solve(int n,int a,int b,int *p)
{
	if(!n){p[0]=b;return;}
	if(n==1){p[0]=a,p[1]=b;return;}
//	cout<<"deafakioi\n"<<n<<" "<<a<<" "<<b<<"\n";
	int w=30;
	while((a&(1<<w))==(b&(1<<w)))w--;
//	cout<<w<<"\n";
	int aa=a%(1<<w);aa=(a>>1)-(a>>1)%(1<<w)+aa;
	int bb=b%(1<<w);bb=(b>>1)-(b>>1)%(1<<w)+bb;
	if(__builtin_popcount(aa)%2==1)
	solve(n-1,aa,0,p),solve(n-1,0,bb,p+(1<<n-1));
	else solve(n-1,aa,1,p),solve(n-1,1,bb,p+(1<<n-1));
	f(i,0,(1<<n-1)-1)
	{
		int x=p[i]%(1<<w);
		p[i]=(p[i]-x)<<1;p[i]+=x;
		if(a&(1<<w))p[i]+=(1<<w);
	}
	f(i,(1<<n-1),(1<<n)-1)
	{
		int x=p[i]%(1<<w);
		p[i]=(p[i]-x)<<1;p[i]+=x;
		if(b&(1<<w))p[i]+=(1<<w);
	}
	
	
}
main()
{
	n=wer,a=wer,b=wer;
	if(__builtin_popcount(a^b)%2==0)return cout<<"NO",0;
	cout<<"YES\n";
	solve(n,a,b,ans);	
	f(i,0,(1<<n)-1)cout<<ans[i]<<" ";
    fwrite(pbuf,1,pp1-pbuf,stdout);
    return 0;
}



Measured memory_bytes: 3712
#include<stdio.h>

int main(void){

   int a[3];
   int work;
   int i,j;


   scanf("%d %d %d",&a[0],&a[1],&a[2]);

   for(i=0;i<3;i++){
	   for(j=i;j<3;j++){
		   if(a[i] > a[j]){
			   work = a[i];
			   a[i] = a[j];
			   a[j] = work;
		   }
	   }
   }

   printf("%d %d %d\n",a[0],a[1],a[2]);
		   
   return 0;

}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple

int main(){
      string s;cin >> s;
      int n = s.length();
      set<char> sc;
      for(int i = 0;i < n;i++)sc.insert(s[i]);
      if(sc.size() == n)cout << "yes";
      else cout << "no";
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using E = System.Linq.Enumerable;

class Program
{
    static readonly double INF = double.PositiveInfinity;

    static void Main(string[] args)
    {
        while (true)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int N = input[0], M = input[1], P = input[2], A = input[3] - 1, B = input[4] - 1;
            if (N == 0) break;
            int[] nums = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            double[][] dist = E.Range(0, M).Select(i => E.Repeat(INF, M).ToArray()).ToArray();

            for (int i = 0; i < P; i++)
            {
                input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                dist[input[0] - 1][input[1] - 1] = input[2];
                dist[input[1] - 1][input[0] - 1] = input[2];
            }
            double[][] dp = E.Range(0, 1 << N).Select(i => E.Repeat(INF, M).ToArray()).ToArray();
            dp[0][A] = 0;
            for (int mask = 0; mask < (1 << N); mask++)
                foreach (int use in E.Range(0, N).Where(use => (mask >> use & 1) == 0))
                    for (int i = 0; i < M; i++)
                        for (int j = 0; j < M; j++)
                        {
                            double cost = dp[mask][i] + dist[i][j] / nums[use];
                            int nextMask = mask | 1 << use;
                            dp[nextMask][j] = Math.Min(dp[nextMask][j], cost);
                        }

            double ans = E.Range(0, 1 << N).Min(mask => dp[mask][B]);
            Console.WriteLine((ans > int.MaxValue) ? "Impossible" : ans.ToString("f3"));
        }
    }
}

Measured memory_bytes: 6404
#include <bits/stdc++.h>
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 ll INF = 1LL << 60;

bool is_palindrome(int x) {
    string num = to_string(x);
    for (int i = 0; i < 2; i++) {
        if (num[i] != num[4 - i]) return false;
    }

    return true;
}

int main() {
    int A, B; cin >> A >> B;
    
    int cnt = 0;
    for (int i = A; i <= B; i++) {
        if (is_palindrome(i)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
l = list(map(int,input().split()))
ans = 0
if l[0] == l[1] == l[2] and l[0] % 2 == 0:
  print(-1)
  exit()
while all(i % 2 == 0 for i in l):
  l[0], l[1], l[2] = l[1]//2 + l[2]//2, l[0]//2 + l[2]//2, l[0]//2 + l[1]//2
  ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/
bool cmp(pair<int64_t,int64_t> a,pair<int64_t,int64_t> b){
  if(a.first != b.first){
    return a.first < b.first;
  }else{
    return a.second > b.second;
  }
}


int main(){
  int64_t k;
  cin >> k;
  vector<int64_t> a(50);
  rep(i,50){
    a.at(i) = 49+(k/50);
    if(i < k%50){
      a.at(i) -= ((k%50)-1-50);
    }else{
      a.at(i) -= (k%50);
    }
  }
  cout << 50 << endl;
  rep(i,50){
    cout << a.at(i) << " ";
  }
  cout << endl;
      
    
  
}

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

int main(){
	vector<string> t;
	string s;
	int k;
	cin>>s>>k;
	
	for(int i=0; i<(signed)s.size(); i++){
		for(int j=1; j<=5; j++){
			t.push_back(s.substr(i,j));
		}
	}
	sort(t.begin(),t.end());
	unique(t.begin(),t.end());
	cout<<t[k-1]<<endl;
}


Measured memory_bytes: 1660
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)

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

// const int kMaxN;

int N, M;
ll ans;

int main() {
  cin >> N >> M;

  int a = MIN(N, M);
  int b = MAX(N, M);
  if (a == 1) {
    if (b == 1) {
      ans = 1;
    } else {
      ans = b-2;
    }
  } else {
    ans = (ll)(a-2) * (b-2);
  }

  cout << ans << endl;
  return 0;
}


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

#define rep(i, first, to) for(int i = first; i < to; ++i)

using namespace std;
typedef long long ll;

const int n = 'z' - 'a' + 1;
int alpha[n][2];

void solve() {

	string s;
	cin >> s;
	rep(i, 0, n) {
		alpha[i][0] = -1;
		alpha[i][1] = s.size() - 1;
	}
	rep(i, 0, n) {
		char c = i + 'a';
		int before = -1;
		rep(j, 0, s.size()) {
			if (s[j] == c) {
				alpha[i][0] = max(alpha[i][0], j - before - 1);
				alpha[i][1] = s.size() - j - 1;
				//cout << c << " : " << alpha[i][0] << ", " << alpha[i][1] << endl;
				before = j;
			}
		}
	}
	//cout << alpha[0][0] << ", " << alpha[0][1] << endl;
	int ans = max(alpha[0][0], alpha[0][1]);
	//cout << "a : " << ans << endl;
	rep (i, 1, n) {
		char c = i + 'a';
		ans = min(ans, max(alpha[i][0], alpha[i][1]));
		//cout << c << " : " << ans << endl;
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

	static BufferedReader reader;
	final static long MOD = 1000000000+7;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		int[] NK = readLineInt();
		int N = NK[0];
		int K = NK[1];
		
		long sum = 0;
		for(long k=K;k<=N+1;k++) {
			//add最小は0+1+2+...+(k-1)
			long min = ((k*(k-1))/2)%MOD;
			//add最大は(N-k+1)+...+(N) = (N-k+1)*k+sum(0,k)
			long max = ((N-k+1)*k)%MOD+((k*(k-1))/2)%MOD;
			
			sum = (sum+max-min+1+MOD)%MOD;
		}
		print(sum);
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


Measured memory_bytes: 32880
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
using namespace std;
char a[100],b[100];
int main()
{
	cin>>a+1;
	cin>>b+1;
	int n = strlen(a+1);
	int t = n; 
	int flag = 0;
	for(int i = 1; i <= n; i++){
		if(a[i] != b[t--])
			flag = 1;
	}
	if(flag) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)

int64_t fill_ones(int64_t a) {
  a |= a >> 1;
  a |= a >> 2;
  a |= a >> 4;
  a |= a >> 8;
  a |= a >> 16;
  a |= a >> 32;
  return a;
}

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

  vector<int64_t> a(N);
  rep(i, N) { cin >> a[i]; }

  int64_t u = a[0];
  int64_t A = a[0] + a[1];
  int64_t S = 0;
  for (int i = 2; i < N; i++) {
    S ^= a[i];
  }

  /*
  cerr << " u=" << bitset<41>(u) << " A=" << bitset<41>(A)
       << " S=" << bitset<41>(S) << endl;

  cerr << "S\t=" << bitset<41>(S) << endl
       << "u\t=" << bitset<41>(u) << endl
       << "S^u\t=" << bitset<41>(S ^ u) << endl
       << "(S^u)+u\t=" << bitset<41>((S ^ u) + u) << endl
       << "A\t=" << bitset<41>(A) << endl;
  //*/

  // a[0]+a[1]は最大で 41 桁
  const int M = 41;
  vector<vector<vector<int64_t>>> dp(
      M + 1, vector<vector<int64_t>>(2, vector<int64_t>(2, -1)));
  dp[0][false][false] = 0;
  rep(i, M) {
    int j = M - 1 - i;
    int64_t t = (S >> j) & 1;
    int64_t b = (A >> j) & 1;
    int64_t v = (u >> j) & 1;
    int64_t c = t ^ b;
    // cerr << "i=" << i << " S=" << t << " A=" << b << " u=" << v << " c=" << c
    //     << "\n";
    rep(lower, 2) rep(carry, 2) {
      rep(d, 2) {
        if ((d <= v || lower) && carry == ((t ^ d) + d + c) / 2) {
          chmax(dp[i + 1][d < v || lower][c], dp[i][lower][carry] * 2 + d);
        }
      }
    }
  }

  /*
  irep(i, M) {
    rep(lower, 2) rep(carry, 2) { cerr << setw(13) << dp[i][lower][carry]; }
    cerr << "\n";
  }
  //*/

  int64_t result = max(dp[M][false][false], dp[M][true][false]);
  cout << (result > 0 ? u - result : -1) << endl;

  return 0;
}

Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll INF = 1000000000000000000;

ll pow(ll a, ll n){
    ll res = 1;
    for (int i = 0; i < n; i++){
        res *= a;
    }
    return res;
}

int main(){
    ll n;
    cin >> n;
    ll a[n+1];
    rep(i, n + 1) cin >> a[i];
    ll node = 1;
    ll log[n+1];
    rep(i, n + 1){
        log[i] = node;
        if(i == n){
            if(node < a[i]){
                cout << -1 << endl;
                return 0;
            }
        }else{
            if(node <= a[i]){
                cout << -1 << endl;
                return 0;
            }
        }
        node -= a[i];
        node = min(INF, 2 * node);
    }
    ll ans = a[n];
    ll num = ans;
    for (int i = n - 1; i >= 0; i--){
        num = min(log[i], num + a[i]);
        ans += num;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5188
A, B, C, D, E, F = map(int,input().split())

ans = [0, 0, -1]
for a in range(1+F//A):
    for b in range(1+F//B):
        w = 100*A*a + 100*B*b
        if 0 < w < F:
            for c in range(1+(F-w)//C):
                for d in range(1+(F-w)//D):
                    s = C*c + D*d
                    if 0 < w + s <= F and s/w <= E/100:
                        if ans[2] < s/(w+s):
                            ans = [w+s,s,s/(w+s)]
print(*ans[:2])


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

int main() {
int h,w;
cin>>h>>w;
vector<string> vec(h+2);
for(int i =0;i<h;i++){
cin>>vec.at(i+1);}
string p;
p="";
for(int i =0;i<w+2;i++){
p+="#";}
vec.at(0)=p;
vec.at(h+1)=p;
for(int i =0;i<h;i++){
vec.at(i+1)="#"+vec.at(i+1)+"#";}
for(int i = 0;i<h+2;i++){
cout<<vec.at(i)<<endl;}
}




Measured memory_bytes: 3592
N = int(input())
C,S,F = [],[],[]
time = []
for i in range(N-1):
  c,s,f = map(int,input().split())
  C.append(c),S.append(s),F.append(f)
  
for i in range(N-1):
  t = S[i]+C[i] #駅i -> 駅i+1
  for j in range(i+1,N-1):
    if(t<S[j]): #始発前についたら
     t = S[j]
    else: #始発後についたら(次発以降のとき）
     #tmp = (t-S[j])%F[j]
     if(t%F[j] == 0): tmp = 0
     else: tmp = F[j]-(t%F[j]) 
     t += tmp
    t += C[j] #駅j -> 駅j+1
  time.append(t)
time.append(0)

for i in range(N):
 print(time[i])

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
    int n,m;
    cin >> n >> m;
    vector<ll> a[3];
    for(int i = 0;i < n;i++){
        for(int j = 0;j < 3;j++){
            ll tmp;
            cin >> tmp;
            a[j].push_back(tmp);
        }
    }
    
    ll ans = 0;
    for(int bit = 0;bit < (1<<3);bit++){
        vector<ll> v;
        for(int i = 0;i < n;i++){
            ll tmp2 = 0;
            for(int j = 0;j < 3;j++){
                if(bit&(1<<j)) tmp2 += a[j][i];
                else tmp2 -= a[j][i];
            }
            v.push_back(tmp2);
        }
        sort(v.begin(),v.end(),greater<ll>());
        ll sum = 0;
        for(int i = 0;i < m;i++) sum += v[i];
        ans = max(ans,sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>v(100005),sum(100005);
    rep(i,n)sum[a[i]]++;
    ll ans=1;
    rep(i,n){
        if(a[i])ans*=v[a[i]-1]-v[a[i]];
        else ans*=(3LL-v[0]);
        ans%=mod;
        v[a[i]]++;
    }
    cout<<ans<<"\n";
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 2688
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for i in range(n)]
ans = 10 ** 15
for i in range(2 ** n):
  rikai = [0] * m
  money = 0
  for j in range(n):
    if (i >> j) & 1:
      for k in range(m):
        rikai[k] += ca[j][k+1]
      money += ca[j][0]
  if min(rikai) >= x:
    ans = min(ans, money)
if ans == 10 ** 15:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long 
#define INF 1e9
#define LINF 1e18
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
 
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;
 
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
 
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, A[100000];
int lgcd[100000], rgcd[100000];

int gcd(int x, int y) {
	return y == 0 ? x : gcd(y, x % y);
}

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

    cin >> N;
    rep(i, N) cin >> A[i];
    lgcd[0] = A[0]; rgcd[N - 1] = A[N - 1];
    FOR(i, 1, N) lgcd[i] = gcd(lgcd[i - 1], A[i]);
    FORr(i, N - 2, 0) rgcd[i] = gcd(rgcd[i + 1], A[i]);
    int res = rgcd[1];
    FOR(i, 1, N - 1) chmax(res, gcd(lgcd[i - 1], rgcd[i + 1]));
    chmax(res, lgcd[N - 2]);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2560
Imports System.Collections.Generic
Module ProblemC

    Sub Main()
        Dim n As Integer = Integer.Parse(Console.ReadLine)
        Dim prm() As Integer
        Dim a As Integer
        Dim s As New Dictionary(Of Integer, Dictionary(Of Integer, Integer))
        Dim v(n) As Integer
        Dim i, j, vs As Integer
        Dim c As Boolean
        Dim ans As Integer = 0

        For i = 1 To n
            a = Integer.Parse(Console.ReadLine)
            s(i) = New Dictionary(Of Integer, Integer)
            If a > 0 Then
                For j = 1 To a
                    prm = Array.ConvertAll(Of String, Integer)(Console.ReadLine.Split(" "c), AddressOf Integer.Parse)
                    s(i).Add(prm(0), prm(1))
                Next
            End If
        Next

        For i = 1 To Convert.ToInt32(2 ^ n) - 1

            vs = 0
            For j = 1 To n
                v(j) = If(((i >> j - 1) And 1) = 1, 1, 0)
                vs += v(j)
            Next

            c = True
            For j = 1 To n
                If v(j) = 1 AndAlso s(j).Count > 0 Then

                    For Each k As KeyValuePair(Of Integer, Integer) In s(j)
                        If v(k.Key) <> k.Value Then
                            c = False
                            Exit For
                        End If
                    Next

                End If
                If Not c Then Exit For
            Next

            If c Then
                ans = Math.Max(ans, vs)
            End If

        Next

        Console.WriteLine(ans.ToString)
    End Sub

End Module


Measured memory_bytes: 15328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 1e5+5;
int main()
{
	int x,a,b;
	cin>>x>>a>>b; 
	if(abs(x-a)<abs(x-b)) cout<<"A";
	else cout<<"B"; 
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,dp[100001][13],MOD=1000000007;
    string S;
    cin >> S;
    for(int i=0;i<100001;i++)
        for(int j=0;j<13;j++)
            dp[i][j] = 0;
    dp[0][0] = 1;
    for(int i=1;i<=S.size();i++)
        for(int j=0;j<13;j++){
            if(S[i-1] == '?'){
                for(int k=0;k<=9;k++){
                    dp[i][((j*10)+k)%13] += dp[i-1][j];
                    dp[i][((j*10)+k)%13] %= MOD;
                }
            }else{
                dp[i][((j*10)+(S[i-1]-'0'))%13] += dp[i-1][j];
                dp[i][((j*10)+(S[i-1]-'0'))%13] %= MOD;
            }
        }
    cout << dp[S.size()][5] << endl;
    return 0;
}

Measured memory_bytes: 5504
#include <stdio.h>

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

    scanf("%d %d %d",&a, &b, &c);
    if(a == b && a != c) 
        printf("Yes\n");
    else if (b == c && b != a)
        printf("Yes\n");
    else if (c == a && c != b)
        printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int n;
    cin>>n;
    int s=n*n;//ans size
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    vector<tuple<int,int,int>>f(n),b(n);//queries
    rep(i,n){//answer 0-indexed
        get<0>(f[i])=a[i]-2;
        get<1>(f[i])=i;
        get<2>(f[i])=i+1;
        get<0>(b[i])=a[i];
        get<1>(b[i])=n-i-1;
        get<2>(b[i])=i+1;
    }
    vector<int>ans(s);
    rep(i,n)ans[a[i]-1]=i+1;
    //rep(i,s)cout<<ans[i];
    sort(all(f));
    sort(all(b),greater<tuple<int,int,int>>());
    //前後それぞれの条件を用意したので厳しいものから満たしていく
    int g,c,k;//goal,cap,number
    rep(i,n){
        g=get<1>(f[i]);
        c=get<0>(f[i]);
        k=get<2>(f[i]);
        //cout<<c<<g<<k<<endl;
        for(int j=0;j<=c;j++){
            if(g){
                if(ans[j]==0){
                    ans[j]=k;
                    g--;
                }
            }
            else break;
        }
        if(g){
            cout<<"No";
            return 0;
        }
    }
    rep(i,n){
        g=get<1>(b[i]);
        c=get<0>(b[i]);
        k=get<2>(b[i]);
        //cout<<c<<g<<k<<endl;
        for(int j=s-1;j>=c;j--){
            if(g){
                if(ans[j]==0){
                    ans[j]=k;
                    g--;
                }
            }
            else break;
        }
        if(g){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    rep(i,s)cout<<ans[i]<<' ';
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int max_price = 0;
    int total = 0;
    for (int i = 0; i < N; i++){
        int p;
        cin >> p;
        max_price = max(max_price, p);
        total += p;
    }
    cout << total - max_price / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define For(i,l,r)for(res i=(l),_=(r);i<=_;++i)
#define Dor(i,l,r)for(res i=(r),_=(l);i>=_;--i)
#define Sor(i,l,r)for(res i=(l),_=(r);i<_;++i)
#define ll long long
#define fz(a,b)memset(a,b,sizeof a)
#define N 100002
#define M 1000000007
struct node{
	int c,v;
	bool operator<(node a)const{
		return v==a.v?c<a.c:v<a.v;
	}
}nw;
priority_queue<node>Q;
int F[N];
int Fx(int x){
	return F[x]==x?x:F[x]=Fx(F[x]);
}
int main() {
	int a,b,x,y,w;
	cin>>a>>b;
	For(i,1,a)scanf("%d%d",&x,&y),Q.push({x,y});
	For(i,1,b+1)F[i]=i;
	while(!Q.empty()){
		nw=Q.top(),Q.pop();
		if(nw.c>b)continue;
		x=Fx(nw.c);
		if(x==b+1)continue;
		w+=nw.v,F[x]++;
	}
	cout<<w;
}

Measured memory_bytes: 1524
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int n = 0;
    int x = 0;
    int y = 0;

    for(;;){
        int a, b;
        char c;
        if(!(cin >> a >> c >> b))
            break;

        ++ n;
        x += a * b;
        y += b;
    }

    cout << x << endl;
    cout << (y+n/2)/n << endl;
    return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
	vector<int> dish(5);
	for (int i = 0; i < dish.size(); i++) {
		cin >> dish[i];
	}
	
	int ans = 0;
	while (dish.size() > 0) {
		int min_index = 0;
		for (int i = 1; i < dish.size(); i++) {
			if ((10 - dish[i] % 10) % 10 < (10 - dish[min_index] % 10) % 10) {
				min_index = i;
			}
		}
		ans += dish[min_index] + ((dish.size() > 1) ? (10 - dish[min_index] % 10) % 10 : 0);
		dish.erase(dish.begin() + min_index);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]
q = int(input())
m = [int(i) for i in input().split()]

ans = []
for i in range(1 << n):
    tmp = 0
    for j in range(n):
        if i >> j & 1:
            tmp += A[j]
    ans.append(tmp)

ans = set(ans)

for i in range(q):
    print("yes" if m[i] in ans else "no")



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

int i, ans;



int main() {


	while (true) {
		cin >> i;
		if (i == 0) break;
		i = 1000 - i;
		ans += i / 500;
		i %= 500;
		ans += i / 100;
		i %= 100;
		ans += i / 50;
		i %= 50;
		ans += i / 10;
		i %= 10;
		ans += i / 5;
		i %= 5;
		ans += i;
		cout << ans << endl;
		ans = 0;
	}


	return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[4],sum=0,m=0;
	for(int i=0;i<4;i++){
		cin >> a[i];
		sum=sum+a[i];
	}
	while(sum>=60){
		sum-=60;
		m++;
	}
	cout << m << endl;
	cout << sum << endl;
}
			
	 


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int, int>
#define pb push_back
#define int long long

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 10;
int arr[N], fen[N];
map<int, int> mp;

void upd(int p){
	for(p++; p<N; p+=p&-p)
		fen[p]++;
}

int get(int p){
	int ans = 0;
	for(; p>0; p-=p&-p)
		ans += fen[p];
	return ans;
}

main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, K; cin >> n >> K;
	ll sum = 0 , ans = 0;
	mp[0] = true;
	arr[0] = 0;
	for(int i=1; i<=n; i++){
		int v; cin >> v;
		sum += v;
		arr[i] = sum - 1LL * K * i;
		mp[arr[i]] = 0;
	}
	int cnt = 0;
	for(auto X : mp)
		mp[X.F] = cnt++;
	for(int i=0; i<=n; i++)
		arr[i] = mp[arr[i]];

	for(int i=0; i<=n; i++){
		ans += get(arr[i] + 1);
		upd(arr[i]);
	}

	cout << ans << endl;
}


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

using ll = long long;
using namespace std;

const ll MOD = 1000000007;

ll n, dp[4000][4000], sum[4000];
string s;

int main(){
    cin >> n >> s;
    rep(i,n) dp[0][i] = 1; // 先頭を選択し終えた状態
    rep(i,n-1){ //　不等号ごとにDPする
        // 累積和
        rep(j,n-i) sum[j+1] = ( dp[i][j] + sum[j] ) % MOD;
        // DP遷移
        if(s[i] == '>') rep(j,n-1-i) dp[i+1][j] = sum[j+1];
        else rep(j,n-1-i) dp[i+1][j] = ( sum[n-i] - sum[j+1] + MOD) % MOD;
    }
    cout << dp[n-1][0] << endl;
    return 0;
}

Measured memory_bytes: 50768
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

const int MAXN = 1e5 + 10;
int N, K;
vector<int> E[MAXN];
int ans;

inline int Dfs(int x) {
	int res = 1, d;
	for(register int i : E[x])
		(d = Dfs(i)) == K ? ++ans : res = max(res, d + 1);
	return res;
}

int main() {
	register int i; int x;
	scanf("%d%d", &N, &K);
	for(i = 1; i <= N; ++i)
		scanf("%d", &x),
		(i > 1) ? E[x].push_back(i), 0 : ans += x != 1;
	for(register int i : E[1]) Dfs(i);
	printf("%d\n", ans);
	return 0;
}

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

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

  long long ans=0;
  if(k==0) ans=(long long) n*n;
  else {
    for (int b = k+1; b <= n; b++)
    {
      int cnt = (n+1)/b*(b-k)+ max(0,(n+1)%b-k);
      ans+=(long long) cnt;
    }
  }
  cout << ans << endl;  
}

Measured memory_bytes: 256
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 20;

str s;

int main(){
	IOS;
	cin >> s;
	ll W = 0;
	for (int i = 0; i < s.size(); i++){
		if (s[i] == 'o') W++;
	}
	if (15 - s.size() + W >= 8) kill("YES");
	kill("NO");
	
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

constexpr int MAXN = 100005;
int n;
int a[MAXN];
bool hit[2][MAXN];
ll dp[2][MAXN];

ll solve(int k, int idx) {
    if (hit[k][idx])
        return dp[k][idx];

    if (idx == n - 1) {
        return k ? -a[idx] : a[idx];
    }

    // don't push
    ll no_push = (k ? -1 : 1) * a[idx] + solve(0, idx + 1);
    ll push = (k ? 1 : -1) * a[idx] + solve(1, idx + 1);
    hit[k][idx] = true;
    return dp[k][idx] = max(no_push, push);
}

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

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

    cout << solve(0, 0) << '\n';
    
    return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	ll n, d;
	cin >> n >> d;

	int ans = 0;
	rep(i, n){
		ll x, y;
		cin >> x >> y;

		if((x*x + y*y) <= d*d ) ans++;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
void selectionSort(int*,int);
int main(){
  int array[100],N;
  int i;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&array[i]);
  selectionSort(array,N);
  return 0;
}
void selectionSort(int *A,int N){
  int i,j,minj,keep,count=0;
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j]<A[minj])
	minj=j;
    }
    if(minj!=i){
      keep=A[i];
      A[i]=A[minj];
      A[minj]=keep;
      count++;
    }
  }
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[N-1]);
  printf("%d\n",count);
}

Measured memory_bytes: 600