akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    while(true){
        int n;
        cin>>n;
        if(n==0) break;
        int a[1000];
        int sum=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n;i++){
            sum+=a[i];
        }
        double average =1.0*sum/n;
        double dispersed = 0.0;
        for(int i=0;i<n;i++){
            dispersed += (a[i]-average)*(a[i]-average);
        }
        cout<<fixed<<setprecision(8)<<sqrt((dispersed/n))<<'\n';

    }
    
}


Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll sx,sy,tx,ty;
    cin >>sx>>sy>>tx>>ty;
    rep(i,tx-sx){
        cout<<'R';
    }
    rep(i,ty-sy){
        cout<<'U';
    }
    rep(i,tx-sx){
        cout<<'L';
    }
    rep(i,ty-sy){
        cout<<'D';
    }
    cout<<'D';

    rep(i,tx-sx+1){
        cout<<'R';
    }

    rep(i,ty-sy+1){
        cout<<'U';
    }
    cout<<'L';
    cout<<'U';
    rep(i,tx-sx+1){
        cout<<'L';
    }
    rep(i,ty-sy+1){
        cout<<'D';
    }
    cout<<'R';
    cout  << endl;


    return 0;
    

}

Measured memory_bytes: 3564
N = int(input())
num_line = [0] + list(map(int, input().split()))
for i in range(N//2, 0, -1):
    num_line[i] = sum(num_line[i::i]) % 2
    #if sum(num_line[i::i]) % 2 != num_line[i]:
        #num_line[i] = 1
ans = [i for i, j in enumerate(num_line) if j == 1]
print(len(ans))
#print(" ".join(map(str, list(i for i in range(1, N+1) if num_line[i] == 1))))
print(*ans)


Measured memory_bytes: 12724
H, W = map(int, input().split())

l=[]
for i in range(H):
    l.append(list(input()))

for i in range(H):
    for j in range(W):
        #地雷数のカウンタ
        c = 0

        #'#'の場合は何もしない
        if l[i][j]=='#':
            pass
        
        #'#'以外の場合
        else:
            #左上
            if 0<i and 0<j and l[i-1][j-1]=='#':
                c+=1
            #上
            if 0<i and l[i-1][j]=='#':
                c+=1
            #右上
            if 0<i and j<W-1 and l[i-1][j+1]=='#':
                c+=1
            #左
            if 0<j and l[i][j-1]=='#':
                c+=1
            #右
            if j<W-1 and l[i][j+1]=='#':
                c+=1
            #左下
            if i<H-1 and 0<j and l[i+1][j-1]=='#':
                c+=1
            #右下
            if i<H-1 and j<W-1 and l[i+1][j+1]=='#':
                c+=1
            #下
            if i<H-1 and l[i+1][j]=='#':
                c+=1

            #地雷接数
            l[i][j]=str(c)

#出力
for i in range(H):
    print(''.join(l[i]))



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

 int main(){
  int n;
  cin>>n;
  if(n%2==0)
    cout<<fixed<<setprecision(10)<<(double)(n/2)/n<<endl;
  else
    cout<<fixed<<setprecision(10)<<(double)(n/2+1)/n<<endl;
  return 0;
 }


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

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

int main()
{
	int px[256],py[256];
	rep(i,3)rep(j,3)px['A'+i*3+j]=j,py['A'+i*3+j]=i;
	
	int n;
	while(cin>>n,n)
	{
		double p[20][3][3]; rep(i,n+1)rep(j,3)rep(k,3)p[i][j][k]=0;
		char s,t,b; cin>>s>>t>>b;
		int bx=px[b],by=py[b];
		
		p[0][py[s]][px[s]]=1;
		rep(i,n)rep(j,3)rep(k,3)rep(d,4)
		{
			int ny=j+dy[d],nx=k+dx[d];
			if(ny<0||nx<0||ny>=3||nx>=3 || ny==by&&nx==bx)ny=j,nx=k;
			p[i+1][ny][nx]+=p[i][j][k]/4;
		}
		
		printf("%.8f\n",p[n][py[t]][px[t]]);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include	<cstdint>
#include	<iostream>
#include	<fstream>
#include	<deque>
#include	<string>
#include	<sstream>
#include	<tuple>

typedef		std::uint_least16_t		USI;
typedef		std::int_least16_t		SSI;
typedef		std::uint_least32_t		ULI;		//10^9
typedef		std::int_least32_t		SLI;
typedef		std::uint_least64_t		ULLI;
typedef		std::int_least64_t		SLLI;

using namespace std;

int main()
{
	//1???????????????
	string			str;
	string			item;
	getline(cin, str);
	stringstream	sstrm(str);

	deque<int>		st;
	int				f, d;

	auto	GetTop2 = [&]() -> tuple<int, int>
	{
		int v = st.front();
		st.pop_front();
		int w = st.front();
		st.pop_front();

		return (forward_as_tuple(v, w));
	};

	while (getline(sstrm, item, ' '))
	{
		switch (item[0])
		{
		case '+':
			tie(f, d) = GetTop2();
			st.push_front(f + d);
			break;
		case '-':
			tie(f, d) = GetTop2();
			st.push_front(d - f);
			break;
		case '*':
			tie(f, d) = GetTop2();
			st.push_front(f * d);
			break;
		default:
			f = stol(item);
			st.push_front(f);
			break;
		}
	}

	cout << st.front() << "\n";

	return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
#include <sstream>
#include <bitset>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
    vector<char> s;
	ll n;
    cin >> n;
    while(n > 0) {
        if(n % 26 == 0)  { s.push_back('z'); n--; }
        else s.push_back((char)((n % 26) + 96));
        n = n/26;
    }
    reverse(s.begin(), s.end());
    for (const auto& e : s) {
      cout << e;
    }

    cout << endl;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int h, w, k;
	cin >>h >> w >>k;
	vector<string> ba(h);
	rep(i, h) cin >>ba[i];
	
	vector<VI> p(h, VI(w));
	int c=1;
	rep(i,h) rep(j,w) if(ba[i][j]=='#') p[i][j] = c++;
	
	rep(i,h){
		rep(j, w-1){
			if(p[i][j]!=0 && p[i][j+1]==0) p[i][j+1] = p[i][j];
		}
		repr(j, w-1, 1){
			if(p[i][j]!=0 && p[i][j-1]==0) p[i][j-1] = p[i][j];
		}
	}
	
	rep(i, h-1){
		if(p[i][0]!=0 && p[i+1][0]==0){
			rep(j, w) p[i+1][j] = p[i][j];
		}
	}
	
	repr(i, h-1, 1){
		if(p[i][0]!=0 && p[i-1][0]==0){
			rep(j, w) p[i-1][j] = p[i][j];
		}
	}
	for(auto xl: p){for(auto x :xl) cout<<x<<" "; cout<<"\n";}
	
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(){
	int n, m;
	cin >> n >> m;
	char a[n*m*2];
	int count = 0;
	for(int i = 0; i < n*m*2; i++){
		cin >> a[i];
	}
	for(int j = 0; j < n*m; j++){
		if(a[j] != a[j+n*m])count++;
	}
	cout << count << endl;
	return 0;
}



Measured memory_bytes: 10884
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;

//素数判定
bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
int GetDigit(int num) {
	return (int)log10(num) + 1;
}

int main() {
	int ans = 0;
	int N;

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}

	cout << ans << endl;

	return 0;
}

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

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

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
struct Seed {
	string name;
	int p, a, b, c, d, e, f, s, m;
	bool operator <(Seed b) {
		if(this->income()*b.time() == b.income()*this->time())return this->name>b.name;
		return this->income()*b.time() < b.income()*this->time();
	}

private :
	int income() {
		return 	f*s*m-p;
	}
	int time() {
		return a + b + c + m*(d + e);
	}
};
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n;
		cin >> n;
		if (!n)break;
		vector<Seed> v(n);
		REP(i, n) {
			cin >> v[i].name >> v[i].p >>v[i].a>> v[i].b >> v[i].c >> v[i].d >> v[i].e >> v[i].f >> v[i].s >> v[i].m;
		}
		sort(ALL(v));
		RREP(i, n)cout << v[i].name << endl;
		cout << '#' << endl;
	}
	return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
#define maxn 100005
#define MOD 998244353
using namespace std;
#define ll long long

#define pii pair<ll, ll>
#define piii pair<ll, pii>

#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}


ll power(ll a, ll b){
    if(b==0) return 1;
    ll R =1, k=a;
    for (ll j=b;j>0;j/=2){
        if (j&1) R=(R*k)%MOD;
        k=(k*k)%MOD;
    }
    return R;
}

void solve(){

    string s;
    cin >> s;
    ll q;
    cin >> q;
    ll t1 = 0, t2 = 0;
    char a;
    while(q--){
        ll x; cin >> x;
        if(x == 1) t1++;
        else {
            ll y; cin >> y >> a;
            if(y == 1){
                if(t1%2 == 0) s.insert(s.begin(), a);
                else s.insert(s.begin() + s.size(), a);
            }
            else{
                if(t1%2 == 1) s.insert(s.begin(), a);
                else s.insert(s.begin() + s.size(), a);
            }
        } //cout << s << endl;
    }
    if(t1%2==1) reverse(s.begin(), s.end());
    cout << s ;
}
void solve2(){

    string s;
    cin >> s;
    ll q;
    cin >> q;
    ll t1 = 0, t2 = 0;
    char a;
    while(q--){
        ll x; cin >> x;
        if(x == 1) reverse(s.begin(), s.end());
        else {
            ll y; cin >> y >> a;
            if(y == 1){
                s.insert(s.begin(), a);
                //else s.insert(s.end()-1, a);
            }
            else{
                s.insert(s.begin() + s.size(), a);
            }
        } //cout << s << endl;
    }
    //if(t1%2==1) reverse(s.begin(), s.end());
    cout << s ;
}
int main()
{


    ll t = 1;//cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 900
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

vector<bool> ok;
bool bellmanford(int s, int N, vector<vector<pair<int, int>>>& graph, vector<int>& d){
  d = vector<int>(N, INF);
  d[s] = 0;
  for(int i = 0; i < N; i++){
    for(int v = 0; v < N; v++){
      if(!ok[v]) continue;
      for(int k = 0; k < (int)graph[v].size(); k++){
        pair<int, int> e = graph[v][k];
        if(d[v] != INF && d[e.first] > d[v] + e.second){
          d[e.first] = d[v] + e.second;
          if(i == N-1) return true;
        }
      }
    }
  }
  return false;
}

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

  vector<vector<int>> back(N);
  vector<vector<pair<int, int>>> graph(N);
  REP(i, M){
    int u, v, d;
    cin >> u >> v >> d;
    u--; v--;
    graph[u].emplace_back(v, -d);
    back[v].emplace_back(u);
  }

  ok.resize(N, false);
  ok[N-1] = true;

  queue<int> q;
  q.push(N-1);

  while(!q.empty()){
    int v = q.front(); q.pop();
    for(auto u : back[v]){
      if(ok[u]) continue;
      ok[u] = true;
      q.push(u);
    }
  }

  vector<int> dist(N);
  if(bellmanford(0, N, graph, dist)){
    cout << "inf" << "\n";
  }else{
    cout << -dist[N-1] << "\n";
  }

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll a, b, k;
  cin >> a >> b >> k;
  if (a >= k)
  {
    cout << a - k << " " << b << endl;
  }
  else if (a + b < k)
  {
    cout << "0 0" << endl;
  }
  else
  {
    cout << "0 " << b - (k - a) << endl;
  }
}


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

int main()
{
  int A, B;
  string S;
  cin >> A >> B >> S;
  string ans = "Yes";
  rep(i, A + B + 1)
  {
    if (i != A && S[i] == '-')
      ans = "No";
    if (i == A && S[i] != '-')
      ans = "No";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	int N;
	cin >> N;
	vector<int> C(N), F(N), S(N), T(N);
	rep(i, 0, N - 1)cin >> C[i] >> S[i] >> F[i];
	rep(i, 0, N - 1) {
		int p = i;
		T[i] = S[i] + C[i];
		while (++p != N - 1) {
			if (S[p] <= T[i]) {
				T[i] = ((T[i] - 1) / F[p] + 1) * F[p];
				T[i] += C[p];
			}
			else T[i] = S[p] + C[p];
		}
	}
	rep(i, 0, N) {
		printf("%d\n", T[i]);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;
int main(){
  int n, a;
  cin >> n;
  vector<int> v, w;
  for(int i=0; i<n; i++){
    cin >> a;
    v.push_back(a);
    w.push_back(a);
  }
  sort(v.begin(), v.end(), greater<int>());
  int max1=v[0], max2=v[1];
  for(int i=0; i<n; i++){
    if(w[i]==max1) cout << max2 << endl;
    else cout << max1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3436
#058-D
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
sx=0
sy=0
for i in range(n):
    sx+=i*x[i]-(n-i-1)*x[i]
for i in range(m):
    sy+=i*y[i]-(m-i-1)*y[i]
sx=sx%(10**9+7)
sy=sy%(10**9+7)
ans=sx*sy%(10**9+7)
print(ans)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    string s;cin >> s;
    int a = 0;
    if(s=="SUN") a=7;
    else if(s=="MON") a=6;
    else if(s=="TUE") a=5;
    else if(s=="WED") a=4;
    else if(s=="THU") a=3;
    else if(s=="FRI") a=2;
    else if(s=="SAT") a=1;
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main() {
    int N, max = 0, H, prevH = 0, cnt = 0;
    scanf("%d%*c", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d%*c", &H);
        if (H <= prevH) cnt++;
        else {
            if (cnt > max) max = cnt;
            cnt = 0;
        }
        prevH = H;
    }
    if (cnt > max) max = cnt;
  	printf("%d\n", max);
}


Measured memory_bytes: 128
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    map<int, int> mp;
    set<int> st;
    for(int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        st.insert(a);
        mp[a]++;

    }

    vector<P> v;
    for(auto p = st.begin(); p != st.end(); ++p) {
        v.pb(MP(*p, mp[*p]));

    }

    int res = 0;
    for(int i = 0; i < v.size(); ++i) {
        if(v[i].F < v[i].S) {
            res += v[i].S - v[i].F;

        } else if(v[i].F > v[i].S) {
            res += v[i].S;

        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long



int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int X;
	cin >> X;
	int actu = 100;
	int in = 0;
	while (actu < X)
	{
		actu += (actu / 100);
		in++;
	}
	cout<<in<<endl;
}

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


int main()
{
	int A, B,C;
	cin  >> A >> B>>C;
	if (C>=A&&C<=B) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
    return 0;
}

Measured memory_bytes: 256
h,w,m=map(int,input().split())
sumw=[set() for _ in range(w)]
sumh=[0]*h
for _ in range(m):
    hi,wi=map(int,input().split())
    hi-=1
    wi-=1
    sumh[hi]+=1
    sumw[wi].add(hi)
maxi=0
for i in range(w):
    maxi=max(maxi,len(sumw[i]))
s=set([i for i in range(h)])
for i in range(w):
    if len(sumw[i])==maxi:
        s=s&sumw[i]
ans=0
#print(sumw)
for i in range(h):
    if i not in s:
        ans=max(ans,sumh[i]+maxi)
    else:
        ans=max(ans,sumh[i]+maxi-1)
print(ans)

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

using namespace std;
 
 

typedef long long ll;
//c++ templte for help............................................................................................................................................


template<typename... T>
void print1(T... t){
	((cout<<t<<" "),...);
}

template<typename... T>
void print2(T... t){
		vector<vector<ll>> ans={t...};
		for(ll i=0;i<(ll)ans.size();i++){
			if(i!=0) cout<<"\t\t";
			else cout<<"\t";
			for(ll j=0;j<(ll)ans[i].size();j++){
				cout<<ans[i][j]<<" ";
			}
			if(i!=(ll)ans.size()-1)
			cout<<endl;
		}
}	
#define deb(...) cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; 
#define vdeb(...) cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;





	
 
//for loop
//#define fo(i,n) for(int i=0;i<(ll)n;i++)
//#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
//template<typename T>
//void printV(T vec){
	//fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	//cout<<endl;
	//}
	
 
#define M int(1e9+7)
const int INF=1e9+5;
 
//iterate map
//template<typename T>
//void itR(T map){
	 //for(auto itr=map.begin();itr!=map.end();itr++){
				//deb(itr->first,itr->second);
			//}
	//cout<<endl;
//}


 

 
//c++ template for help...........................................................................................................................................

ll pow_10(ll i,ll m){
	ll a=10;
	ll b=i;
	ll ans=1;
	//deb(a,b);
	while(b!=1){
		if(b%2==0){
			b=b/2;
			a=((a%m)*(a%m))%m;
		}else{
			ans=((ans%m)*(a%m))%m;
			b--;
		}
	}
	return a*ans;
}

ll solve(){
	ll n;
	cin>>n;
	
	if(n==7 or n==1) return 1;
	set<ll> same;
	ll sum=7%n;
	ll i=1;
	while(true){
		sum=(sum%n+(7*pow_10(i,n))%n)%n;
		//sum=(sum%n+(7*(ll)pow((ll)10,(ll)i))%n)%n;
		if(same.count(sum)!=0) break;
		else if(sum==0) return i+1;
		same.insert(sum);
		i++;
	}
	return -1;
}


int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	//ofstream myfile;
	//myfile.open ("output.txt");
	

	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		//solve();
		ll ans=solve();
		cout<<ans<<endl;
	//}
	//myfile.close();
	return 0;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) {
        printf("No\n");
        return 0;
    }
    if (a == b || b == c || a == c)
        printf("Yes\n");
    else
        printf("No\n");
}

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

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

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

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX_N 200000
#define INF 10000000000000000LL

long long s[MAX_N];

long long min(long long p, long long q)
{
    return p < q? p: q;
}

long long abs(long long p)
{
    return p >= 0? p: -p;
}

int main(void)
{
    int n, a;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a);
        s[i] = (long long)a;
        if (i != 0) s[i] += s[i - 1];
    }
    long long sum = s[n - 1];
    long long mini = INF;
    if (n == 2) {
        mini = abs(sum - 2LL * s[0]);
    }
    else {
        for (int i = 1; i < n - 1; i++)
            mini = min(mini, abs(sum - 2LL * s[i]));
    }
    printf("%lld\n", mini);
    return 0;
}


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

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

	int n,m,k,j;
	cin>>n>>m;
	int a[m+1];
	for(int i=1;i<=m;i++){
		a[i]=0;
	}
	for(int i=0;i<n;i++){
		cin>>k;
		while(k--){
			cin>>j;
			a[j]+=1;
		}
	}
	int c=0;
	for(int i=1;i<=m;i++){
		if(a[i]==n) c+=1;
	}
	cout<<c<<"\n";
	return 0;
}

Measured memory_bytes: 256
# 二項係数を"やるだけ"にしてくれるライブラリ
MAX = 1000005
MOD = 10**9+7
factrial = [0]*MAX
inverse = [0]*MAX
factrial_inverse = [0]*MAX


# テーブルを作る前処理
def COMinit():
    global factrial, inverse, factrial_inverse
    factrial[0] = 1
    factrial[1] = 1
    inverse[1] = 1
    factrial_inverse[0] = 1
    factrial_inverse[1] = 1
    for i in range(2, MAX):
        factrial[i] = factrial[i-1] * i % MOD
        inverse[i] = MOD - inverse[MOD % i] * (MOD//i) % MOD
        factrial_inverse[i] = factrial_inverse[i-1] * inverse[i] % MOD


# 二項係数計算
def COM(n, k):
    global factrial, inverse, factrial_inverse
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return factrial[n] * (factrial_inverse[k] * factrial_inverse[n-k] % MOD) % MOD


# 前処理完了
COMinit()
N = int(input())
A = list(map(int, input().split()))

primes = {}

for val in A:
    p = 2
    while val >= p * p:
        if val % p == 0:
            # 割り切れるならそこから話が始まる
            cnt = 0
            while val % p == 0:
                cnt += 1
                val //= p
            if p not in primes:
                primes[p] = cnt
            else:
                primes[p] = max(cnt, primes[p])
        p += 1
    if val != 1:
        if val not in primes:
            primes[val] = 1

lcm = 1
for p, cnt in primes.items():
    lcm *= p ** cnt
    lcm %= MOD

ans = 0
for val in A:
    ans += lcm * inverse[val]
    ans %= MOD
print(ans)


Measured memory_bytes: 68188
import sys
def I(): return int(sys.stdin.readline().rstrip())

K = I()

Graph = [0]*K
for i in range(K):
    if (i+1) % K != (10*i) % K:
        Graph[i] = [(1,(i+1) % K),(0,(10*i) % K)]  # 1を加える,10倍する
    else:
        Graph[i] = [(0,(10*i) % K)]

# dijkstra

from heapq import heappush,heappop

d = [100]*K
d[1] = 1
q = []
heappush(q,(1,1))
v = [False]*K
while q:
    a,n = heappop(q)
    if v[n]:
        continue
    v[n] = True
    for da,dn in Graph[n]:
        if v[dn]:
            continue
        if a+da < d[dn]:
            d[dn] = a+da
            heappush(q,(a+da,dn))

print(d[0])


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // Another formulation: Given a random placement what is the expected value of:
    // \sum_{i < j} dist(p[i], p[j])
    // and then multiply with \binom{n*m}{k}.
    // The same as:
    // \sum_{p_1 < p_2} dist(p_1, p_2) \cdot P(p_1 and p_2 chosen)
    // We have P(p_1 and p_2) chosen = \binom{n*m-2}{k-2}/\binom{n*m}{k}
    // So the final sum we are looking at is:
    // \binom{nm-2}{k-2} \cdot \sum_{p_1 < p_2} dist(p_1, p_2)
    // Now what is \sum_{p_1 < p_2} dist(p_1, p_2)? It's the same as:
    // \frac{1}{2} \sum_{(x_0, y_0) != (x_1, y_1)} \abs{x_0-x_1} + \abs{y_0-y_1}
    // Which is the same as:
    // \frac{1}{2} \sum_{x_0, x_1, y_0, y_1} (\abs{x_0-x_1} + \abs{y_0-y_1})
    // Now we have:
    // \frac{1}{2} \sum_{x_0, x_1, y_0, y_1} \abs{x_0-x_1}
    // =
    // \frac{m^2}{2} \sum_{x_0, x_1} \abs{x_0-x_1}
    // Now let f(n) = \sum_{0 <= x_0, x_1 < n} \abs{x_0-x_1}
    // Then f(n+1) = f(n) + (1 + ... + n)*2 = f(n) + n*(n+1)
    // This fits since:
    // f(0) = 0
    // f(1) = 0
    // f(2) = 2 = 0 + 1*2
    // f(3) = 8 = 2 + 2*3, etc.
    // So we have that f(n) = 2\binom{n}{2} + ... + 2\binom{2}{2} = 2\binom{n+1}{3}
    // This also fits since:
    // f(2) = 2 = 2\binom{3}{3}
    // f(3) = 8 = 2\binom{4}{3}, etc.
    // So the final formula is:
    // \binom{nm-2}{k-2} \cdot \left ( m^2 \binom{n+1}{3} + n^2 \binom{m+1}{3} \right )
    long long prime = 1000000007;
    function<long long (long long, long long)> pow = [&](long long a, long long r) {
        if (r == 0) {
            return 1LL;
        }
        long long y = pow(a, r/2);
        long long z = (y*y) % prime;
        return r % 2 == 1 ? (a*z) % prime : z;
    };
    auto inv = [&](long long a) {
        return pow(a, prime-2);
    };
    auto down_to = [&](long long n, long long r) {
        // Calculates n(n-1)...(n-r+1)
        long long product = 1;
        while (r > 0) {
            product = (product * n) % prime;
            --n;
            --r;
        }
        return product;
    };
    auto binom = [&](long long n, long long k) {
        return (down_to(n, k) * inv(down_to(k, k))) % prime;
    };
    long long N, M, K;
    cin >> N >> M >> K;
    long long result = binom(N*M-2, K-2) * ( M * M % prime * binom(N+1, 3) % prime + N * N % prime * binom(M+1, 3) % prime) % prime;
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// C - Bugged
int N;
int s[110];
bool dp[10100][110];
int ans = 0;

int main(){
    cin >> N;
    rep(i, 0, N){
        cin >> s[i];
    }
    rep(i, 0, 10010){
        rep(j, 0, 110){
            dp[i][j] = false;
        }
    }
    dp[0][0] = true;

    rep(i, 0, N){
        rep(j, 0, 10001){
            if(dp[j][i]){
                dp[j][i+1] = true;
                dp[j+s[i]][i+1] = true;
            }
        }
    }

    per(i, 0, 10001){
        if(i%10!=0 && dp[i][N]){
            ans = max(ans, i);
        }
    }

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




Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,count1=0,count2=0,count3=0,count4=0;
  string result;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> result;
    if(result == "AC"){
      count1 ++;
    }
    else if(result =="WA"){
      count2 ++;
    }
    else if(result == "TLE"){
      count3 ++;
    }
    else if(result == "RE"){
      count4 ++;
    }
  }
  cout << "AC x " << count1 << endl;
  cout << "WA x " << count2 << endl;
  cout << "TLE x " << count3 << endl;
  cout << "RE x " << count4 << endl;
  return 0;
}

Measured memory_bytes: 3616
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;


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

	cin >> N >> M >> H >> W >> L >> R;
	bool dp[31] = {};
	for (int i = 0; i <= 30; i += N) {
		dp[i] = true;
	}
	for (int i = 0; i <= 30; i++) {
		if (dp[i]) {
			for (int j = 0; i + j <= 30; j += M) {
				dp[i + j] = true;
			}
		}
	}
	bool beet[3001] = {};
	for (int i = 0; i <= 3000; i += H) {
		beet[i] = true;
	}
	for (int i = 0; i <= 3000; i++) {
		if (beet[i]) {
			for (int j = 0; i + j <= 3000; j += W) {
				beet[i + j] = true;
			}
		}
	}
	long double box = -1;
	int water = 0;
	int sugar = 0;
	for (int i = 1; i <= 30; i++) {
		if (dp[i]) {
			for (int j = 0; j <= 3000; j++) {
				if (beet[j]) {
					if (i * 100 + j <= R&&j <= i  * L) {
						if (100 * j <= L*(i * 100 + j)) {
							if (box < (long double)100 * j / ((long double)i * 100 + j)) {
								box = (long double)100 * j / ((long double)i * 100 + j);
								water = i * 100;
								sugar = j;
							}
						}
					}
				}
			}
		}
	}
	cout << water+sugar << " " << sugar << endl;
	return 0;
}

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

class Program
{
    struct Connection {
        public List<long> list;
        public Connection(int index)
        {
            list = new List<long>();
        }
    }
    
    static void Main()
    {
        var nk = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var N = nk[0];
        var K = nk[1];

        var connection = new Connection[N];
        for (int i = 0; i < N; ++i) connection[i] = new Connection(i);
        for (int i=0;i<N-1;++i)
        {
            var ab = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
            connection[ab[0] - 1].list.Add(ab[1]-1);
            connection[ab[1] - 1].list.Add(ab[0] - 1);
        }

        var combination = new long[N];
        combination[0] = K;
        var queue = new Queue<long[]>();
        queue.Enqueue(new long[2] { -1, 0 });
        while (0 < queue.Count)
        {
            var current = queue.Dequeue();
            var parent = current[0];
            var node = current[1];
            var k = parent < 0 ? K - 1 : K - 2;
            foreach (var l in connection[node].list)
            {
                if (l == parent) continue;
                combination[l] = k;
                k--;
                queue.Enqueue(new long[2] { node, l });
            }
        }

        var ans = 1L;
        const long mod = 1000000007;
        foreach (var c in combination)
        {
            ans = (ans * c) % mod;
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 38900
#include <iostream>
#include <string>

using namespace std;
int main(){
  string str;
  while(getline(cin,str)){
    int cnt = 0;
    int f = 1;
    str+='.';
    for(int i = 0 ; i < str.size() ; i++ ){

      if(str[i] == ',' || str[i] == '.' || str[i] == ' '){
	if(3<=cnt && cnt < 7){
	  if(f == 1){
	    cout << str.substr(i-cnt,cnt);
	    f = 0;
	      } else cout <<" "<< str.substr(i-cnt,cnt);
	}
	cnt = 0;
      }else cnt++;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#include<stdio.h>
long long CO[200010];
long long R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(long long a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
void dijk(int v,int e,int *fr,int *to,int *co,int mi){
  int i,id[200010],ta[200010],nt[200010],f[200010]={0};
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<v;i++)CO[i]=1e18+10;
  for(i=CO[mi]=0;i<e;i++){
    nt[i]=ta[fr[i]];
    ta[fr[i]]=i;
  }
  while(f[mi]-1){
    f[mi]=1;
    for(i=ta[mi];i+1;i=nt[i]){
      if(CO[to[i]]>CO[mi]+co[i])hin(CO[id[R]=to[i]]=CO[mi]+co[i]);
    }
    while(f[mi]&&C-1)mi=id[hout()];
  }
}
int main(){
  int n,m,i,r=0,a[200010],b[200010],c[200010];
  scanf("%d %d",&n,&m);
  for(i=1;i<n;i++){
    a[r]=i+1;
    b[r]=i;
    c[r++]=0;
  }
  for(i=0;i<m;i++){
    scanf("%d %d %d",&a[r],&b[r],&c[r]);
    r++;
  }
  dijk(n+1,r,a,b,c,1);
  printf("%lld\n",CO[n]>1e17?-1:CO[n]);
  return 0;
}


Measured memory_bytes: 11008
#include <stdio.h>
void ppp(int arr[], int size){
    int i, j, counter;
    int key = 0;
    for(i=1; i<size+1; i++){
        for(counter=0; counter<size; counter++){
            if(counter>0) printf(" ");
            printf("%d",arr[counter]);
        }
        printf("\n");
        key = arr[i];
        j = i-1;
        while(j>=0 && arr[j]>key){
            arr[j+1] = arr[j];
            j--;
        }

        arr[j+1] = key;
    }
}
int main()
{
    int N;
    scanf("%d", &N);
    if(N<1 || N>100){
        return 0;
    }
    else{
        int arr[N];
        int k = 0;
        for(k=0; k<N; k++){
            scanf("%d",&arr[k]);
        }
        ppp(arr, N);
        //printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e5+10;
const ll mod =   1e9+7;
ll n;
bool check(ll x,ll y){
	while(x%10==0){
		x/=10;
	}while(y%10==0){
		y/=10;
	}
	if(x>1||y>1)return true;
	return false;
}
ll cnt(ll x,ll y){
	ll cnt1=0;
	while(x){
		x/=10;cnt1++;
	}while(y){
		y/=10;cnt1++;
	}return max(1ll,cnt1-2ll);
}
ll arr[N];
int main()
{  fast
cin>>n;
for(int i=1;i<=n;i++)cin>>arr[i];
sort(arr+1,arr+n+1);
ll ans=1;
if(arr[1]==0ll){
	cout<<0;return 0;
}
for(int i=n;i;i--)
{
	ll x=cnt(arr[i],ans);
	if(x>18){
		cout<<-1;
		return 0;
	}
	if(x==18){
		if(check(arr[i],ans)){
			cout<<-1;return 0;
		}
	}
	ans*=arr[i];
	if(ans>1000000000000000000){
		cout<<-1;
		return 0;
	}
}

cout<<ans;




}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, k;
    std::cin >> n >> k;
    std::deque<int> v;
    for (int i = 0; i < n; i++) {
        int in;
        std::cin >> in;
        v.push_back(in);
    }
    int ret = 0;
    std::deque<int> q;
    for (int a = 1; a <= std::min(n, k); a++) {
        for (int i = 0; i <= a; i++) {
            q.insert(q.end(), v.begin(), v.begin() + i);
            q.insert(q.end(), v.end() - a + i, v.end());
            std::sort(q.begin(), q.end());
            for (int j = 0; !q.empty() && j < k - a; j++) {
                if (q.front() >= 0) break;
                q.pop_front();
            }
            ret = std::max(ret, std::accumulate(q.begin(), q.end(), 0));
            q.clear();
        }
    }
    std::cout << ret << std::endl;

    return 0;
}


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

w = set()
for i in range(F // (100 * A) + 1):
    t = F - 100 * A * i
    for j in range(t // (100 * B) + 1):
        a = (A * i + B * j) * 100
        w.add(a)
w.remove(0)

s = set()
t = E * F // 100
for i in range(t // C + 1):
    u = t - C * i
    for j in range(u // D + 1):
        b = C * i + D * j
        s.add(b)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in sorted(s):
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)


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

#define ff              first
#define ss              second
#define endl            "\n"
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerbefone(x)    __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define Pi              acos(-1.0)
#define precise(x,y)    fixed<<setprecision(y)<<x
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	FIO;

	int tt = 1;
	// cin >> tt;
	while (tt--)
	{
		int n, W, ans = INT_MIN;
		cin >> n >> W;
		int w[n + 1], v[n + 1];
		w[0] = 0; v[0] = 0;
		for (int i = 1; i <= n; i++)
			cin >> w[i] >> v[i];
		int dp[n + 1][W + 1];
		memset(dp, 0, sizeof(dp));
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= W; j++)
			{
				dp[i][j] = dp[i - 1][j];
				if (j >= w[i])
					dp[i][j] = max(dp[i][j], v[i] + dp[i - 1][j - w[i]]);
			}
		}
		for (int i = 1; i <= W; i++)
			ans = max(ans, dp[n][i]);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 82424
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S;cin>>S;
    int cnt=0;
    for(int i = 0; i < S.size()-1; i++)
    {
        if (S[i+1]==S[i]&&S[i+1]=='0') {
            /* code */
            S[i+1]='1';
            cnt++;
        
        }
        else if (S[i+1]==S[i]&&S[i+1]=='1') {
            /* code */
            S[i+1]='0';
            cnt++;
        }
        
        
    }
    cout<<cnt<<endl;
    
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int maxn = 333;

int f[maxn][maxn] , s[maxn][maxn];
int c[maxn][maxn];
int n , k , m;
int main(){
	cin >> n >> k >> m;
	memset(f , 0 , sizeof f);
	c[0][0] = 1;
	for(int i = 1 ; i <= n ; ++ i){
		c[i][0] = c[i][i] = 1;
		for(int t = 1 ; t < i ; ++ t)
			c[i][t] = (c[i - 1][t] + c[i - 1][t - 1]) % m;
	}
	for(int i = k ; i >= 0 ; -- i){
		f[1][i] = (k - i) % m;
		s[1][i] = (s[1][i + 1] + f[1][i]) % m;
	}
	for(int l = 2 ; l <= n ; ++ l)
		for(int j = k - 1 ; j >= 0 ; -- j){
			f[l][j] = (f[l][j] + 1ll * (k - j) * f[l - 1][j]) % m;
			f[l][j] = (f[l][j] + s[l - 1][j + 1]) % m;
			for(int r = 1 ; r < l - 1 ; ++ r)
				f[l][j] = (f[l][j] + 1ll * s[r][j + 1] * f[l - r - 1][j] % m * c[l - 1][r]) % m;
			s[l][j] = (s[l][j + 1] + f[l][j]) % m;
		}
	cout << f[n][0] << endl;
	return 0;
}

Measured memory_bytes: 1536
object Main extends App {
	import scala.math._

	val N = scala.io.StdIn.readInt
	val K = scala.io.StdIn.readInt

	val x = scala.io.StdIn.readLine.split(" ").map(z => min(z.toInt, K-z.toInt))

	println(x.sum * 2)

}

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

void func1() { cout << "Sunny" << endl; }
void func2() { cout << "Cloudy" << endl; }
void func3() { cout << "Rainy" << endl; }

int main()
{
    typedef map<string, void(*)()> funcs_type;

    funcs_type funcs;
    funcs.insert(make_pair("Sunny", func2));
    funcs.insert(make_pair("Cloudy", func3));
    funcs.insert(make_pair("Rainy", func1));

    string str;
    cin >> str;

    funcs_type::iterator it = funcs.find(str);
    if (it != funcs.end())
        it->second();
    else
        cout << "not found" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final long L = Long.parseLong(sc.next());
        final long R = Long.parseLong(sc.next());
        sc.close();

        int min = Integer.MAX_VALUE;

        for (long i=L; i<R; i++) {
            for (long j=i+1; j<=R; j++) {
                long mod = (i * j) % 2019;
                if (min>mod)
                    min = (int)mod;
                if (i%2019==0 || j%2019==0) {
                    System.out.println(0);
                    return;
                }
            }
        }

        System.out.println(min);
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<ll>h(n, 0);
	rep(i, n)cin >> h[i];

	bool ok = true;
	ll MAX = -1;
	rep(i, n) {
		MAX = max(MAX, h[i]);
		if (MAX - h[i] > 1) {
			ok = false;
		}
	}

	if (ok)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int main() {
  int A, B, C, D, left, right;
  cin >> A >> B >> C >> D;
  left = A+B;
  right = C+D;
  if (left > right) {
	cout << "Left" << endl;
  } else if (left < right) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "YES" << endl;
}
void No() {
    cout << "NO" << endl;
}
int main(void) {
    string s, t; cin >> s >> t;
    reverse(s.begin(), s.end());
    if(s == t) Yes();
    else No();
}


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

int main (void) {
  int n, m, x;
  cin >> n >> m >> x;
  map<int, bool> a;
  REP(i, m) {
    int in;
    cin >> in;
    a[in] = true;
  }
  int to_zero = 0;
  for (int i = x; i >= 0; i--) {
    if (a[i])
      to_zero++;
  }
  int to_n = 0;
  for (int i = x; i <= n; i++) {
    if (a[i])
      to_n++;
  }
  cout << min(to_zero, to_n) << endl;
  return 0;
}


Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val X = new Array[Int](N)
    val Y = new Array[Int](N)
    val H = new Array[Int](N)

    (0 until N) foreach { i =>
      val x, y, h = sc.nextInt()
      X(i) = x
      Y(i) = y
      H(i) = h
    }

    val range = 0 until N
    val valid = range filter (i => H(i) >= 1)

    def solve(): Option[(Int, Int, Int)] = {
      var px = 0
      while (px <= 100) {
        var py = 0
        while (py <= 100) {
          var i = 0
          val candidates = valid. map { i =>
            H(i) + Math.abs(X(i) - px) + Math.abs(Y(i) - py)
          }
          val h = candidates.head
          if (h >= 1) {
            if (candidates.forall(_ == h)) {
              if (range forall { i =>
                H(i) == Math.max(h - Math.abs(X(i) - px) - Math.abs(Y(i) - py), 0)
              }) return Some(px, py, candidates.head)
            }
          }
          py += 1
        }
        px += 1
      }
      None
    }

    solve() map (r => s"${r._1} ${r._2} ${r._3}") foreach println
  }

}


Measured memory_bytes: 35960
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

int main() {
  int n, k;
  cin >> n >> k;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    sum = x > abs(k - x) ? sum + 2 * abs(k - x) : sum + 2 * x;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a;
int main()
{
	cin>>a;
	int lena;
	lena=a.length();
	if(a[0]==a[lena-1])
	{
		if(lena%2==0)
		{
			cout<<"First";
			return 0;
		}
		if(lena%2!=0)
		{
			cout<<"Second";
			return 0;
		}
	}
	if(a[0]!=a[lena-1])
	{
		if(lena%2==0)
		{
			cout<<"Second";
			return 0;
		}
		if(lena%2!=0)
		{
			cout<<"First";
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 512